]> granicus.if.org Git - llvm/commitdiff
DebugInfo: Use assembly label arithmetic for address pool size for easier reading...
authorDavid Blaikie <dblaikie@gmail.com>
Mon, 24 Dec 2018 07:35:10 +0000 (07:35 +0000)
committerDavid Blaikie <dblaikie@gmail.com>
Mon, 24 Dec 2018 07:35:10 +0000 (07:35 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@350048 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/AsmPrinter/AddressPool.cpp
lib/CodeGen/AsmPrinter/AddressPool.h
test/DebugInfo/X86/addr_comments.ll

index 042243b79259195a3a482470b9b7ae7a70ea6a97..97c08da38273c7aa67e3e0136bc9b763c14d5a4c 100644 (file)
@@ -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);
 }
index 2209c7eb50edc3de78b8527e4a32beb5ec2e8478..e1bf3e9ae582ce0b2777bf60f3434cecca329673 100644 (file)
@@ -30,6 +30,8 @@ class AddressPool {
   };
   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
index 780b37915a4b504e1ae082daeeadcda5689d1c8e..487973d2267b401a2eb711dc505e1e2cf7a18d51 100644 (file)
@@ -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 {