[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
Tue Apr 20 01:35:23 PDT 2021


shchenz updated this revision to Diff 338765.
shchenz added a comment.

1: use strict dwarf flag instead of DBX debugger


Repository:
  rG LLVM Github Monorepo

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

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:   -strict-dwarf=true < %s | llvm-dwarfdump -debug-info - | \
+; RUN:   FileCheck %s --check-prefix=STRICT
+
+; CHECK: DW_AT_noreturn
+; STRICT-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
@@ -36,6 +36,7 @@
 #include "llvm/Support/Casting.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Target/TargetLoweringObjectFile.h"
+#include "llvm/Target/TargetMachine.h"
 #include <cassert>
 #include <cstdint>
 #include <string>
@@ -1274,7 +1275,10 @@
   if (SP->isRValueReference())
     addFlag(SPDie, dwarf::DW_AT_rvalue_reference);
 
-  if (SP->isNoReturn())
+  // DW_AT_noreturn was introduced in DWARF 5, in strict DWARF mode, only
+  // generate this attribute when DWARF version is not smaller than 5.
+  if (SP->isNoReturn() &&
+      (!Asm->TM.Options.DebugStrictDwarf || DD->getDwarfVersion() >= 5))
     addFlag(SPDie, dwarf::DW_AT_noreturn);
 
   if (SP->isProtected())


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D100628.338765.patch
Type: text/x-patch
Size: 2541 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210420/3724915c/attachment.bin>


More information about the llvm-commits mailing list