[PATCH] D101024: [Debug-Info] make DIE attributes generating under control of strict dwarf

ChenZheng via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 22 19:17:37 PDT 2021


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

1: use new wrapper function `addAttribute()`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101024

Files:
  llvm/lib/CodeGen/AsmPrinter/DwarfUnit.h
  llvm/test/DebugInfo/PowerPC/strict-dwarf.ll


Index: llvm/test/DebugInfo/PowerPC/strict-dwarf.ll
===================================================================
--- llvm/test/DebugInfo/PowerPC/strict-dwarf.ll
+++ llvm/test/DebugInfo/PowerPC/strict-dwarf.ll
@@ -2,11 +2,7 @@
 ; 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
-
-; FIXME: when -strict-dwarf=true is specified, we should check "STRICT" to tell
-; that with DWARF 4, we should not generate DWARF 5 attribute DW_AT_noreturn and
-; DW_AT_alignment.
+; RUN:   FileCheck %s -check-prefix=STRICT
 
 ; CHECK: DW_AT_alignment
 ; CHECK: DW_AT_noreturn
Index: llvm/lib/CodeGen/AsmPrinter/DwarfUnit.h
===================================================================
--- llvm/lib/CodeGen/AsmPrinter/DwarfUnit.h
+++ llvm/lib/CodeGen/AsmPrinter/DwarfUnit.h
@@ -18,6 +18,7 @@
 #include "llvm/ADT/Optional.h"
 #include "llvm/CodeGen/AsmPrinter.h"
 #include "llvm/CodeGen/DIE.h"
+#include "llvm/Target/TargetMachine.h"
 #include <string>
 
 namespace llvm {
@@ -79,6 +80,11 @@
   template <class T>
   void addAttribute(DIEValueList &Die, BumpPtrAllocator &Alloc,
                     dwarf::Attribute Attribute, dwarf::Form Form, T &&Value) {
+    // For strict DWARF mode, only generate attributes available to current
+    // DWARF version.
+    if (Attribute != 0 && Asm->TM.Options.DebugStrictDwarf &&
+        DD->getDwarfVersion() < dwarf::AttributeVersion(Attribute))
+      return;
     Die.addValue(Alloc, DIEValue(Attribute, Form, std::forward<T>(Value)));
   }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D101024.339844.patch
Type: text/x-patch
Size: 1645 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210423/c5195522/attachment.bin>


More information about the llvm-commits mailing list