summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis/ScalarEvolution.cpp
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2009-07-14 14:34:04 +0000
committerDan Gohman <gohman@apple.com>2009-07-14 14:34:04 +0000
commitf34f8634e7584e8f3fa6d62915567fb5487cd826 (patch)
tree47cb7d576676434138ffa346963f07e4abc4cac1 /llvm/lib/Analysis/ScalarEvolution.cpp
parente141364e5c36aa2994e31444c336d3bff7887eaf (diff)
downloadbcm5719-llvm-f34f8634e7584e8f3fa6d62915567fb5487cd826.tar.gz
bcm5719-llvm-f34f8634e7584e8f3fa6d62915567fb5487cd826.zip
Make SCEVCallbackVH::allUsesReplacedWith more thorough in removing
users from the Scalars map. llvm-svn: 75634
Diffstat (limited to 'llvm/lib/Analysis/ScalarEvolution.cpp')
-rw-r--r--llvm/lib/Analysis/ScalarEvolution.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp
index 457466f9de5..2b4623cd84f 100644
--- a/llvm/lib/Analysis/ScalarEvolution.cpp
+++ b/llvm/lib/Analysis/ScalarEvolution.cpp
@@ -4845,6 +4845,7 @@ void ScalarEvolution::SCEVCallbackVH::allUsesReplacedWith(Value *) {
// so that future queries will recompute the expressions using the new
// value.
SmallVector<User *, 16> Worklist;
+ SmallPtrSet<User *, 8> Visited;
Value *Old = getValPtr();
bool DeleteOld = false;
for (Value::use_iterator UI = Old->use_begin(), UE = Old->use_end();
@@ -4858,15 +4859,18 @@ void ScalarEvolution::SCEVCallbackVH::allUsesReplacedWith(Value *) {
DeleteOld = true;
continue;
}
+ if (!Visited.insert(U))
+ continue;
if (PHINode *PN = dyn_cast<PHINode>(U))
SE->ConstantEvolutionLoopExitValue.erase(PN);
if (Instruction *I = dyn_cast<Instruction>(U))
SE->ValuesAtScopes.erase(I);
- if (SE->Scalars.erase(U))
- for (Value::use_iterator UI = U->use_begin(), UE = U->use_end();
- UI != UE; ++UI)
- Worklist.push_back(*UI);
+ SE->Scalars.erase(U);
+ for (Value::use_iterator UI = U->use_begin(), UE = U->use_end();
+ UI != UE; ++UI)
+ Worklist.push_back(*UI);
}
+ // Delete the Old value if it (indirectly) references itself.
if (DeleteOld) {
if (PHINode *PN = dyn_cast<PHINode>(Old))
SE->ConstantEvolutionLoopExitValue.erase(PN);
OpenPOWER on IntegriCloud