diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp --- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -1247,10 +1247,12 @@ ? dwarf::DW_AT_dwo_name : dwarf::DW_AT_GNU_dwo_name; finishUnitAttributes(TheCU.getCUNode(), TheCU); - TheCU.addString(TheCU.getUnitDie(), attrDWOName, - Asm->TM.Options.MCOptions.SplitDwarfFile); - SkCU->addString(SkCU->getUnitDie(), attrDWOName, - Asm->TM.Options.MCOptions.SplitDwarfFile); + StringRef embeddedDWOName = TheCU.getCUNode()->getSplitDebugFilename(); + if (embeddedDWOName.empty()) { + embeddedDWOName = Asm->TM.Options.MCOptions.SplitDwarfFile; + } + TheCU.addString(TheCU.getUnitDie(), attrDWOName, embeddedDWOName); + SkCU->addString(SkCU->getUnitDie(), attrDWOName, embeddedDWOName); // Emit a unique identifier for this CU. uint64_t ID = DIEHash(Asm, &TheCU).computeCUSignature(DWOName, TheCU.getUnitDie()); diff --git a/llvm/test/DebugInfo/X86/debug-macinfo-split-dwarf.ll b/llvm/test/DebugInfo/X86/debug-macinfo-split-dwarf.ll --- a/llvm/test/DebugInfo/X86/debug-macinfo-split-dwarf.ll +++ b/llvm/test/DebugInfo/X86/debug-macinfo-split-dwarf.ll @@ -44,7 +44,7 @@ !llvm.module.flags = !{!21, !22, !23} !llvm.ident = !{!24} -!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 10.0.0", isOptimized: false, runtimeVersion: 0, splitDebugFilename: "debug-macro-split-dwarf.dwo", emissionKind: FullDebug, enums: !2, macros: !3, nameTableKind: GNU) +!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 10.0.0", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, macros: !3, nameTableKind: GNU) !1 = !DIFile(filename: "debug-macro-split-dwarf.c", directory: "/", checksumkind: CSK_MD5, checksum: "e74d0fa8f714535c1bac6da2ffbbd898") !2 = !{} !3 = !{!4, !14, !15, !16, !17, !18, !19, !20} diff --git a/llvm/test/DebugInfo/dwo-different-name.ll b/llvm/test/DebugInfo/dwo-different-name.ll new file mode 100644 --- /dev/null +++ b/llvm/test/DebugInfo/dwo-different-name.ll @@ -0,0 +1,16 @@ +; RUN: %llc_dwarf %s -filetype=obj -o %t --split-dwarf-file from-mc-options.dwo +; RUN: llvm-dwarfdump -debug-info %t | FileCheck %s +; REQUIRES: default_triple, object-emission +; +; CHECK: DW_AT_GNU_dwo_name ("from-debuginfo.dwo") +; CHECK-NOT: DW_AT_GNU_dwo_name ("from-mc-options.dwo") + +!llvm.dbg.cu = !{!0} +!llvm.module.flags = !{!3} + +!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "Clang", isOptimized: false, runtimeVersion: 2, splitDebugFilename: "from-debuginfo.dwo", emissionKind: FullDebug, enums: !2, globals: !2, retainedTypes: !5) +!1 = !DIFile(filename: "", directory: "/") +!2 = !{} +!3 = !{i32 2, !"Debug Info Version", i32 3} +!5 = !{!6} +!6 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) diff --git a/llvm/test/tools/llvm-dwp/X86/absolute_paths.test b/llvm/test/tools/llvm-dwp/X86/absolute_paths.test --- a/llvm/test/tools/llvm-dwp/X86/absolute_paths.test +++ b/llvm/test/tools/llvm-dwp/X86/absolute_paths.test @@ -1,37 +1,37 @@ -; RUN: rm -rf %t -; RUN: mkdir -p %t -; RUN: llc %s -mtriple=x86_64-linux --split-dwarf-file=%t/test.dwo --split-dwarf-output=%t/test.dwo --filetype=obj -o %t/test.o -; RUN: llvm-dwarfdump -v %t/test.dwo | FileCheck %s -DPATH=%t -; RUN: llvm-dwp -e %t/test.o -o %t/test.dwp -; RUN: llvm-dwarfdump -v %t/test.dwp | FileCheck %s -DPATH=%t - -; CHECK-LABEL: .debug_abbrev.dwo contents: -; CHECK: DW_AT_name -; CHECK: DW_AT_GNU_dwo_name -; CHECK: DW_AT_name -; CHECK-LABEL: .debug_str.dwo contents: -; CHECK: "banana" -; CHECK: "/tmp/test.c" -; CHECK: "[[PATH]]/test.dwo" - -define void @banana() !dbg !8 { - ret void, !dbg !12 -} - -!llvm.dbg.cu = !{!0} -!llvm.module.flags = !{!3, !4, !5, !6} -!llvm.ident = !{!7} - -!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 11.0.1", isOptimized: true, runtimeVersion: 0, splitDebugFilename: "test.dwo", emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: GNU) -!1 = !DIFile(filename: "/tmp/test.c", directory: "/tmp") -!2 = !{} -!3 = !{i32 7, !"Dwarf Version", i32 4} -!4 = !{i32 2, !"Debug Info Version", i32 3} -!5 = !{i32 1, !"wchar_size", i32 4} -!6 = !{i32 7, !"PIC Level", i32 2} -!7 = !{!"clang version 11.0.1"} -!8 = distinct !DISubprogram(name: "banana", scope: !9, file: !9, line: 1, type: !10, scopeLine: 1, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !2) -!9 = !DIFile(filename: "test.c", directory: "/tmp") -!10 = !DISubroutineType(types: !11) -!11 = !{null} -!12 = !DILocation(line: 1, column: 20, scope: !8) +; RUN: rm -rf %t +; RUN: mkdir -p %t +; RUN: llc %s -mtriple=x86_64-linux --split-dwarf-file=%t/test.dwo --split-dwarf-output=%t/test.dwo --filetype=obj -o %t/test.o +; RUN: llvm-dwarfdump -v %t/test.dwo | FileCheck %s -DPATH=%t +; RUN: llvm-dwp -e %t/test.o -o %t/test.dwp +; RUN: llvm-dwarfdump -v %t/test.dwp | FileCheck %s -DPATH=%t + +; CHECK-LABEL: .debug_abbrev.dwo contents: +; CHECK: DW_AT_name +; CHECK: DW_AT_GNU_dwo_name +; CHECK: DW_AT_name +; CHECK-LABEL: .debug_str.dwo contents: +; CHECK: "banana" +; CHECK: "/tmp/test.c" +; CHECK: "[[PATH]]/test.dwo" + +define void @banana() !dbg !8 { + ret void, !dbg !12 +} + +!llvm.dbg.cu = !{!0} +!llvm.module.flags = !{!3, !4, !5, !6} +!llvm.ident = !{!7} + +!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 11.0.1", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: GNU) +!1 = !DIFile(filename: "/tmp/test.c", directory: "/tmp") +!2 = !{} +!3 = !{i32 7, !"Dwarf Version", i32 4} +!4 = !{i32 2, !"Debug Info Version", i32 3} +!5 = !{i32 1, !"wchar_size", i32 4} +!6 = !{i32 7, !"PIC Level", i32 2} +!7 = !{!"clang version 11.0.1"} +!8 = distinct !DISubprogram(name: "banana", scope: !9, file: !9, line: 1, type: !10, scopeLine: 1, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !2) +!9 = !DIFile(filename: "test.c", directory: "/tmp") +!10 = !DISubroutineType(types: !11) +!11 = !{null} +!12 = !DILocation(line: 1, column: 20, scope: !8)