Make SCEVCallbackVH::allUsesReplacedWith unconditionally delete

the old value.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@109567 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Dan Gohman 2010-07-28 00:28:25 +00:00
parent 51409214d7
commit 59846aced2

View File

@ -5699,7 +5699,6 @@ void ScalarEvolution::SCEVCallbackVH::allUsesReplacedWith(Value *) {
SmallVector<User *, 16> Worklist; SmallVector<User *, 16> Worklist;
SmallPtrSet<User *, 8> Visited; SmallPtrSet<User *, 8> Visited;
Value *Old = getValPtr(); Value *Old = getValPtr();
bool DeleteOld = false;
for (Value::use_iterator UI = Old->use_begin(), UE = Old->use_end(); for (Value::use_iterator UI = Old->use_begin(), UE = Old->use_end();
UI != UE; ++UI) UI != UE; ++UI)
Worklist.push_back(*UI); Worklist.push_back(*UI);
@ -5707,10 +5706,8 @@ void ScalarEvolution::SCEVCallbackVH::allUsesReplacedWith(Value *) {
User *U = Worklist.pop_back_val(); User *U = Worklist.pop_back_val();
// Deleting the Old value will cause this to dangle. Postpone // Deleting the Old value will cause this to dangle. Postpone
// that until everything else is done. // that until everything else is done.
if (U == Old) { if (U == Old)
DeleteOld = true;
continue; continue;
}
if (!Visited.insert(U)) if (!Visited.insert(U))
continue; continue;
if (PHINode *PN = dyn_cast<PHINode>(U)) if (PHINode *PN = dyn_cast<PHINode>(U))
@ -5720,14 +5717,11 @@ void ScalarEvolution::SCEVCallbackVH::allUsesReplacedWith(Value *) {
UI != UE; ++UI) UI != UE; ++UI)
Worklist.push_back(*UI); Worklist.push_back(*UI);
} }
// Delete the Old value if it (indirectly) references itself. // Delete the Old value.
if (DeleteOld) { if (PHINode *PN = dyn_cast<PHINode>(Old))
if (PHINode *PN = dyn_cast<PHINode>(Old)) SE->ConstantEvolutionLoopExitValue.erase(PN);
SE->ConstantEvolutionLoopExitValue.erase(PN); SE->Scalars.erase(Old);
SE->Scalars.erase(Old); // this now dangles!
// this now dangles!
}
// this may dangle!
} }
ScalarEvolution::SCEVCallbackVH::SCEVCallbackVH(Value *V, ScalarEvolution *se) ScalarEvolution::SCEVCallbackVH::SCEVCallbackVH(Value *V, ScalarEvolution *se)