From 653c1099b40957d836dd85d81449e35a22e4558d Mon Sep 17 00:00:00 2001 From: "Duncan P. N. Exon Smith" Date: Wed, 6 May 2015 19:11:20 +0000 Subject: 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.) llvm-svn: 236629 --- llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'llvm/lib/CodeGen') diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp index 4fe4f26c923..e275d3aac7d 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -1545,16 +1545,13 @@ void DebugLocEntry::finalize(const AsmPrinter &AP, DebugLocStream &Locs, } 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. -- cgit v1.2.3