[llvm] r196600 - DebugInfo: Ensure unit IDs (for non-skeletal units) match thein index in the list

David Blaikie dblaikie at gmail.com
Fri Dec 6 11:38:47 PST 2013


Author: dblaikie
Date: Fri Dec  6 13:38:46 2013
New Revision: 196600

URL: http://llvm.org/viewvc/llvm-project?rev=196600&view=rev
Log:
DebugInfo: Ensure unit IDs (for non-skeletal units) match thein index in the list

This simplifies reasoning about the code and enables simple navigation
from a skeleton to its full unit. (currently there are no type unit
skeletons, so the skeleton list doesn't have the same ID == index
property)

Eventually we should get rid of this ID and just store the labels we
need as the IDs are allowing this code to create difficult to
manage/understand associations (loops over non-skeletal units are
implicitly referencing their skeletal units during pub* emission, for
example). It may be necessary to have some kind of skeleton->full unit
association and a more direct pointer or similar device would be
preferable than an index.

Modified:
    llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
    llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.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=196600&r1=196599&r2=196600&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Fri Dec  6 13:38:46 2013
@@ -179,7 +179,7 @@ static unsigned getDwarfVersionFromModul
 
 DwarfDebug::DwarfDebug(AsmPrinter *A, Module *M)
     : Asm(A), MMI(Asm->MMI), FirstCU(0), SourceIdMap(DIEValueAllocator),
-      PrevLabel(NULL), GlobalCUIndexCount(0), GlobalRangeCount(0),
+      PrevLabel(NULL), GlobalRangeCount(0),
       InfoHolder(A, "info_string", DIEValueAllocator),
       SkeletonHolder(A, "skel_string", DIEValueAllocator) {
 
@@ -747,8 +747,10 @@ CompileUnit *DwarfDebug::constructCompil
   CompilationDir = DIUnit.getDirectory();
 
   DIE *Die = new DIE(dwarf::DW_TAG_compile_unit);
-  CompileUnit *NewCU = new CompileUnit(GlobalCUIndexCount++, Die, DIUnit, Asm,
-                                       this, &InfoHolder);
+  CompileUnit *NewCU = new CompileUnit(InfoHolder.getUnits().size(), Die,
+                                       DIUnit, Asm, this, &InfoHolder);
+  InfoHolder.addUnit(NewCU);
+
 
   FileIDCUMap[NewCU->getUniqueID()] = 0;
   // Call this to emit a .file directive if it wasn't emitted for the source
@@ -816,8 +818,6 @@ CompileUnit *DwarfDebug::constructCompil
   if (!FirstCU)
     FirstCU = NewCU;
 
-  InfoHolder.addUnit(NewCU);
-
   CUMap.insert(std::make_pair(DIUnit, NewCU));
   CUDieMap.insert(std::make_pair(Die, NewCU));
   return NewCU;
@@ -3048,8 +3048,10 @@ void DwarfDebug::addTypeUnitType(uint16_
     }
   } else {
     DIE *UnitDie = new DIE(dwarf::DW_TAG_type_unit);
-    TypeUnit *NewTU = new TypeUnit(GlobalCUIndexCount++, UnitDie, Language, Asm,
-                                   this, &InfoHolder);
+    TypeUnit *NewTU = new TypeUnit(InfoHolder.getUnits().size(), UnitDie,
+                                   Language, Asm, this, &InfoHolder);
+    InfoHolder.addUnit(NewTU);
+
     NewTU->addUInt(UnitDie, dwarf::DW_AT_language, dwarf::DW_FORM_data2,
                    Language);
 
@@ -3077,8 +3079,6 @@ void DwarfDebug::addTypeUnitType(uint16_
     // Remove the References vector and add the type hash.
     I->second.first = Signature;
     I->second.second = NULL;
-
-    InfoHolder.addUnit(NewTU);
   }
 
   // Populate all the signatures.

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h?rev=196600&r1=196599&r2=196600&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h Fri Dec  6 13:38:46 2013
@@ -437,9 +437,6 @@ class DwarfDebug : public AsmPrinterHand
   // table for the same directory as DW_AT_comp_dir.
   StringRef CompilationDir;
 
-  // Counter for assigning globally unique IDs for CUs.
-  unsigned GlobalCUIndexCount;
-
   // Counter for assigning globally unique IDs for ranges.
   unsigned GlobalRangeCount;
 

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=196600&r1=196599&r2=196600&view=diff
==============================================================================
--- llvm/trunk/test/DebugInfo/X86/generate-odr-hash.ll (original)
+++ llvm/trunk/test/DebugInfo/X86/generate-odr-hash.ll Fri Dec  6 13:38:46 2013
@@ -76,6 +76,9 @@
 
 ; Check that we generate a hash for wombat and the value, but not for the
 ; anonymous type contained within.
+; CHECK-LABEL: DW_AT_GNU_odr_signature [DW_FORM_data8] (0x685bcc220141e9d7)
+; CHECK: DW_TAG_structure_type
+; CHECK-NEXT: debug_str{{.*}}"wombat"
 ; CHECK: DW_TAG_type_unit
 ; CHECK: DW_TAG_structure_type
 ; The signature for the outer 'wombat' type - this can be FileChecked once the
@@ -87,9 +90,6 @@
 ; CHECK-NOT: DW_AT_GNU_odr_signature
 ; CHECK: DW_TAG_member
 ; CHECK-NEXT: debug_str{{.*}}"a"
-; CHECK-LABEL: DW_AT_GNU_odr_signature [DW_FORM_data8] (0x685bcc220141e9d7)
-; CHECK: DW_TAG_structure_type
-; CHECK-NEXT: debug_str{{.*}}"wombat"
 
 ; Use the unit size as a rough hash/identifier for the unit we're dealing with
 ; it happens to be unambiguous at the moment, but it's hardly ideal.
@@ -108,12 +108,12 @@
 ; CHECK-NEXT: unit_size = 0x0000002f
 ; CHECK-NEXT: Offset Name
 ; CHECK-NEXT: "walrus"
-; CHECK-NEXT: unit_size = 0x0000003f
-; CHECK-NEXT: Offset Name
-; CHECK-NEXT: "int"
 ; CHECK-NEXT: unit_size = 0x00000036
 ; CHECK-NEXT: Offset Name
 ; CHECK-NEXT: "wombat"
+; CHECK-NEXT: unit_size = 0x0000003f
+; CHECK-NEXT: Offset Name
+; CHECK-NEXT: "int"
 
 %struct.bar = type { i8 }
 %"class.echidna::capybara::mongoose::fluffy" = type { i32, i32 }





More information about the llvm-commits mailing list