OSDN Git Service

[LVI] Reduce compile time by lazily scanning blocks if needed
authorPhilip Reames <listmail@philipreames.com>
Wed, 27 Apr 2016 00:30:55 +0000 (00:30 +0000)
committerPhilip Reames <listmail@philipreames.com>
Wed, 27 Apr 2016 00:30:55 +0000 (00:30 +0000)
commit82d78c2f2793ac32da09d86f608fa8c87dd41b76
tree6dea574dc43047dee8e1e51eda00adc5fc169b59
parent7ec26d4fefddd5a438db38eb86b6722a789076b1
[LVI] Reduce compile time by lazily scanning blocks if needed

When encountering a non-local pointer, LVI would eagerly scan the block for dereferences of the given object to prove the pointer to be non null.  That's all well and good, but *then* we'd go recurse through our input blocks.  As a result, we could end up scanning each and every block we traverse, even if the final definition was obviously non null or we found a constant value somewhere up the chain.  The previous code papered over this by using the isKnownNonNull routine from value tracking.  This made the duplication less painful in the common case.

Instead, we know do the block scan only *after* we've gotten the recursive results back.  This lets us stop scanning individual blocks as soon as we've determined it to be non-null in any predecessor block and use our usual merge rules to propagate that information cheaply through successor blocks.  For a pointer which can be found non-null, this does strictly less work and sometimes substaintially so.

Note that the case where we *can't* prove something non-null is still the really expensive case.  We end up scanning each and every block looking for a dereference and never end up finding one.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@267642 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Analysis/LazyValueInfo.cpp
test/Transforms/CorrelatedValuePropagation/basic.ll