[PATCH] D87021: [DebugInfo] Fix emitting DWARF64 type units (14/19).

Igor Kudrin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 2 06:22:57 PDT 2020


ikudrin created this revision.
ikudrin added reviewers: dblaikie, jhenderson, probinson, aprantl.
ikudrin added projects: LLVM, debug-info.
Herald added subscribers: ormris, hiraditya.
ikudrin requested review of this revision.

The patch fixes emitting the offset to the type DIE. All other fields are already fixed in previous patches.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D87021

Files:
  llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
  llvm/lib/CodeGen/AsmPrinter/DwarfUnit.h
  llvm/test/DebugInfo/X86/debug-types-dwarf64.ll


Index: llvm/test/DebugInfo/X86/debug-types-dwarf64.ll
===================================================================
--- /dev/null
+++ llvm/test/DebugInfo/X86/debug-types-dwarf64.ll
@@ -0,0 +1,41 @@
+; This checks that .debug_types can be generated in the DWARF64 format.
+
+; RUN: llc -mtriple=x86_64 -dwarf-version=4 -dwarf64 -generate-type-units -filetype=obj %s -o %t
+; RUN: llvm-dwarfdump -debug-types -v %t | FileCheck %s
+
+; CHECK:      .debug_types contents:
+; CHECK-NEXT: Type Unit: {{.+}}, format = DWARF64, {{.+}}, type_offset = 0x[[OFF:.+]] (next unit at
+
+; CHECK:      0x00000027:     DW_TAG_type_unit
+
+; CHECK:      0x0000[[OFF]]:    DW_TAG_structure_type
+; CHECK-NEXT:                     DW_AT_name [DW_FORM_strp] ({{.+}} = "Foo")
+
+; CHECK:      0x{{.+}}:           DW_TAG_member
+; CHECK-NEXT:                       DW_AT_name [DW_FORM_strp] ({{.+}} = "bar")
+; CHECK-NEXT:                       DW_AT_type [DW_FORM_ref4] (cu + 0x[[BTOFF:.+]] => {0x0000[[BTOFF]]} "int")
+
+; CHECK:      0x{{.+}}:           NULL
+
+; CHECK:      0x0000[[BTOFF]]:  DW_TAG_base_type [4]  
+; CHECK-NEXT:                     DW_AT_name [DW_FORM_strp] ({{.+}} = "int")
+
+; CHECK:      0x{{.+}}:         NULL
+
+%struct.Foo = type { i32 }
+ at foo = common dso_local global %struct.Foo zeroinitializer, align 4, !dbg !5
+
+!llvm.dbg.cu = !{!2}
+!llvm.module.flags = !{!0}
+
+!0 = !{i32 2, !"Debug Info Version", i32 3}
+!1 = !DIFile(filename: "foo.c", directory: "/tmp")
+!2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "Manual", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !3, globals: !4, splitDebugInlining: false, nameTableKind: None)
+!3 = !{}
+!4 = !{!5}
+!5 = !DIGlobalVariableExpression(var: !6, expr: !DIExpression())
+!6 = distinct !DIGlobalVariable(name: "foo", scope: !2, file: !1, line: 2, type: !7, isLocal: false, isDefinition: true)
+!7 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "Foo", file: !1, line: 1, size: 32, elements: !8, identifier: "_ZTS3Foo")
+!8 = !{!9}
+!9 = !DIDerivedType(tag: DW_TAG_member, name: "bar", scope: !7, file: !1, line: 1, baseType: !10, size: 32)
+!10 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
Index: llvm/lib/CodeGen/AsmPrinter/DwarfUnit.h
===================================================================
--- llvm/lib/CodeGen/AsmPrinter/DwarfUnit.h
+++ llvm/lib/CodeGen/AsmPrinter/DwarfUnit.h
@@ -356,7 +356,7 @@
   void emitHeader(bool UseOffsets) override;
   unsigned getHeaderSize() const override {
     return DwarfUnit::getHeaderSize() + sizeof(uint64_t) + // Type Signature
-           sizeof(uint32_t);                               // Type DIE Offset
+           Asm->getDwarfOffsetByteSize();                  // Type DIE Offset
   }
   void addGlobalName(StringRef Name, const DIE &Die,
                      const DIScope *Context) override;
Index: llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
===================================================================
--- llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
+++ llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
@@ -1737,8 +1737,7 @@
   Asm->OutStreamer->emitIntValue(TypeSignature, sizeof(TypeSignature));
   Asm->OutStreamer->AddComment("Type DIE Offset");
   // In a skeleton type unit there is no type DIE so emit a zero offset.
-  Asm->OutStreamer->emitIntValue(Ty ? Ty->getOffset() : 0,
-                                 sizeof(Ty->getOffset()));
+  Asm->emitDwarfLengthOrOffset(Ty ? Ty->getOffset() : 0);
 }
 
 DIE::value_iterator


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D87021.289426.patch
Type: text/x-patch
Size: 3538 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200902/3198bafc/attachment.bin>


More information about the llvm-commits mailing list