]> granicus.if.org Git - llvm/commitdiff
DebugInfo: Fix missing local imported entities after r349207
authorDavid Blaikie <dblaikie@gmail.com>
Tue, 18 Dec 2018 19:40:22 +0000 (19:40 +0000)
committerDavid Blaikie <dblaikie@gmail.com>
Tue, 18 Dec 2018 19:40:22 +0000 (19:40 +0000)
Post commit review/bug reported by Pavel Labath - thanks!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@349528 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/AsmPrinter/DwarfDebug.cpp
test/DebugInfo/X86/fission-local-import.ll [new file with mode: 0644]

index 5fc8d0622a4667c114c116d4c053569b825fa42e..2d8c9e497388155f705894fe502285fbc0c4dc4b 100644 (file)
@@ -573,9 +573,6 @@ void DwarfDebug::finishUnitAttributes(const DICompileUnit *DIUnit,
   DIE &Die = NewCU.getUnitDie();
   StringRef FN = DIUnit->getFilename();
 
-  for (auto *IE : DIUnit->getImportedEntities())
-    NewCU.addImportedEntity(IE);
-
   // LTO with assembly output shares a single line table amongst multiple CUs.
   // To avoid the compilation directory being ambiguous, let the line table
   // explicitly describe the directory of all files, never relying on the
@@ -649,6 +646,9 @@ DwarfDebug::getOrCreateDwarfCompileUnit(const DICompileUnit *DIUnit) {
   DwarfCompileUnit &NewCU = *OwnedUnit;
   InfoHolder.addUnit(std::move(OwnedUnit));
 
+  for (auto *IE : DIUnit->getImportedEntities())
+    NewCU.addImportedEntity(IE);
+
   if (useSplitDwarf()) {
     NewCU.setSkeleton(constructSkeletonCU(NewCU));
     NewCU.setSection(Asm->getObjFileLowering().getDwarfInfoDWOSection());
diff --git a/test/DebugInfo/X86/fission-local-import.ll b/test/DebugInfo/X86/fission-local-import.ll
new file mode 100644 (file)
index 0000000..4f43a22
--- /dev/null
@@ -0,0 +1,33 @@
+; RUN: llc -split-dwarf-file=foo.dwo -O0 %s -mtriple=x86_64-unknown-linux-gnu -filetype=obj -o %t
+; RUN: llvm-dwarfdump %t | FileCheck %s
+
+; CHECK: .debug_info.dwo contents:
+; CHECK: DW_TAG_compile_unit
+; CHECK:   DW_TAG_subprogram
+; CHECK:     DW_TAG_imported_module
+
+; Function Attrs: noinline nounwind optnone uwtable
+define dso_local void @_Z4testv() !dbg !5 {
+entry:
+  ret void, !dbg !13
+}
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!9, !10, !11}
+!llvm.ident = !{!12}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 8.0.0 (trunk 349508) (llvm/trunk 349520)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, imports: !3, nameTableKind: None)
+!1 = !DIFile(filename: "test.cpp", directory: "/usr/local/google/home/blaikie/dev/scratch")
+!2 = !{}
+!3 = !{!4}
+!4 = !DIImportedEntity(tag: DW_TAG_imported_module, scope: !5, entity: !8, file: !1, line: 2)
+!5 = distinct !DISubprogram(name: "test", linkageName: "_Z4testv", scope: !1, file: !1, line: 2, type: !6, scopeLine: 2, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2)
+!6 = !DISubroutineType(types: !7)
+!7 = !{null}
+!8 = !DINamespace(name: "ns1", scope: null)
+!9 = !{i32 2, !"Dwarf Version", i32 4}
+!10 = !{i32 2, !"Debug Info Version", i32 3}
+!11 = !{i32 1, !"wchar_size", i32 4}
+!12 = !{!"clang version 8.0.0 (trunk 349508) (llvm/trunk 349520)"}
+!13 = !DILocation(line: 2, column: 36, scope: !5)
+