[LVI] Handle constants defensively
authorPhilip Reames <listmail@philipreames.com>
Wed, 10 Feb 2016 21:46:32 +0000 (21:46 +0000)
committerPhilip Reames <listmail@philipreames.com>
Wed, 10 Feb 2016 21:46:32 +0000 (21:46 +0000)
commitbb781b46e2a28436330cf6b8507603b137c38071
treecc8ccdccfb61a396e4cf3927c61f3b0d5721ab6a
parentd5dbb6e7fd99055e96aacf66a17361c11aca7705
[LVI] Handle constants defensively

There's nothing preventing callers of LVI from asking for lattice values representing a Constant.  In fact, given that several callers are walking back through PHI nodes and trying to simplify predicates, such queries are actually quite common.  This is mostly harmless today, but we start volatiling assertions if we add new calls to getBlockValue in otherwise reasonable places.

Note that this change is not NFC.  Specifically:
1) The result returned through getValueAt will now be more precise.  In principle, this could trigger any latent infinite optimization loops in callers, but in practice, we're unlikely to see this.
2) The result returned through getBlockValueAt is potentially weakened for non-constants that were previously queried.  With the old code, you had the possibility that a later query might bypass the cache and discover some information the original query did not.  I can't find a scenario which actually causes this to happen, but it was in principle possible.  On the other hand, this may end up reducing compile time when the same value is queried repeatedly.

llvm-svn: 260439
llvm/lib/Analysis/LazyValueInfo.cpp