[PATCH] D100628: [Debug-Info][DBX] DW_AT_noreturn should not be generated when dwarf version is not 5

ChenZheng via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 16 02:25:19 PDT 2021


shchenz created this revision.
shchenz added reviewers: dblaikie, aprantl, probinson, jsji, Esme, PowerPC, echristo.
shchenz added a project: debug-info.
Herald added subscribers: hiraditya, nemanjai.
shchenz requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

As discussed in D99250 <https://reviews.llvm.org/D99250> , we added a new tuning debugger DBX(D99400 <https://reviews.llvm.org/D99400>) to add some debug info customizations for DBX on AIX.

This is part of the customizations, not generating DWARF infos not matching the DWARF version.

This patch is for attribute DW_AT_noreturn which is introduced in DWARF 5.

Now for DBX, we only generate this attribute when DWARF version is 5 or higher.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D100628

Files:
  llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
  llvm/test/DebugInfo/PowerPC/noreturn.ll


Index: llvm/test/DebugInfo/PowerPC/noreturn.ll
===================================================================
--- /dev/null
+++ llvm/test/DebugInfo/PowerPC/noreturn.ll
@@ -0,0 +1,35 @@
+; RUN: llc -filetype=obj -mtriple=powerpc64le-unknown-linux-gnu < %s | \
+; RUN:   llvm-dwarfdump -debug-info - | FileCheck %s
+; RUN: llc -filetype=obj -mtriple=powerpc64le-unknown-linux-gnu \
+; RUN:   -debugger-tune=dbx < %s | llvm-dwarfdump -debug-info - | \
+; RUN:   FileCheck %s --check-prefix=DBX
+
+; CHECK: DW_AT_noreturn
+; DBX-NOT: DW_AT_noreturn
+
+; Function Attrs: noreturn
+define dso_local void @_Z1fv() #0 !dbg !7 {
+  call void @_Z4exitv() #2, !dbg !10
+  unreachable, !dbg !10
+}
+
+; Function Attrs: noreturn
+declare void @_Z4exitv() #1
+
+attributes #0 = { noreturn }
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!3, !4, !5}
+!llvm.ident = !{!6}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 13.0.0", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: None)
+!1 = !DIFile(filename: "noreturn.cpp", directory: "./")
+!2 = !{}
+!3 = !{i32 7, !"Dwarf Version", i32 4}
+!4 = !{i32 2, !"Debug Info Version", i32 3}
+!5 = !{i32 1, !"wchar_size", i32 4}
+!6 = !{!"clang version 13.0.0"}
+!7 = distinct !DISubprogram(name: "f", linkageName: "_Z1fv", scope: !1, file: !1, line: 2, type: !8, scopeLine: 2, flags: DIFlagPrototyped | DIFlagNoReturn, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2)
+!8 = !DISubroutineType(types: !9)
+!9 = !{null}
+!10 = !DILocation(line: 3, column: 3, scope: !7)
Index: llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
===================================================================
--- llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
+++ llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
@@ -1274,7 +1274,9 @@
   if (SP->isRValueReference())
     addFlag(SPDie, dwarf::DW_AT_rvalue_reference);
 
-  if (SP->isNoReturn())
+  // For DBX, we only generate DWARF 5 attribute when the DWARF version is no
+  // less than 5.
+  if (SP->isNoReturn() && (!DD->tuneForDBX() || DD->getDwarfVersion() >= 5))
     addFlag(SPDie, dwarf::DW_AT_noreturn);
 
   if (SP->isProtected())


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D100628.338031.patch
Type: text/x-patch
Size: 2220 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210416/326ec739/attachment-0001.bin>


More information about the llvm-commits mailing list