From 6ea39d18c5775cbac434981fa9b419ef76d397a0 Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Tue, 18 Dec 2018 19:40:22 +0000 Subject: [PATCH] DebugInfo: Fix missing local imported entities after r349207 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 | 6 ++-- test/DebugInfo/X86/fission-local-import.ll | 33 ++++++++++++++++++++++ 2 files changed, 36 insertions(+), 3 deletions(-) create mode 100644 test/DebugInfo/X86/fission-local-import.ll diff --git a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp index 5fc8d0622a4..2d8c9e49738 100644 --- a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -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 index 00000000000..4f43a22b708 --- /dev/null +++ b/test/DebugInfo/X86/fission-local-import.ll @@ -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) + -- 2.50.1