[DebugInfo] Re-implement LexicalScopes dominance method, add unit tests
authorJeremy Morse <jeremy.morse@sony.com>
Fri, 28 Feb 2020 10:41:23 +0000 (10:41 +0000)
committerJeremy Morse <jeremy.morse@sony.com>
Fri, 28 Feb 2020 11:41:28 +0000 (11:41 +0000)
commit6af859dcca272cf3706d070183562e4cecb1dc36
treea1e8d9292555946a1595d31ec7c5190e15e188e6
parentcc28a754679a2c85625e719944154fe82491f008
[DebugInfo] Re-implement LexicalScopes dominance method, add unit tests

Way back in D24994, the combination of LexicalScopes::dominates and
LiveDebugValues was identified as having worst-case quadratic complexity,
but it wasn't triggered by any code path at the time. I've since run into a
scenario where this occurs, in a very large basic block where large numbers
of inlined DBG_VALUEs are present.

The quadratic-ness comes from LiveDebugValues::join calling "dominates" on
every variable location, and LexicalScopes::dominates potentially touching
every instruction in a block to test for the presence of a scope. We have,
however, already computed the presence of scopes in blocks, in the
"InstrRanges" of each scope. This patch switches the dominates method to
examine whether a block is present in a scope's InsnRanges, avoiding
walking through the whole block.

At the same time, fix getMachineBasicBlocks to account for the fact that
InsnRanges can cover multiple blocks, and add some unit tests, as Lexical
Scopes didn't have any.

Differential revision: https://reviews.llvm.org/D73725
llvm/lib/CodeGen/LexicalScopes.cpp
llvm/unittests/CodeGen/CMakeLists.txt
llvm/unittests/CodeGen/LexicalScopesTest.cpp [new file with mode: 0644]
llvm/unittests/CodeGen/MFCommon.inc [new file with mode: 0644]
llvm/unittests/CodeGen/MachineInstrTest.cpp