Teach LiveDebugValues about lexical scopes.
authorAdrian Prantl <aprantl@apple.com>
Wed, 28 Sep 2016 17:51:14 +0000 (17:51 +0000)
committerAdrian Prantl <aprantl@apple.com>
Wed, 28 Sep 2016 17:51:14 +0000 (17:51 +0000)
commit7f5866c227a716cb063b268b6f0edaccb1029605
treef4b38040c7bf4ca7a2327988945b6954477432b0
parentd4d9dc82529d5788fdf6a18f413584e3aa0b3fd4
Teach LiveDebugValues about lexical scopes.

This addresses PR26055 LiveDebugValues is very slow.

Contrary to the old LiveDebugVariables pass LiveDebugValues currently
doesn't look at the lexical scopes before inserting a DBG_VALUE
intrinsic. This means that we often propagate DBG_VALUEs much further
down than necessary. This is especially noticeable in large C++
functions with many inlined method calls that all use the same
"this"-pointer.

For example, in the following code it makes no sense to propagate the
inlined variable a from the first inlined call to f() into any of the
subsequent basic blocks, because the variable will always be out of
scope:

void sink(int a);
void __attribute((always_inline)) f(int a) { sink(a); }
void foo(int i) {
   f(i);
   if (i)
     f(i);
   f(i);
}

This patch reuses the LexicalScopes infrastructure we have for
LiveDebugVariables to take this into account.

The effect on compile time and memory consumption is quite noticeable:
I tested a benchmark that is a large C++ source with an enormous
amount of inlined "this"-pointers that would previously eat >24GiB
(most of them for DBG_VALUE intrinsics) and whose compile time was
dominated by LiveDebugValues. With this patch applied the memory
consumption is 1GiB and 1.7% of the time is spent in LiveDebugValues.

https://reviews.llvm.org/D24994
Thanks to Daniel Berlin and Keith Walker for reviewing!

llvm-svn: 282611
llvm/lib/CodeGen/LiveDebugValues.cpp
llvm/test/CodeGen/ARM/dbg-range-extension.mir
llvm/test/DebugInfo/COFF/register-variables.ll
llvm/test/DebugInfo/MIR/X86/livedebugvalues-limit.mir [new file with mode: 0644]
llvm/test/DebugInfo/X86/fission-ranges.ll