[PATCH] D100630: [Debug-Info][DBX] DW_TAG_rvalue_reference_type should not be generated when dwarf version is smaller than 4

ChenZheng via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon May 10 00:37:12 PDT 2021


shchenz updated this revision to Diff 343983.
shchenz added a comment.
Herald added subscribers: llvm-commits, hiraditya, nemanjai.
Herald added a project: LLVM.

update according to @dblaikie comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100630

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


Index: llvm/test/DebugInfo/PowerPC/strict-dwarf-tags.ll
===================================================================
--- /dev/null
+++ llvm/test/DebugInfo/PowerPC/strict-dwarf-tags.ll
@@ -0,0 +1,43 @@
+; 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
+
+; If not strict DWARF mode, we expect DW_TAG_rvalue_reference_type at DWARF 3.
+; If strict DWARF mode, we expect DW_TAG_reference_type at DWARF 3 as DW_TAG_rvalue_reference_type
+; is a DWARF 4 tag.
+
+; CHECK: DW_TAG_rvalue_reference_type
+; STRICT: DW_TAG_reference_type
+
+define void @_Z3fooOi(i32* dereferenceable(4) %i) !dbg !8 {
+entry:
+  call void @llvm.dbg.value(metadata i32* %i, metadata !14, metadata !DIExpression()), !dbg !15
+  ret void, !dbg !16
+}
+
+; Function Attrs: nofree nosync nounwind readnone speculatable willreturn
+declare void @llvm.dbg.value(metadata, metadata, metadata) #1
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!3, !4, !5, !6}
+!llvm.ident = !{!7}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 13.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: None)
+!1 = !DIFile(filename: "1.cpp", directory: "./")
+!2 = !{}
+!3 = !{i32 7, !"Dwarf Version", i32 3}
+!4 = !{i32 2, !"Debug Info Version", i32 3}
+!5 = !{i32 1, !"wchar_size", i32 4}
+!6 = !{i32 7, !"uwtable", i32 1}
+!7 = !{!"clang version 13.0.0"}
+!8 = distinct !DISubprogram(name: "foo", linkageName: "_Z3fooOi", scope: !1, file: !1, line: 1, type: !9, scopeLine: 2, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !13)
+!9 = !DISubroutineType(types: !10)
+!10 = !{null, !11}
+!11 = !DIDerivedType(tag: DW_TAG_rvalue_reference_type, baseType: !12, size: 64)
+!12 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
+!13 = !{!14}
+!14 = !DILocalVariable(name: "i", arg: 1, scope: !8, file: !1, line: 1, type: !11)
+!15 = !DILocation(line: 0, scope: !8)
+!16 = !DILocation(line: 3, column: 1, scope: !8)
Index: llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
===================================================================
--- llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
+++ llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
@@ -386,7 +386,20 @@
 }
 
 DIE &DwarfUnit::createAndAddDIE(unsigned Tag, DIE &Parent, const DINode *N) {
-  DIE &Die = Parent.addChild(DIE::get(DIEValueAllocator, (dwarf::Tag)Tag));
+  // For strict DWARF mode, only generate tags available to current DWARF
+  // version.
+  dwarf::Tag FixedTag = (dwarf::Tag)Tag;
+  if (Asm->TM.Options.DebugStrictDwarf &&
+      DD->getDwarfVersion() < dwarf::TagVersion(FixedTag)) {
+    // See if there is any replacement for some tags.
+    if (FixedTag == dwarf::DW_TAG_rvalue_reference_type &&
+        DD->getDwarfVersion() >= 3)
+      FixedTag = dwarf::DW_TAG_reference_type;
+
+    // Assertion for other cases.
+    assert(true && "Tag is generated not following strict DWARF!");
+  }
+  DIE &Die = Parent.addChild(DIE::get(DIEValueAllocator, FixedTag));
   if (N)
     insertDIE(N, &Die);
   return Die;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D100630.343983.patch
Type: text/x-patch
Size: 3392 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210510/f872929c/attachment-0001.bin>


More information about the llvm-commits mailing list