[llvm] r204099 - DebugInfo: Implement debug_line.dwo for file names used in type units during -gsplit-dwarf

David Blaikie dblaikie at gmail.com
Mon Mar 17 18:17:26 PDT 2014


Author: dblaikie
Date: Mon Mar 17 20:17:26 2014
New Revision: 204099

URL: http://llvm.org/viewvc/llvm-project?rev=204099&view=rev
Log:
DebugInfo: Implement debug_line.dwo for file names used in type units during -gsplit-dwarf

This removes an attribute (and more importantly, a relocation) from
skeleton type units and removes some unnecessary file names from the
debug_line section that remains in the .o (and linked executable) file.

There's still a few places we could shave off some more space here:

* use compilation dir of the underlying compilation unit (since all the
  type units share that compilation dir - though this would be more
  complicated in LTO cases where they don't (keep a map of compilation
  dir->line table header?))

* Remove some of the unnecessary header fields from the line table since
  they're not needed in this situation (about 12 bytes per table).

Modified:
    llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
    llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h
    llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
    llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.h
    llvm/trunk/test/DebugInfo/X86/generate-odr-hash.ll

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=204099&r1=204098&r2=204099&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Mon Mar 17 20:17:26 2014
@@ -1060,6 +1060,7 @@ void DwarfDebug::endModule() {
     emitDebugStrDWO();
     emitDebugInfoDWO();
     emitDebugAbbrevDWO();
+    emitDebugLineDWO();
     // Emit DWO addresses.
     InfoHolder.emitAddresses(Asm->getObjFileLowering().getDwarfAddrSection());
   }
@@ -2658,7 +2659,6 @@ DwarfTypeUnit *DwarfDebug::constructSkel
   NewTU->setType(NULL);
   NewTU->initSection(
       Asm->getObjFileLowering().getDwarfTypesSection(TU->getTypeSignature()));
-  CU.applyStmtList(*Die);
 
   initSkeletonUnit(TU, Die, NewTU);
   return NewTU;
@@ -2680,6 +2680,13 @@ void DwarfDebug::emitDebugAbbrevDWO() {
   InfoHolder.emitAbbrevs(Asm->getObjFileLowering().getDwarfAbbrevDWOSection());
 }
 
+void DwarfDebug::emitDebugLineDWO() {
+  assert(useSplitDwarf() && "No split dwarf?");
+  Asm->OutStreamer.SwitchSection(
+      Asm->getObjFileLowering().getDwarfLineDWOSection());
+  Asm->OutStreamer.EmitLabel(SplitTypeUnitFileTable.Emit(&Asm->OutStreamer).second);
+}
+
 // Emit the .debug_str.dwo section for separated dwarf. This contains the
 // string section and is identical in format to traditional .debug_str
 // sections.
@@ -2708,8 +2715,9 @@ void DwarfDebug::addDwarfTypeUnitType(Dw
   }
 
   DIE *UnitDie = new DIE(dwarf::DW_TAG_type_unit);
-  DwarfTypeUnit *NewTU = new DwarfTypeUnit(InfoHolder.getUnits().size(),
-                                           UnitDie, CU, Asm, this, &InfoHolder);
+  DwarfTypeUnit *NewTU = new DwarfTypeUnit(
+      InfoHolder.getUnits().size(), UnitDie, CU, Asm, this, &InfoHolder,
+      useSplitDwarf() ? &SplitTypeUnitFileTable : nullptr);
   TU = NewTU;
   InfoHolder.addUnit(NewTU);
 

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h?rev=204099&r1=204098&r2=204099&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h Mon Mar 17 20:17:26 2014
@@ -27,6 +27,7 @@
 #include "llvm/IR/DebugInfo.h"
 #include "llvm/IR/DebugLoc.h"
 #include "llvm/MC/MachineLocation.h"
+#include "llvm/MC/MCDwarf.h"
 #include "llvm/Support/Allocator.h"
 
 namespace llvm {
@@ -486,6 +487,10 @@ class DwarfDebug : public AsmPrinterHand
   // Holder for the skeleton information.
   DwarfFile SkeletonHolder;
 
+  // Store file names for type units under fission in a line table header that
+  // will be emitted into debug_line.dwo.
+  MCDwarfLineTableHeader SplitTypeUnitFileTable;
+
   void addScopeVariable(LexicalScope *LS, DbgVariable *Var);
 
   const SmallVectorImpl<DwarfUnit *> &getUnits() {
@@ -621,6 +626,9 @@ class DwarfDebug : public AsmPrinterHand
   /// \brief Emit the debug abbrev dwo section.
   void emitDebugAbbrevDWO();
 
+  /// \brief Emit the debug line dwo section.
+  void emitDebugLineDWO();
+
   /// \brief Emit the debug str dwo section.
   void emitDebugStrDWO();
 

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp?rev=204099&r1=204098&r2=204099&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp Mon Mar 17 20:17:26 2014
@@ -56,8 +56,13 @@ DwarfCompileUnit::DwarfCompileUnit(unsig
 }
 
 DwarfTypeUnit::DwarfTypeUnit(unsigned UID, DIE *D, DwarfCompileUnit &CU,
-                             AsmPrinter *A, DwarfDebug *DW, DwarfFile *DWU)
-    : DwarfUnit(UID, D, CU.getCUNode(), A, DW, DWU), CU(CU) {}
+                             AsmPrinter *A, DwarfDebug *DW, DwarfFile *DWU,
+                             MCDwarfLineTableHeader *SplitLineTable)
+    : DwarfUnit(UID, D, CU.getCUNode(), A, DW, DWU), CU(CU),
+      SplitLineTable(SplitLineTable) {
+  if (SplitLineTable)
+    addSectionOffset(UnitDie.get(), dwarf::DW_AT_stmt_list, 0);
+}
 
 /// ~Unit - Destructor for compile unit.
 DwarfUnit::~DwarfUnit() {
@@ -307,6 +312,11 @@ unsigned DwarfCompileUnit::getOrCreateSo
       Asm->OutStreamer.hasRawTextSupport() ? 0 : getUniqueID());
 }
 
+unsigned DwarfTypeUnit::getOrCreateSourceID(StringRef FileName, StringRef DirName) {
+  return SplitLineTable ? SplitLineTable->getFile(DirName, FileName)
+                        : getCU().getOrCreateSourceID(FileName, DirName);
+}
+
 /// addOpAddress - Add a dwarf op address data and value using the
 /// form given and an op of either DW_FORM_addr or DW_FORM_GNU_addr_index.
 ///
@@ -394,7 +404,7 @@ void DwarfUnit::addSourceLine(DIE *Die,
   if (Line == 0)
     return;
 
-  unsigned FileID = getCU().getOrCreateSourceID(File, Directory);
+  unsigned FileID = getOrCreateSourceID(File, Directory);
   assert(FileID && "Invalid file id");
   addUInt(Die, dwarf::DW_AT_decl_file, None, FileID);
   addUInt(Die, dwarf::DW_AT_decl_line, None, Line);

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.h?rev=204099&r1=204098&r2=204099&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.h (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.h Mon Mar 17 20:17:26 2014
@@ -23,6 +23,7 @@
 #include "llvm/IR/DebugInfo.h"
 #include "llvm/MC/MCExpr.h"
 #include "llvm/MC/MCSection.h"
+#include "llvm/MC/MCDwarf.h"
 
 namespace llvm {
 
@@ -511,6 +512,10 @@ protected:
   /// getOrCreateStaticMemberDIE - Create new static data member DIE.
   DIE *getOrCreateStaticMemberDIE(DIDerivedType DT);
 
+  /// Look up the source ID with the given directory and source file names. If
+  /// none currently exists, create a new ID and insert it in the line table.
+  virtual unsigned getOrCreateSourceID(StringRef File, StringRef Directory) = 0;
+
 private:
   /// constructTypeDIE - Construct basic type die from DIBasicType.
   void constructTypeDIE(DIE &Buffer, DIBasicType BTy);
@@ -603,9 +608,7 @@ public:
 
   DwarfCompileUnit &getCU() override { return *this; }
 
-  /// Look up the source ID with the given directory and source file names. If
-  /// none currently exists, create a new ID and insert it in the line table.
-  unsigned getOrCreateSourceID(StringRef FileName, StringRef DirName);
+  unsigned getOrCreateSourceID(StringRef FileName, StringRef DirName) override;
 };
 
 class DwarfTypeUnit : public DwarfUnit {
@@ -613,10 +616,12 @@ private:
   uint64_t TypeSignature;
   const DIE *Ty;
   DwarfCompileUnit &CU;
+  MCDwarfLineTableHeader *SplitLineTable;
 
 public:
   DwarfTypeUnit(unsigned UID, DIE *D, DwarfCompileUnit &CU, AsmPrinter *A,
-                DwarfDebug *DW, DwarfFile *DWU);
+                DwarfDebug *DW, DwarfFile *DWU,
+                MCDwarfLineTableHeader *SplitLineTable = nullptr);
 
   void setTypeSignature(uint64_t Signature) { TypeSignature = Signature; }
   uint64_t getTypeSignature() const { return TypeSignature; }
@@ -631,6 +636,9 @@ public:
   }
   void initSection(const MCSection *Section);
   DwarfCompileUnit &getCU() override { return CU; }
+
+protected:
+  unsigned getOrCreateSourceID(StringRef File, StringRef Directory) override;
 };
 } // end llvm namespace
 #endif

Modified: llvm/trunk/test/DebugInfo/X86/generate-odr-hash.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/X86/generate-odr-hash.ll?rev=204099&r1=204098&r2=204099&view=diff
==============================================================================
--- llvm/trunk/test/DebugInfo/X86/generate-odr-hash.ll (original)
+++ llvm/trunk/test/DebugInfo/X86/generate-odr-hash.ll Mon Mar 17 20:17:26 2014
@@ -76,9 +76,9 @@
 ; FISSION-NOT: type_signature
 ; FISSION-LABEL: type_signature = 0x1d02f3be30cc5688
 ; FISSION: DW_TAG_type_unit
-; FISSION: DW_AT_stmt_list [DW_FORM_sec_offset] (0x00000000)
-; FISSION: DW_AT_GNU_dwo_name{{.*}}"bar.dwo"
-; FISSION: DW_AT_comp_dir{{.*}}"/tmp/dbginfo"
+; FISSION-NEXT: DW_AT_GNU_dwo_name{{.*}}"bar.dwo"
+; FISSION-NEXT: DW_AT_GNU_addr_base
+; FISSION-NEXT: DW_AT_comp_dir{{.*}}"/tmp/dbginfo"
 ; FISSION-NOT: type_signature
 ; FISSION-LABEL: type_signature = 0xb04af47397402e77
 ; FISSION-NOT: type_signature
@@ -120,8 +120,7 @@
 ; CHECK-NOT: type_signature
 ; CHECK-LABEL: type_signature = 0xe94f6d3843e62d6b
 ; CHECK: DW_TAG_type_unit
-; SINGLE: DW_AT_stmt_list [DW_FORM_sec_offset] (0x00000000)
-; FISSION-NOT: DW_AT_stmt_list
+; CHECK: DW_AT_stmt_list [DW_FORM_sec_offset] (0x00000000)
 ; CHECK-NOT: NULL
 ; CHECK-NOT: DW_AT_GNU_odr_signature
 ; CHECK: DW_TAG_structure_type
@@ -136,9 +135,17 @@
 ; CHECK-LABEL: .debug_line contents:
 ; CHECK: Line table prologue
 ; CHECK-NOT: file_names[
-; CHECK: file_names{{.*}} bar.h
+; SINGLE: file_names{{.*}} bar.h
 ; CHECK: file_names{{.*}} bar.cpp
 ; CHECK-NOT: file_names[
+
+; CHECK-LABEL: .debug_line.dwo contents:
+; FISSION: Line table prologue
+; FISSION-NOT: file_names[
+; FISSION: file_names{{.*}} bar.h
+; FISSION: file_names{{.*}} bar.cpp
+; FISSION-NOT: file_names[
+
 ; CHECK-LABEL: .debug_str contents:
 
 ; Use the unit size as a rough hash/identifier for the unit we're dealing with





More information about the llvm-commits mailing list