[PATCH] D115485: [DwarfDebug] Prioritise DWARF filename in debuginfo over MC Target Options

Andy Wang via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 10 03:50:50 PST 2021


cbeuw updated this revision to Diff 393439.
cbeuw added a comment.

Fix line endings


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D115485/new/

https://reviews.llvm.org/D115485

Files:
  llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
  llvm/test/DebugInfo/X86/debug-macinfo-split-dwarf.ll
  llvm/test/DebugInfo/dwo-different-name.ll
  llvm/test/tools/llvm-dwp/X86/absolute_paths.test


Index: llvm/test/tools/llvm-dwp/X86/absolute_paths.test
===================================================================
--- llvm/test/tools/llvm-dwp/X86/absolute_paths.test
+++ llvm/test/tools/llvm-dwp/X86/absolute_paths.test
@@ -22,7 +22,7 @@
 !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)
+!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}
Index: llvm/test/DebugInfo/dwo-different-name.ll
===================================================================
--- /dev/null
+++ 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: "<stdin>", directory: "/")
+!2 = !{}
+!3 = !{i32 2, !"Debug Info Version", i32 3}
+!5 = !{!6}
+!6 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
Index: llvm/test/DebugInfo/X86/debug-macinfo-split-dwarf.ll
===================================================================
--- llvm/test/DebugInfo/X86/debug-macinfo-split-dwarf.ll
+++ 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}
Index: llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
===================================================================
--- llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ 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());


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D115485.393439.patch
Type: text/x-patch
Size: 3984 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211210/b6fec0e8/attachment.bin>


More information about the llvm-commits mailing list