From: David Blaikie Date: Mon, 24 Dec 2018 07:35:10 +0000 (+0000) Subject: DebugInfo: Use assembly label arithmetic for address pool size for easier reading... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e90a06c33ff56bfc200cd401a0a81bf6089e8243;p=llvm DebugInfo: Use assembly label arithmetic for address pool size for easier reading/editing git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@350048 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/AsmPrinter/AddressPool.cpp b/lib/CodeGen/AsmPrinter/AddressPool.cpp index 042243b7925..97c08da3827 100644 --- a/lib/CodeGen/AsmPrinter/AddressPool.cpp +++ b/lib/CodeGen/AsmPrinter/AddressPool.cpp @@ -27,12 +27,13 @@ unsigned AddressPool::getIndex(const MCSymbol *Sym, bool TLS) { void AddressPool::emitHeader(AsmPrinter &Asm, MCSection *Section) { static const uint8_t AddrSize = Asm.getDataLayout().getPointerSize(); - uint64_t Length = sizeof(uint16_t) // version - + sizeof(uint8_t) // address_size - + sizeof(uint8_t) // segment_selector_size - + AddrSize * Pool.size(); // entries + StringRef Prefix = "debug_addr_"; + MCSymbol *BeginLabel = Asm.createTempSymbol(Prefix + "start"); + EndLabel = Asm.createTempSymbol(Prefix + "end"); 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.emitInt16(Asm.getDwarfVersion()); Asm.OutStreamer->AddComment("Address size"); @@ -67,4 +68,6 @@ void AddressPool::emit(AsmPrinter &Asm, MCSection *AddrSection) { for (const MCExpr *Entry : Entries) Asm.OutStreamer->EmitValue(Entry, Asm.getDataLayout().getPointerSize()); + + Asm.OutStreamer->EmitLabel(EndLabel); } diff --git a/lib/CodeGen/AsmPrinter/AddressPool.h b/lib/CodeGen/AsmPrinter/AddressPool.h index 2209c7eb50e..e1bf3e9ae58 100644 --- a/lib/CodeGen/AsmPrinter/AddressPool.h +++ b/lib/CodeGen/AsmPrinter/AddressPool.h @@ -30,6 +30,8 @@ class AddressPool { }; DenseMap Pool; + MCSymbol *EndLabel; + /// Record whether the AddressPool has been queried for an address index since /// the last "resetUsedFlag" call. Used to implement type unit fallback - a /// type that references addresses cannot be placed in a type unit when using diff --git a/test/DebugInfo/X86/addr_comments.ll b/test/DebugInfo/X86/addr_comments.ll index 780b37915a4..487973d2267 100644 --- a/test/DebugInfo/X86/addr_comments.ll +++ b/test/DebugInfo/X86/addr_comments.ll @@ -1,12 +1,14 @@ ; RUN: llc %s -mtriple=i386-unknown-linux-gnu -filetype=asm -o - | FileCheck %s -; CHECK: .section .debug_addr -; CHECK: .long 8 # Length of contribution -; CHECK: .short 5 # DWARF version number -; CHECK: .byte 4 # Address size -; CHECK: .byte 0 # Segment selector size -; CHECK: .Laddr_table_base0: -; CHECK: .long .Lfunc_begin0 +; CHECK: .section .debug_addr +; CHECK-NEXT: .long .Ldebug_addr_end0-.Ldebug_addr_start0 # Length of contribution +; CHECK-NEXT: .Ldebug_addr_startt 0: +; CHECK-NEXT: .short 5 # DWARF version number +; CHECK-NEXT: .byte 4 # Address size +; CHECK-NEXT: .byte 0 # Segment selector size +; CHECK-NEXT: .Laddr_table_base0: +; CHECK-NEXT: .long .Lfunc_begin0 +; CHECK-NEXT: .Ldebug_addr_end0: ; Function Attrs: noinline nounwind optnone uwtable define dso_local void @foo() #0 !dbg !7 {