[LiveDebugValues] Add cutoffs to avoid pathological behavior
authorVedant Kumar <vsk@apple.com>
Wed, 27 May 2020 20:22:10 +0000 (13:22 -0700)
committerVedant Kumar <vsk@apple.com>
Thu, 28 May 2020 20:53:40 +0000 (13:53 -0700)
commitd11155d273af00f75c2b40a5ca3007463f9808c1
tree6b885a04e2169c970a46657cc425623e504b6726
parent4855534d10cea3dd93d33da13ceb3381b0c588e6
[LiveDebugValues] Add cutoffs to avoid pathological behavior

Summary:
We received a report of LiveDebugValues consuming 25GB+ of RAM when
compiling code generated by Unity's IL2CPP scripting backend.

There's an initial 5GB spike due to repeatedly copying cached lists of
MachineBasicBlocks within the UserValueScopes members of VarLocs.

But the larger scaling issue arises due to the fact that prior to range
extension, there are 81K basic blocks and 156K DBG_VALUEs: given enough
memory, LiveDebugValues would insert 101 million MIs (I counted this by
incrementing a counter inside of VarLoc::BuildDbgValue).

It seems like LiveDebugValues would have to be rearchitected to support
this kind of input (we'd need some new represntation for DBG_VALUEs that
get inserted into ~every block via flushPendingLocs). OTOH, large globs
of auto-generated code are typically not debugged interactively.

So: add cutoffs to disable range extension when the input is too big. I
chose the cutoffs experimentally, erring on the conservative side. When
compiling a large collection of Apple software, range extension never
got disabled.

rdar://63418929

Reviewers: aprantl, friss, jmorse, Orlando

Subscribers: hiraditya, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D80662
llvm/lib/CodeGen/LiveDebugValues.cpp
llvm/test/DebugInfo/MIR/X86/live-debug-values-cutoffs.mir [new file with mode: 0644]