[llvm] 03b09c6 - [DebugInfo] Fix emitting pre-v5 name lookup tables in the DWARF64 format (12/19).
Igor Kudrin via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 14 22:24:39 PDT 2020
Author: Igor Kudrin
Date: 2020-09-15T12:23:30+07:00
New Revision: 03b09c6b68bbce80bea47db40ad85809d363b260
URL: https://github.com/llvm/llvm-project/commit/03b09c6b68bbce80bea47db40ad85809d363b260
DIFF: https://github.com/llvm/llvm-project/commit/03b09c6b68bbce80bea47db40ad85809d363b260.diff
LOG: [DebugInfo] Fix emitting pre-v5 name lookup tables in the DWARF64 format (12/19).
The transition is done by using methods of AsmPrinter which
automatically emit values in compliance with the selected DWARF format.
Differential Revision: https://reviews.llvm.org/D87013
Added:
llvm/test/DebugInfo/X86/debug-pubtables-dwarf64.ll
Modified:
llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
Removed:
################################################################################
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
index 2938444e0ff7..ced05a27c4e6 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -2336,10 +2336,10 @@ void DwarfDebug::emitDebugPubSection(bool GnuStyle, StringRef Name,
TheU = Skeleton;
// Emit the header.
- Asm->OutStreamer->AddComment("Length of Public " + Name + " Info");
MCSymbol *BeginLabel = Asm->createTempSymbol("pub" + Name + "_begin");
MCSymbol *EndLabel = Asm->createTempSymbol("pub" + Name + "_end");
- Asm->emitLabelDifference(EndLabel, BeginLabel, 4);
+ Asm->emitDwarfUnitLength(EndLabel, BeginLabel,
+ "Length of Public " + Name + " Info");
Asm->OutStreamer->emitLabel(BeginLabel);
@@ -2350,7 +2350,7 @@ void DwarfDebug::emitDebugPubSection(bool GnuStyle, StringRef Name,
emitSectionReference(*TheU);
Asm->OutStreamer->AddComment("Compilation Unit Length");
- Asm->emitInt32(TheU->getLength());
+ Asm->emitDwarfLengthOrOffset(TheU->getLength());
// Emit the pubnames for this compilation unit.
for (const auto &GI : Globals) {
@@ -2358,7 +2358,7 @@ void DwarfDebug::emitDebugPubSection(bool GnuStyle, StringRef Name,
const DIE *Entity = GI.second;
Asm->OutStreamer->AddComment("DIE offset");
- Asm->emitInt32(Entity->getOffset());
+ Asm->emitDwarfLengthOrOffset(Entity->getOffset());
if (GnuStyle) {
dwarf::PubIndexEntryDescriptor Desc = computeIndexValue(TheU, Entity);
@@ -2373,7 +2373,7 @@ void DwarfDebug::emitDebugPubSection(bool GnuStyle, StringRef Name,
}
Asm->OutStreamer->AddComment("End Mark");
- Asm->emitInt32(0);
+ Asm->emitDwarfLengthOrOffset(0);
Asm->OutStreamer->emitLabel(EndLabel);
}
diff --git a/llvm/test/DebugInfo/X86/debug-pubtables-dwarf64.ll b/llvm/test/DebugInfo/X86/debug-pubtables-dwarf64.ll
new file mode 100644
index 000000000000..5ac3551e68d3
--- /dev/null
+++ b/llvm/test/DebugInfo/X86/debug-pubtables-dwarf64.ll
@@ -0,0 +1,54 @@
+; This checks that .debug_pubnames and .debug_pubtypes can be generated in the DWARF64 format.
+
+; RUN: llc -mtriple=x86_64 -dwarf64 -filetype=obj %s -o %t
+; RUN: llvm-dwarfdump -debug-info -debug-pubnames -debug-pubtypes %t | FileCheck %s
+
+; CHECK: .debug_info contents:
+; CHECK: 0x[[VAR:.+]]: DW_TAG_variable
+; CHECK-NEXT: DW_AT_name ("foo")
+; CHECK: 0x[[STRUCT:.+]]: DW_TAG_structure_type
+; CHECK-NEXT: DW_AT_name ("Foo")
+; CHECK: 0x[[BASET:.+]]: DW_TAG_base_type
+; CHECK-NEXT: DW_AT_name ("int")
+
+; CHECK: .debug_pubnames contents:
+; CHECK-NEXT: length = 0x0000000000000026, format = DWARF64, version = 0x0002, unit_offset =
+; CHECK-NEXT: Offset Name
+; CHECK-NEXT: 0x00000000[[VAR]] "foo"
+
+; CHECK: .debug_pubtypes contents:
+; CHECK-NEXT: length = 0x0000000000000032, format = DWARF64, version = 0x0002, unit_offset =
+; CHECK-NEXT: Offset Name
+; CHECK-NEXT: 0x00000000[[STRUCT]] "Foo"
+; CHECK-NEXT: 0x00000000[[BASET]] "int"
+
+; IR generated and reduced from:
+; $ cat foo.c
+; struct Foo { int bar; };
+; struct Foo foo;
+; $ clang -g -gpubnames -S -emit-llvm foo.c -o foo.ll
+
+target triple = "x86_64-unknown-linux-gnu"
+
+%struct.Foo = type { i32 }
+
+ at foo = dso_local global %struct.Foo zeroinitializer, align 4, !dbg !0
+
+!llvm.dbg.cu = !{!2}
+!llvm.module.flags = !{!10, !11, !12}
+!llvm.ident = !{!13}
+
+!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
+!1 = distinct !DIGlobalVariable(name: "foo", scope: !2, file: !3, line: 2, type: !6, isLocal: false, isDefinition: true)
+!2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "clang version 12.0.0", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !5, splitDebugInlining: false)
+!3 = !DIFile(filename: "foo.c", directory: "/tmp")
+!4 = !{}
+!5 = !{!0}
+!6 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "Foo", file: !3, line: 1, size: 32, elements: !7)
+!7 = !{!8}
+!8 = !DIDerivedType(tag: DW_TAG_member, name: "bar", scope: !6, file: !3, line: 1, baseType: !9, size: 32)
+!9 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
+!10 = !{i32 7, !"Dwarf Version", i32 4}
+!11 = !{i32 2, !"Debug Info Version", i32 3}
+!12 = !{i32 1, !"wchar_size", i32 4}
+!13 = !{!"clang version 12.0.0"}
More information about the llvm-commits
mailing list