[llvm] r236629 - DwarfDebug: Emit number of bytes in .debug_loc entry directly
Duncan P. N. Exon Smith
dexonsmith at apple.com
Wed May 6 12:11:20 PDT 2015
Author: dexonsmith
Date: Wed May 6 14:11:20 2015
New Revision: 236629
URL: http://llvm.org/viewvc/llvm-project?rev=236629&view=rev
Log:
DwarfDebug: Emit number of bytes in .debug_loc entry directly
Emit the number of bytes in a `.debug_loc` entry directly. The old code
created temp labels (expensive), emitted the difference between them,
and then emitted one on each side of the relevant bytes.
(I'm looking at `llc` memory usage on `verify-uselistorder.lto.opt.bc`
(the optimized version of ld64's `-save-temps` when linking the
`verify-uselistorder` executable in an LTO bootstrap). I've hacked
`MCContext::Allocate()` to just call `malloc()` instead of using the
`BumpPtrAllocator` so that the heap profile is easier to read. As far
as peak memory is concerned, `MCContext::Allocate()` is equivalent to a
leak, since it only gets freed at process teardown.
In my heap profile, this patch drops memory usage of
`DwarfDebug::emitDebugLoc()` from 132.56 MB (11.4%) down to 29.86 MB
(2.7%) at peak memory. Some of that must be noise from `SmallVector`
(or other) allocations -- peak memory only dropped from 1160 MB down to
1100 MB -- but this nevertheless shaves 5% off the top.)
Modified:
llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
llvm/trunk/test/CodeGen/X86/2010-05-25-DotDebugLoc.ll
llvm/trunk/test/CodeGen/X86/2010-05-26-DotDebugLoc.ll
llvm/trunk/test/DebugInfo/X86/dbg-value-range.ll
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=236629&r1=236628&r2=236629&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Wed May 6 14:11:20 2015
@@ -1545,16 +1545,13 @@ void DebugLocEntry::finalize(const AsmPr
}
void DwarfDebug::emitDebugLocEntryLocation(const DebugLocStream::Entry &Entry) {
+ // Emit the size.
Asm->OutStreamer->AddComment("Loc expr size");
- MCSymbol *begin = Asm->OutStreamer->getContext().CreateTempSymbol();
- MCSymbol *end = Asm->OutStreamer->getContext().CreateTempSymbol();
- Asm->EmitLabelDifference(end, begin, 2);
- Asm->OutStreamer->EmitLabel(begin);
+ Asm->EmitInt16(DebugLocs.getBytes(Entry).size());
+
// Emit the entry.
APByteStreamer Streamer(*Asm);
emitDebugLocEntry(Streamer, Entry);
- // Close the range.
- Asm->OutStreamer->EmitLabel(end);
}
// Emit locations into the debug loc section.
Modified: llvm/trunk/test/CodeGen/X86/2010-05-25-DotDebugLoc.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2010-05-25-DotDebugLoc.ll?rev=236629&r1=236628&r2=236629&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/2010-05-25-DotDebugLoc.ll (original)
+++ llvm/trunk/test/CodeGen/X86/2010-05-25-DotDebugLoc.ll Wed May 6 14:11:20 2015
@@ -2,8 +2,7 @@
; RUN: llc -mtriple=x86_64-pc-linux -O2 -regalloc=basic < %s | FileCheck %s
; Test to check .debug_loc support. This test case emits many debug_loc entries.
-; CHECK: .short {{.*}} # Loc expr size
-; CHECK-NEXT: .Ltmp
+; CHECK: .short 1 # Loc expr size
; CHECK-NEXT: DW_OP_reg
%0 = type { double }
Modified: llvm/trunk/test/CodeGen/X86/2010-05-26-DotDebugLoc.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2010-05-26-DotDebugLoc.ll?rev=236629&r1=236628&r2=236629&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/2010-05-26-DotDebugLoc.ll (original)
+++ llvm/trunk/test/CodeGen/X86/2010-05-26-DotDebugLoc.ll Wed May 6 14:11:20 2015
@@ -77,18 +77,12 @@ declare void @llvm.dbg.value(metadata, i
; CHECK-NEXT: .quad [[SET1]]
; CHECK-NEXT: [[SET2:.*]] = [[LABEL]]-Lfunc_begin0
; CHECK-NEXT: .quad [[SET2]]
-; CHECK-NEXT: Lset{{.*}} = Ltmp{{.*}}-Ltmp{{.*}} ## Loc expr size
-; CHECK-NEXT: .short Lset{{.*}}
-; CHECK-NEXT: Ltmp{{.*}}:
+; CHECK-NEXT: .short 1 ## Loc expr size
; CHECK-NEXT: .byte 85
-; CHECK-NEXT: Ltmp{{.*}}:
; CHECK-NEXT: [[SET3:.*]] = [[LABEL]]-Lfunc_begin0
; CHECK-NEXT: .quad [[SET3]]
; CHECK-NEXT: [[SET4:.*]] = [[CLOBBER]]-Lfunc_begin0
; CHECK-NEXT: .quad [[SET4]]
-; CHECK-NEXT: Lset{{.*}} = Ltmp{{.*}}-Ltmp{{.*}} ## Loc expr size
-; CHECK-NEXT: .short Lset{{.*}}
-; CHECK-NEXT: Ltmp{{.*}}:
+; CHECK-NEXT: .short 1 ## Loc expr size
; CHECK-NEXT: .byte 83
-; CHECK-NEXT: Ltmp{{.*}}:
!38 = !{i32 1, !"Debug Info Version", i32 3}
Modified: llvm/trunk/test/DebugInfo/X86/dbg-value-range.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/X86/dbg-value-range.ll?rev=236629&r1=236628&r2=236629&view=diff
==============================================================================
--- llvm/trunk/test/DebugInfo/X86/dbg-value-range.ll (original)
+++ llvm/trunk/test/DebugInfo/X86/dbg-value-range.ll Wed May 6 14:11:20 2015
@@ -55,11 +55,8 @@ declare void @llvm.dbg.value(metadata, i
;CHECK-NEXT: .quad
;CHECK-NEXT: [[CLOBBER_OFF:Lset.*]] = [[CLOBBER]]-{{.*}}
;CHECK-NEXT: .quad [[CLOBBER_OFF]]
-;CHECK-NEXT: Lset{{.*}} = Ltmp{{.*}}-Ltmp{{.*}}
-;CHECK-NEXT: .short Lset
-;CHECK-NEXT: Ltmp
+;CHECK-NEXT: .short 1 ## Loc expr size
;CHECK-NEXT: .byte 85 ## DW_OP_reg
-;CHECK-NEXT: Ltmp
;CHECK-NEXT: .quad 0
;CHECK-NEXT: .quad 0
!24 = !{i32 1, !"Debug Info Version", i32 3}
More information about the llvm-commits
mailing list