DwarfDebug: Emit number of bytes in .debug_loc entry directly
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>
Wed, 6 May 2015 19:11:20 +0000 (19:11 +0000)
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>
Wed, 6 May 2015 19:11:20 +0000 (19:11 +0000)
commit7838051bda3ee8b95c73c6d5e1a97ea3570684f1
treebecd75adbe3bf1737f5221308319d2194cbf7365
parent4e21d7aff9187de570062ae6e58f42205466b93b
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.)

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@236629 91177308-0d34-0410-b5e6-96231b3b80d8
lib/CodeGen/AsmPrinter/DwarfDebug.cpp
test/CodeGen/X86/2010-05-25-DotDebugLoc.ll
test/CodeGen/X86/2010-05-26-DotDebugLoc.ll
test/DebugInfo/X86/dbg-value-range.ll