This patch adds a new pass that keeps track of dereferenced objects and
eliminates null checks that are dominated by a memory instruction that
dereferences the underlying object.
Currently this works by collecting all object dereferences and null
checks with known underlying objects. Those are then sorted by DomTree DFS
numbers of their containing blocks and the relative order in a basic
block. Then we iterate over the list and keep track of the currently
dereferenced objects. We remove objects once we encounter a block that
is not dominated by the dereference instruction.
Currently this is O(N * log(N)), where N is the number of memory
instructions that dereference a known underlying object plus number of
null checks of known underlying objects. As it is, the compile time
impact is +0.33% geomean for -O3 ThinLTO
(http://llvm-compile-time-tracker.com/compare.php?from=a5bd75aab861df8cea8d1c6b88e764ad4a2c09ea&to=c02c43b0fe6648772d70c3f3de41a9e5e29e0628&stat=instructions)
It is probably possible to improve that if we would directly traverse
the dominator tree.
This currently results in 1924 compare simplifications on
MultiSource/SPEC2000/SPEC2006 with -O3 -flto.
clang-tidy: warning: 'auto *UO' can be declared as 'const auto *UO' [llvm-qualified-auto]
not useful