1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 02:52:53 +02:00

DebugInfo: Use assembly label arithmetic for address pool size for easier reading/editing

Recommits 350048, 350050 That broke buildbots because of some typos in
the test case.

llvm-svn: 352019
This commit is contained in:
David Blaikie 2019-01-24 03:27:57 +00:00
parent 99c9f56646
commit da4d116ccc
3 changed files with 25 additions and 15 deletions

View File

@ -23,21 +23,24 @@ unsigned AddressPool::getIndex(const MCSymbol *Sym, bool TLS) {
return IterBool.first->second.Number; return IterBool.first->second.Number;
} }
MCSymbol *AddressPool::emitHeader(AsmPrinter &Asm, MCSection *Section) {
void AddressPool::emitHeader(AsmPrinter &Asm, MCSection *Section) {
static const uint8_t AddrSize = Asm.getDataLayout().getPointerSize(); static const uint8_t AddrSize = Asm.getDataLayout().getPointerSize();
uint64_t Length = sizeof(uint16_t) // version StringRef Prefix = "debug_addr_";
+ sizeof(uint8_t) // address_size MCSymbol *BeginLabel = Asm.createTempSymbol(Prefix + "start");
+ sizeof(uint8_t) // segment_selector_size MCSymbol *EndLabel = Asm.createTempSymbol(Prefix + "end");
+ AddrSize * Pool.size(); // entries
Asm.OutStreamer->AddComment("Length of contribution"); Asm.OutStreamer->AddComment("Length of contribution");
Asm.emitInt32(Length); // TODO: Support DWARF64 format. Asm.EmitLabelDifference(EndLabel, BeginLabel,
4); // TODO: Support DWARF64 format.
Asm.OutStreamer->EmitLabel(BeginLabel);
Asm.OutStreamer->AddComment("DWARF version number"); Asm.OutStreamer->AddComment("DWARF version number");
Asm.emitInt16(Asm.getDwarfVersion()); Asm.emitInt16(Asm.getDwarfVersion());
Asm.OutStreamer->AddComment("Address size"); Asm.OutStreamer->AddComment("Address size");
Asm.emitInt8(AddrSize); Asm.emitInt8(AddrSize);
Asm.OutStreamer->AddComment("Segment selector size"); Asm.OutStreamer->AddComment("Segment selector size");
Asm.emitInt8(0); // TODO: Support non-zero segment_selector_size. Asm.emitInt8(0); // TODO: Support non-zero segment_selector_size.
return EndLabel;
} }
// Emit addresses into the section given. // Emit addresses into the section given.
@ -48,8 +51,10 @@ void AddressPool::emit(AsmPrinter &Asm, MCSection *AddrSection) {
// Start the dwarf addr section. // Start the dwarf addr section.
Asm.OutStreamer->SwitchSection(AddrSection); Asm.OutStreamer->SwitchSection(AddrSection);
MCSymbol *EndLabel = nullptr;
if (Asm.getDwarfVersion() >= 5) if (Asm.getDwarfVersion() >= 5)
emitHeader(Asm, AddrSection); EndLabel = emitHeader(Asm, AddrSection);
// Define the symbol that marks the start of the contribution. // Define the symbol that marks the start of the contribution.
// It is referenced via DW_AT_addr_base. // It is referenced via DW_AT_addr_base.
@ -66,4 +71,7 @@ void AddressPool::emit(AsmPrinter &Asm, MCSection *AddrSection) {
for (const MCExpr *Entry : Entries) for (const MCExpr *Entry : Entries)
Asm.OutStreamer->EmitValue(Entry, Asm.getDataLayout().getPointerSize()); Asm.OutStreamer->EmitValue(Entry, Asm.getDataLayout().getPointerSize());
if (EndLabel)
Asm.OutStreamer->EmitLabel(EndLabel);
} }

View File

@ -54,7 +54,7 @@ public:
void setLabel(MCSymbol *Sym) { AddressTableBaseSym = Sym; } void setLabel(MCSymbol *Sym) { AddressTableBaseSym = Sym; }
private: private:
void emitHeader(AsmPrinter &Asm, MCSection *Section); MCSymbol *emitHeader(AsmPrinter &Asm, MCSection *Section);
/// Symbol designates the start of the contribution to the address table. /// Symbol designates the start of the contribution to the address table.
MCSymbol *AddressTableBaseSym = nullptr; MCSymbol *AddressTableBaseSym = nullptr;

View File

@ -1,12 +1,14 @@
; RUN: llc %s -mtriple=i386-unknown-linux-gnu -filetype=asm -o - | FileCheck %s ; RUN: llc %s -mtriple=i386-unknown-linux-gnu -filetype=asm -o - | FileCheck %s
; CHECK: .section .debug_addr ; CHECK: .section .debug_addr
; CHECK: .long 8 # Length of contribution ; CHECK-NEXT: .long .Ldebug_addr_end0-.Ldebug_addr_start0 # Length of contribution
; CHECK: .short 5 # DWARF version number ; CHECK-NEXT: .Ldebug_addr_start0:
; CHECK: .byte 4 # Address size ; CHECK-NEXT: .short 5 # DWARF version number
; CHECK: .byte 0 # Segment selector size ; CHECK-NEXT: .byte 4 # Address size
; CHECK: .Laddr_table_base0: ; CHECK-NEXT: .byte 0 # Segment selector size
; CHECK: .long .Lfunc_begin0 ; CHECK-NEXT: .Laddr_table_base0:
; CHECK-NEXT: .long .Lfunc_begin0
; CHECK-NEXT: .Ldebug_addr_end0:
; Function Attrs: noinline nounwind optnone uwtable ; Function Attrs: noinline nounwind optnone uwtable
define dso_local void @foo() #0 !dbg !7 { define dso_local void @foo() #0 !dbg !7 {