[PATCH] D105687: [Debug-Info] [llvm-dwarfdump] Don't use DW_FORM_data4/8 to encode the constants for DW_AT_data_member_location.

Esme Yi via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 22 02:16:33 PDT 2021


Esme updated this revision to Diff 360738.
Esme added a comment.
Herald added a subscriber: nemanjai.

Address comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105687

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


Index: llvm/test/DebugInfo/PowerPC/data_member_location_dwarf3.ll
===================================================================
--- llvm/test/DebugInfo/PowerPC/data_member_location_dwarf3.ll
+++ llvm/test/DebugInfo/PowerPC/data_member_location_dwarf3.ll
@@ -0,0 +1,36 @@
+; RUN: llc -mtriple=powerpc64le-unknown-linux-gnu -dwarf-version=3 -O0 -o - -filetype=obj < %s | \
+; RUN:   llvm-dwarfdump -v -debug-info -name g -| FileCheck %s
+
+; CHECK: DW_AT_name [DW_FORM_strp] {{.*}} "g"
+; CHECK: DW_AT_data_member_location [DW_FORM_udata] (65536)
+
+; ModuleID = '1.cpp'
+source_filename = "1.cpp"
+
+%struct.e = type { [65536 x i8], i8 }
+
+ at E = dso_local local_unnamed_addr global %struct.e zeroinitializer, align 1, !dbg !0
+
+!llvm.dbg.cu = !{!2}
+!llvm.module.flags = !{!14, !15, !16, !17}
+!llvm.ident = !{!18}
+
+!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
+!1 = distinct !DIGlobalVariable(name: "E", scope: !2, file: !3, line: 5, type: !6, isLocal: false, isDefinition: true)
+!2 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !3, producer: "clang version 13.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !5, splitDebugInlining: false, nameTableKind: None)
+!3 = !DIFile(filename: "1.cpp", directory: "/tmp")
+!4 = !{}
+!5 = !{!0}
+!6 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "e", file: !3, line: 1, size: 524296, flags: DIFlagTypePassByValue, elements: !7, identifier: "_ZTS1e")
+!7 = !{!8, !13}
+!8 = !DIDerivedType(tag: DW_TAG_member, name: "f", scope: !6, file: !3, line: 2, baseType: !9, size: 524288)
+!9 = !DICompositeType(tag: DW_TAG_array_type, baseType: !10, size: 524288, elements: !11)
+!10 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_unsigned_char)
+!11 = !{!12}
+!12 = !DISubrange(count: 65536)
+!13 = !DIDerivedType(tag: DW_TAG_member, name: "g", scope: !6, file: !3, line: 3, baseType: !10, size: 8, offset: 524288)
+!14 = !{i32 7, !"Dwarf Version", i32 3}
+!15 = !{i32 2, !"Debug Info Version", i32 3}
+!16 = !{i32 1, !"wchar_size", i32 4}
+!17 = !{i32 7, !"uwtable", i32 1}
+!18 = !{!"clang version 13.0.0"}
Index: llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
===================================================================
--- llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
+++ llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
@@ -1618,9 +1618,18 @@
       addUInt(*MemLocationDie, dwarf::DW_FORM_data1, dwarf::DW_OP_plus_uconst);
       addUInt(*MemLocationDie, dwarf::DW_FORM_udata, OffsetInBytes);
       addBlock(MemberDie, dwarf::DW_AT_data_member_location, MemLocationDie);
-    } else if (!IsBitfield || DD->useDWARF2Bitfields())
-      addUInt(MemberDie, dwarf::DW_AT_data_member_location, None,
-              OffsetInBytes);
+    } else if (!IsBitfield || DD->useDWARF2Bitfields()) {
+      // In DWARF v3, DW_FORM_data4/8 in DW_AT_data_member_location are
+      // interpreted as location-list pointers. Interpretating constants into
+      // pointers is not expected, so we use DW_FORM_udata to encode the
+      // constants here.
+      if (DD->getDwarfVersion() == 3)
+        addUInt(MemberDie, dwarf::DW_AT_data_member_location,
+                dwarf::DW_FORM_udata, OffsetInBytes);
+      else
+        addUInt(MemberDie, dwarf::DW_AT_data_member_location, None,
+                OffsetInBytes);
+    }
   }
 
   if (DT->isProtected())


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D105687.360738.patch
Type: text/x-patch
Size: 3392 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210722/29e862f0/attachment.bin>


More information about the llvm-commits mailing list