mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 03:02:36 +01:00
[DebugInfo] Add the -dwarf64 switch to llc and other internal tools (4/19).
The patch adds a switch to enable emitting debug info in the 64-bit DWARF format. Most emitter for sections will be updated in the subsequent patches, whereas for .debug_line and .debug_frame the emitters are in the MC library, which is already updated. For now, the switch is enabled only for 64-bit ELF targets. Differential Revision: https://reviews.llvm.org/D87011
This commit is contained in:
parent
a07977eed6
commit
bac464f625
@ -373,6 +373,11 @@ DwarfDebug::DwarfDebug(AsmPrinter *A, Module *M)
|
||||
DwarfVersion =
|
||||
TT.isNVPTX() ? 2 : (DwarfVersion ? DwarfVersion : dwarf::DWARF_VERSION);
|
||||
|
||||
bool Dwarf64 = Asm->TM.Options.MCOptions.Dwarf64 &&
|
||||
DwarfVersion >= 3 && // DWARF64 was introduced in DWARFv3.
|
||||
TT.isArch64Bit() && // DWARF64 requires 64-bit relocations.
|
||||
TT.isOSBinFormatELF(); // Support only ELF for now.
|
||||
|
||||
UseRangesSection = !NoDwarfRangesSection && !TT.isNVPTX();
|
||||
|
||||
// Use sections as references. Force for NVPTX.
|
||||
@ -414,6 +419,8 @@ DwarfDebug::DwarfDebug(AsmPrinter *A, Module *M)
|
||||
DwarfVersion >= 5 || (UseGNUDebugMacro && !useSplitDwarf());
|
||||
|
||||
Asm->OutStreamer->getContext().setDwarfVersion(DwarfVersion);
|
||||
Asm->OutStreamer->getContext().setDwarfFormat(Dwarf64 ? dwarf::DWARF64
|
||||
: dwarf::DWARF32);
|
||||
}
|
||||
|
||||
// Define out of line so we don't have to include DwarfUnit.h in DwarfDebug.h.
|
||||
|
37
test/DebugInfo/X86/debug-frame-dwarf64.ll
Normal file
37
test/DebugInfo/X86/debug-frame-dwarf64.ll
Normal file
@ -0,0 +1,37 @@
|
||||
; This checks that .debug_frame can be generated in the DWARF64 format.
|
||||
|
||||
; RUN: llc -mtriple=x86_64 -dwarf64 -force-dwarf-frame-section -filetype=obj %s -o %t
|
||||
; RUN: llvm-dwarfdump -debug-frame %t | FileCheck %s
|
||||
|
||||
; CHECK: .debug_frame contents:
|
||||
; CHECK: 00000000 {{.+}} ffffffffffffffff CIE
|
||||
; CHECK-NEXT: Format: DWARF64
|
||||
; CHECK: {{.+}} 0000000000000000 FDE cie=00000000 pc=
|
||||
; CHECK-NEXT: Format: DWARF64
|
||||
|
||||
; IR generated and reduced from:
|
||||
; $ cat foo.c
|
||||
; void foo() { }
|
||||
; $ clang -g -S -emit-llvm foo.c -o foo.ll
|
||||
|
||||
target triple = "x86_64-unknown-linux-gnu"
|
||||
|
||||
define dso_local void @foo() #0 !dbg !7 {
|
||||
ret void, !dbg !10
|
||||
}
|
||||
|
||||
!llvm.dbg.cu = !{!0}
|
||||
!llvm.module.flags = !{!3, !4, !5}
|
||||
!llvm.ident = !{!6}
|
||||
|
||||
!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 12.0.0", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: None)
|
||||
!1 = !DIFile(filename: "foo.c", directory: "/tmp")
|
||||
!2 = !{}
|
||||
!3 = !{i32 7, !"Dwarf Version", i32 4}
|
||||
!4 = !{i32 2, !"Debug Info Version", i32 3}
|
||||
!5 = !{i32 1, !"wchar_size", i32 4}
|
||||
!6 = !{!"clang version 12.0.0"}
|
||||
!7 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 1, type: !8, scopeLine: 1, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2)
|
||||
!8 = !DISubroutineType(types: !9)
|
||||
!9 = !{null}
|
||||
!10 = !DILocation(line: 1, column: 14, scope: !7)
|
35
test/DebugInfo/X86/debug-line-dwarf64.ll
Normal file
35
test/DebugInfo/X86/debug-line-dwarf64.ll
Normal file
@ -0,0 +1,35 @@
|
||||
; This checks that .debug_line can be generated in the DWARF64 format.
|
||||
|
||||
; RUN: llc -mtriple=x86_64 -dwarf-version=3 -dwarf64 -filetype=obj %s -o %t3
|
||||
; RUN: llvm-dwarfdump -debug-line %t3 | FileCheck %s
|
||||
|
||||
; CHECK: .debug_line contents:
|
||||
; CHECK-NEXT: debug_line[0x00000000]
|
||||
; CHECK-NEXT: Line table prologue:
|
||||
; CHECK-NEXT: total_length:
|
||||
; CHECK-NEXT: format: DWARF64
|
||||
|
||||
; IR generated and reduced from:
|
||||
; $ cat foo.c
|
||||
; int foo;
|
||||
; $ clang -g -S -emit-llvm foo.c -o foo.ll
|
||||
|
||||
target triple = "x86_64-unknown-linux-gnu"
|
||||
|
||||
@foo = dso_local global i32 0, align 4, !dbg !0
|
||||
|
||||
!llvm.dbg.cu = !{!2}
|
||||
!llvm.module.flags = !{!7, !8, !9}
|
||||
!llvm.ident = !{!10}
|
||||
|
||||
!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
|
||||
!1 = distinct !DIGlobalVariable(name: "foo", scope: !2, file: !3, line: 1, 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, nameTableKind: None)
|
||||
!3 = !DIFile(filename: "foo.c", directory: "/tmp")
|
||||
!4 = !{}
|
||||
!5 = !{!0}
|
||||
!6 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
|
||||
!7 = !{i32 7, !"Dwarf Version", i32 4}
|
||||
!8 = !{i32 2, !"Debug Info Version", i32 3}
|
||||
!9 = !{i32 1, !"wchar_size", i32 4}
|
||||
!10 = !{!"clang version 12.0.0"}
|
59
test/DebugInfo/X86/dwarf64-support.ll
Normal file
59
test/DebugInfo/X86/dwarf64-support.ll
Normal file
@ -0,0 +1,59 @@
|
||||
; This checks cases when the 64-bit DWARF debug info should not be generated
|
||||
; even if '-dwarf64' is specified.
|
||||
|
||||
; The 64-bit DWARF format was introduced in DWARFv3, so the '-dwarf64' switch
|
||||
; should be ignored for earlier versions.
|
||||
; RUN: llc -mtriple=x86_64 -dwarf-version=2 -dwarf64 -filetype=obj %s -o - | \
|
||||
; RUN: llvm-dwarfdump -debug-line - | \
|
||||
; RUN: FileCheck %s --check-prefixes=ELF64,CHECK
|
||||
|
||||
; DWARF64 requires 64-bit relocations, so it is not produced for 32-bit targets.
|
||||
; RUN: llc -mtriple=i386 -dwarf-version=5 -dwarf64 -filetype=obj %s -o - | \
|
||||
; RUN: llvm-dwarfdump -debug-line - | \
|
||||
; RUN: FileCheck %s --check-prefixes=ELF32,CHECK
|
||||
|
||||
; DWARF64 is enabled only for ELF targets. The switch should be ignored for COFF.
|
||||
; RUN: llc -mtriple=x86_64-windows-gnu -dwarf-version=5 -dwarf64 -filetype=obj %s -o - | \
|
||||
; RUN: llvm-dwarfdump -debug-line - | \
|
||||
; RUN: FileCheck %s --check-prefixes=COFF,CHECK
|
||||
|
||||
; DWARF64 is enabled only for ELF targets. The switch should be ignored for Mach-O.
|
||||
; RUN: llc -mtriple=x86_64-apple-darwin -dwarf-version=5 -dwarf64 -filetype=obj %s -o - | \
|
||||
; RUN: llvm-dwarfdump -debug-line - | \
|
||||
; RUN: FileCheck %s --check-prefixes=MACHO,CHECK
|
||||
|
||||
; ELF64: file format elf64-x86-64
|
||||
; ELF32: file format elf32-i386
|
||||
; COFF: file format COFF-x86-64
|
||||
; MACHO: file format Mach-O 64-bit x86-64
|
||||
|
||||
; CHECK: .debug_line contents:
|
||||
; CHECK-NEXT: debug_line[0x00000000]
|
||||
; CHECK-NEXT: Line table prologue:
|
||||
; CHECK-NEXT: total_length:
|
||||
; CHECK-NEXT: format: DWARF32
|
||||
|
||||
; IR generated and reduced from:
|
||||
; $ cat foo.c
|
||||
; int foo;
|
||||
; $ clang -g -S -emit-llvm foo.c -o foo.ll
|
||||
|
||||
target triple = "x86_64-unknown-linux-gnu"
|
||||
|
||||
@foo = dso_local global i32 0, align 4, !dbg !0
|
||||
|
||||
!llvm.dbg.cu = !{!2}
|
||||
!llvm.module.flags = !{!7, !8, !9}
|
||||
!llvm.ident = !{!10}
|
||||
|
||||
!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
|
||||
!1 = distinct !DIGlobalVariable(name: "foo", scope: !2, file: !3, line: 1, 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, nameTableKind: None)
|
||||
!3 = !DIFile(filename: "foo.c", directory: "/tmp")
|
||||
!4 = !{}
|
||||
!5 = !{!0}
|
||||
!6 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
|
||||
!7 = !{i32 7, !"Dwarf Version", i32 4}
|
||||
!8 = !{i32 2, !"Debug Info Version", i32 3}
|
||||
!9 = !{i32 1, !"wchar_size", i32 4}
|
||||
!10 = !{!"clang version 12.0.0"}
|
Loading…
Reference in New Issue
Block a user