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");
for (const MCExpr *Entry : Entries)
Asm.OutStreamer->EmitValue(Entry, Asm.getDataLayout().getPointerSize());
+
+ Asm.OutStreamer->EmitLabel(EndLabel);
}
};
DenseMap<const MCSymbol *, AddressPoolEntry> 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
; 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 {