[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
llvm-svn: 330249
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
index 177a094..a8e36ec 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -2267,6 +2267,13 @@
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 @@
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 @@
&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 @@
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;