[llvm] r330249 - [CodeGen/Dwarf] Make debug_names compatible with split-dwarf

Pavel Labath via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 18 05:12:00 PDT 2018


Author: labath
Date: Wed Apr 18 05:11:59 2018
New Revision: 330249

URL: http://llvm.org/viewvc/llvm-project?rev=330249&view=rev
Log:
[CodeGen/Dwarf] Make debug_names compatible with split-dwarf

Summary:
Previously we crashed for the combination of the two features because we
tried to reference the dwo CU from the main object file. The fix
consists of two items:
- reference the skeleton CU from the name index (the consumer is
  expected to use the skeleton CU to find the real data).
- use the main object file string pool for the strings in the index

Reviewers: JDevlieghere, aprantl, dblaikie

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D45566

Modified:
    llvm/trunk/lib/CodeGen/AsmPrinter/AccelTable.cpp
    llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
    llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h
    llvm/trunk/test/DebugInfo/Generic/debug-names-one-cu.ll

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AccelTable.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AccelTable.cpp?rev=330249&r1=330248&r2=330249&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/AccelTable.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/AccelTable.cpp Wed Apr 18 05:11:59 2018
@@ -416,7 +416,9 @@ void Dwarf5AccelTableEmitter::emitCUList
   for (const auto &CU : enumerate(CompUnits)) {
     assert(CU.index() == CU.value()->getUniqueID());
     Asm->OutStreamer->AddComment("Compilation unit " + Twine(CU.index()));
-    Asm->emitDwarfSymbolReference(CU.value()->getLabelBegin());
+    const DwarfCompileUnit *MainCU =
+        DD.useSplitDwarf() ? CU.value()->getSkeleton() : CU.value().get();
+    Asm->emitDwarfSymbolReference(MainCU->getLabelBegin());
   }
 }
 

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=330249&r1=330248&r2=330249&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Wed Apr 18 05:11:59 2018
@@ -2267,6 +2267,13 @@ void DwarfDebug::addDwarfTypeUnitType(Dw
   CU.addDIETypeSignature(RefDie, Signature);
 }
 
+void DwarfDebug::addAccelDebugName(StringRef Name, const DIE &Die) {
+  assert(getAccelTableKind() == AccelTableKind::Dwarf);
+
+  DwarfFile &Holder = useSplitDwarf() ? SkeletonHolder : InfoHolder;
+  AccelDebugNames.addName(Holder.getStringPool().getEntry(*Asm, Name), Die);
+}
+
 // Accelerator table mutators - add each name along with its companion
 // DIE to the proper table while ensuring that the name that we're going
 // to reference is in the string table. We do this since the names we
@@ -2277,8 +2284,7 @@ void DwarfDebug::addAccelName(StringRef
     AccelNames.addName(InfoHolder.getStringPool().getEntry(*Asm, Name), &Die);
     break;
   case AccelTableKind::Dwarf:
-    AccelDebugNames.addName(InfoHolder.getStringPool().getEntry(*Asm, Name),
-                            Die);
+    addAccelDebugName(Name, Die);
     break;
   case AccelTableKind::None:
     return;
@@ -2300,8 +2306,7 @@ void DwarfDebug::addAccelNamespace(Strin
                            &Die);
     break;
   case AccelTableKind::Dwarf:
-    AccelDebugNames.addName(InfoHolder.getStringPool().getEntry(*Asm, Name),
-                            Die);
+    addAccelDebugName(Name, Die);
     break;
   case AccelTableKind::None:
     return;
@@ -2316,8 +2321,7 @@ void DwarfDebug::addAccelType(StringRef
     AccelTypes.addName(InfoHolder.getStringPool().getEntry(*Asm, Name), &Die);
     break;
   case AccelTableKind::Dwarf:
-    AccelDebugNames.addName(InfoHolder.getStringPool().getEntry(*Asm, Name),
-                            Die);
+    addAccelDebugName(Name, Die);
     break;
   case AccelTableKind::None:
     return;

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h?rev=330249&r1=330248&r2=330249&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h Wed Apr 18 05:11:59 2018
@@ -339,6 +339,10 @@ class DwarfDebug : public DebugHandlerBa
   /// Construct a DIE for this abstract scope.
   void constructAbstractSubprogramScopeDIE(DwarfCompileUnit &SrcCU, LexicalScope *Scope);
 
+  /// Helper function to add a name to the .debug_names table, using the
+  /// appropriate string pool.
+  void addAccelDebugName(StringRef Name, const DIE &Die);
+
   void finishVariableDefinitions();
 
   void finishSubprogramDefinitions();

Modified: llvm/trunk/test/DebugInfo/Generic/debug-names-one-cu.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/Generic/debug-names-one-cu.ll?rev=330249&r1=330248&r2=330249&view=diff
==============================================================================
--- llvm/trunk/test/DebugInfo/Generic/debug-names-one-cu.ll (original)
+++ llvm/trunk/test/DebugInfo/Generic/debug-names-one-cu.ll Wed Apr 18 05:11:59 2018
@@ -3,6 +3,10 @@
 ; RUN: llvm-dwarfdump -debug-names %t | FileCheck %s
 ; RUN: llvm-dwarfdump -debug-names -verify %t | FileCheck --check-prefix=VERIFY %s
 
+; Now try the same with split dwarf.
+; RUN: %llc_dwarf -split-dwarf-file=foo.dwo -accel-tables=Dwarf -filetype=obj -o %t < %s
+; RUN: llvm-dwarfdump -debug-names %t | FileCheck %s
+
 ; Check the header
 ; CHECK: CU count: 1
 ; CHECK: Local TU count: 0




More information about the llvm-commits mailing list