mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 11:13:28 +01:00
[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
This commit is contained in:
parent
41d067a08e
commit
6a008ae64e
@ -1155,9 +1155,10 @@ LVILatticeVal LazyValueInfoCache::getValueInBlock(Value *V, BasicBlock *BB,
|
||||
<< BB->getName() << "'\n");
|
||||
|
||||
assert(BlockValueStack.empty() && BlockValueSet.empty());
|
||||
pushBlockValue(std::make_pair(BB, V));
|
||||
|
||||
solve();
|
||||
if (!hasBlockValue(V, BB)) {
|
||||
pushBlockValue(std::make_pair(BB, V));
|
||||
solve();
|
||||
}
|
||||
LVILatticeVal Result = getBlockValue(V, BB);
|
||||
intersectAssumeBlockValueConstantRange(V, Result, CxtI);
|
||||
|
||||
@ -1169,6 +1170,9 @@ LVILatticeVal LazyValueInfoCache::getValueAt(Value *V, Instruction *CxtI) {
|
||||
DEBUG(dbgs() << "LVI Getting value " << *V << " at '"
|
||||
<< CxtI->getName() << "'\n");
|
||||
|
||||
if (auto *C = dyn_cast<Constant>(V))
|
||||
return LVILatticeVal::get(C);
|
||||
|
||||
LVILatticeVal Result = LVILatticeVal::getOverdefined();
|
||||
if (auto *I = dyn_cast<Instruction>(V))
|
||||
Result = getFromRangeMetadata(I);
|
||||
|
Loading…
Reference in New Issue
Block a user