summaryrefslogtreecommitdiffstats
path: root/lib/Transforms/Scalar
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2009-05-02 21:19:20 +0000
committerDan Gohman <gohman@apple.com>2009-05-02 21:19:20 +0000
commitdb6fa2964176c34f0e878e101427c28782c93419 (patch)
tree13d7f373c4090041d7c033446ce0516860a2e7a7 /lib/Transforms/Scalar
parentc09b12c62208f09de9d107b320f5420ae6e4fc38 (diff)
downloadexternal_llvm-db6fa2964176c34f0e878e101427c28782c93419.zip
external_llvm-db6fa2964176c34f0e878e101427c28782c93419.tar.gz
external_llvm-db6fa2964176c34f0e878e101427c28782c93419.tar.bz2
Convert ScalarEvolution to use CallbackVH for its internal map. This
makes ScalarEvolution::deleteValueFromRecords, and it's code that subtly needed to be called before ReplaceAllUsesWith, unnecessary. It also makes ValueDeletionListener unnecessary. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@70645 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Scalar')
-rw-r--r--lib/Transforms/Scalar/IndVarSimplify.cpp2
-rw-r--r--lib/Transforms/Scalar/LoopDeletion.cpp7
-rw-r--r--lib/Transforms/Scalar/LoopStrengthReduce.cpp23
3 files changed, 3 insertions, 29 deletions
diff --git a/lib/Transforms/Scalar/IndVarSimplify.cpp b/lib/Transforms/Scalar/IndVarSimplify.cpp
index be94c45..3d9017d 100644
--- a/lib/Transforms/Scalar/IndVarSimplify.cpp
+++ b/lib/Transforms/Scalar/IndVarSimplify.cpp
@@ -124,7 +124,6 @@ DeleteTriviallyDeadInstructions(SmallPtrSet<Instruction*, 16> &Insts) {
for (unsigned i = 0, e = I->getNumOperands(); i != e; ++i)
if (Instruction *U = dyn_cast<Instruction>(I->getOperand(i)))
Insts.insert(U);
- SE->deleteValueFromRecords(I);
DOUT << "INDVARS: Deleting: " << *I;
I->eraseFromParent();
Changed = true;
@@ -308,7 +307,6 @@ void IndVarSimplify::RewriteLoopExitValues(Loop *L,
// the PHI entirely. This is safe, because the NewVal won't be variant
// in the loop, so we don't need an LCSSA phi node anymore.
if (NumPreds == 1) {
- SE->deleteValueFromRecords(PN);
PN->replaceAllUsesWith(ExitVal);
PN->eraseFromParent();
break;
diff --git a/lib/Transforms/Scalar/LoopDeletion.cpp b/lib/Transforms/Scalar/LoopDeletion.cpp
index 83c2561..96b7a52 100644
--- a/lib/Transforms/Scalar/LoopDeletion.cpp
+++ b/lib/Transforms/Scalar/LoopDeletion.cpp
@@ -246,13 +246,6 @@ bool LoopDeletion::runOnLoop(Loop* L, LPPassManager& LPM) {
DT.eraseNode(*LI);
if (DF) DF->removeBlock(*LI);
- // Remove instructions that we're deleting from ScalarEvolution.
- for (BasicBlock::iterator BI = (*LI)->begin(), BE = (*LI)->end();
- BI != BE; ++BI)
- SE.deleteValueFromRecords(BI);
-
- SE.deleteValueFromRecords(*LI);
-
// Remove the block from the reference counting scheme, so that we can
// delete it freely later.
(*LI)->dropAllReferences();
diff --git a/lib/Transforms/Scalar/LoopStrengthReduce.cpp b/lib/Transforms/Scalar/LoopStrengthReduce.cpp
index b940665..7d69dc8 100644
--- a/lib/Transforms/Scalar/LoopStrengthReduce.cpp
+++ b/lib/Transforms/Scalar/LoopStrengthReduce.cpp
@@ -253,8 +253,6 @@ void LoopStrengthReduce::DeleteTriviallyDeadInstructions() {
if (I == 0 || !isInstructionTriviallyDead(I))
continue;
- SE->deleteValueFromRecords(I);
-
for (User::op_iterator OI = I->op_begin(), E = I->op_end(); OI != E; ++OI) {
if (Instruction *U = dyn_cast<Instruction>(*OI)) {
*OI = 0;
@@ -2130,7 +2128,6 @@ ICmpInst *LoopStrengthReduce::ChangeCompareStride(Loop *L, ICmpInst *Cond,
// Remove the old compare instruction. The old indvar is probably dead too.
DeadInsts.push_back(cast<Instruction>(CondUse->OperandValToReplace));
- SE->deleteValueFromRecords(OldCond);
OldCond->replaceAllUsesWith(Cond);
OldCond->eraseFromParent();
@@ -2251,16 +2248,12 @@ ICmpInst *LoopStrengthReduce::OptimizeSMax(Loop *L, ICmpInst *Cond,
Cond->getOperand(0), NewRHS, "scmp", Cond);
// Delete the max calculation instructions.
- SE->deleteValueFromRecords(Cond);
Cond->replaceAllUsesWith(NewCond);
Cond->eraseFromParent();
Instruction *Cmp = cast<Instruction>(Sel->getOperand(0));
- SE->deleteValueFromRecords(Sel);
Sel->eraseFromParent();
- if (Cmp->use_empty()) {
- SE->deleteValueFromRecords(Cmp);
+ if (Cmp->use_empty())
Cmp->eraseFromParent();
- }
CondUse->User = NewCond;
return NewCond;
}
@@ -2367,7 +2360,6 @@ void LoopStrengthReduce::OptimizeShadowIV(Loop *L) {
NewPH->addIncoming(NewIncr, PH->getIncomingBlock(Latch));
/* Remove cast operation */
- SE->deleteValueFromRecords(ShadowUse);
ShadowUse->replaceAllUsesWith(NewPH);
ShadowUse->eraseFromParent();
SI->second.Users.erase(CandidateUI);
@@ -2507,17 +2499,8 @@ bool LoopStrengthReduce::runOnLoop(Loop *L, LPPassManager &LPM) {
DeleteTriviallyDeadInstructions();
// At this point, it is worth checking to see if any recurrence PHIs are also
- // dead, so that we can remove them as well. To keep ScalarEvolution
- // current, use a ValueDeletionListener class.
- struct LSRListener : public ValueDeletionListener {
- ScalarEvolution &SE;
- explicit LSRListener(ScalarEvolution &se) : SE(se) {}
-
- virtual void ValueWillBeDeleted(Value *V) {
- SE.deleteValueFromRecords(V);
- }
- } VDL(*SE);
- DeleteDeadPHIs(L->getHeader(), &VDL);
+ // dead, so that we can remove them as well.
+ DeleteDeadPHIs(L->getHeader());
return Changed;
}