Rename ScalarEvolution::deleteInstructionFromRecords to

deleteValueFromRecords and loosen the types to all it to accept
Value* instead of just Instruction*, since this is what
ScalarEvolution uses internally anyway. This allows more flexibility
for future uses.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@37657 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Dan Gohman 2007-06-19 14:28:31 +00:00
parent b5bec2b6f6
commit 5cec4db6ae
4 changed files with 22 additions and 22 deletions

View File

@ -232,10 +232,10 @@ namespace llvm {
/// an analyzable loop-invariant iteration count. /// an analyzable loop-invariant iteration count.
bool hasLoopInvariantIterationCount(const Loop *L) const; bool hasLoopInvariantIterationCount(const Loop *L) const;
/// deleteInstructionFromRecords - This method should be called by the /// deleteValueFromRecords - This method should be called by the
/// client before it removes an instruction from the program, to make sure /// client before it removes a Value from the program, to make sure
/// that no dangling references are left around. /// that no dangling references are left around.
void deleteInstructionFromRecords(Instruction *I) const; void deleteValueFromRecords(Value *V) const;
virtual bool runOnFunction(Function &F); virtual bool runOnFunction(Function &F);
virtual void releaseMemory(); virtual void releaseMemory();

View File

@ -1167,10 +1167,10 @@ namespace {
/// loop without a loop-invariant iteration count. /// loop without a loop-invariant iteration count.
SCEVHandle getIterationCount(const Loop *L); SCEVHandle getIterationCount(const Loop *L);
/// deleteInstructionFromRecords - This method should be called by the /// deleteValueFromRecords - This method should be called by the
/// client before it removes an instruction from the program, to make sure /// client before it removes a value from the program, to make sure
/// that no dangling references are left around. /// that no dangling references are left around.
void deleteInstructionFromRecords(Instruction *I); void deleteValueFromRecords(Value *V);
private: private:
/// createSCEV - We know that there is no SCEV for the specified value. /// createSCEV - We know that there is no SCEV for the specified value.
@ -1236,27 +1236,27 @@ namespace {
// Basic SCEV Analysis and PHI Idiom Recognition Code // Basic SCEV Analysis and PHI Idiom Recognition Code
// //
/// deleteInstructionFromRecords - This method should be called by the /// deleteValueFromRecords - This method should be called by the
/// client before it removes an instruction from the program, to make sure /// client before it removes an instruction from the program, to make sure
/// that no dangling references are left around. /// that no dangling references are left around.
void ScalarEvolutionsImpl::deleteInstructionFromRecords(Instruction *I) { void ScalarEvolutionsImpl::deleteValueFromRecords(Value *V) {
SmallVector<Instruction *, 16> Worklist; SmallVector<Value *, 16> Worklist;
if (Scalars.erase(I)) { if (Scalars.erase(V)) {
if (PHINode *PN = dyn_cast<PHINode>(I)) if (PHINode *PN = dyn_cast<PHINode>(V))
ConstantEvolutionLoopExitValue.erase(PN); ConstantEvolutionLoopExitValue.erase(PN);
Worklist.push_back(I); Worklist.push_back(V);
} }
while (!Worklist.empty()) { while (!Worklist.empty()) {
Instruction *II = Worklist.back(); Value *VV = Worklist.back();
Worklist.pop_back(); Worklist.pop_back();
for (Instruction::use_iterator UI = II->use_begin(), UE = II->use_end(); for (Instruction::use_iterator UI = VV->use_begin(), UE = VV->use_end();
UI != UE; ++UI) { UI != UE; ++UI) {
Instruction *Inst = cast<Instruction>(*UI); Instruction *Inst = cast<Instruction>(*UI);
if (Scalars.erase(Inst)) { if (Scalars.erase(Inst)) {
if (PHINode *PN = dyn_cast<PHINode>(II)) if (PHINode *PN = dyn_cast<PHINode>(VV))
ConstantEvolutionLoopExitValue.erase(PN); ConstantEvolutionLoopExitValue.erase(PN);
Worklist.push_back(Inst); Worklist.push_back(Inst);
} }
@ -2593,8 +2593,8 @@ SCEVHandle ScalarEvolution::getSCEVAtScope(Value *V, const Loop *L) const {
return ((ScalarEvolutionsImpl*)Impl)->getSCEVAtScope(getSCEV(V), L); return ((ScalarEvolutionsImpl*)Impl)->getSCEVAtScope(getSCEV(V), L);
} }
void ScalarEvolution::deleteInstructionFromRecords(Instruction *I) const { void ScalarEvolution::deleteValueFromRecords(Value *V) const {
return ((ScalarEvolutionsImpl*)Impl)->deleteInstructionFromRecords(I); return ((ScalarEvolutionsImpl*)Impl)->deleteValueFromRecords(V);
} }
static void PrintLoopInfo(std::ostream &OS, const ScalarEvolution *SE, static void PrintLoopInfo(std::ostream &OS, const ScalarEvolution *SE,

View File

@ -115,7 +115,7 @@ DeleteTriviallyDeadInstructions(std::set<Instruction*> &Insts) {
for (unsigned i = 0, e = I->getNumOperands(); i != e; ++i) for (unsigned i = 0, e = I->getNumOperands(); i != e; ++i)
if (Instruction *U = dyn_cast<Instruction>(I->getOperand(i))) if (Instruction *U = dyn_cast<Instruction>(I->getOperand(i)))
Insts.insert(U); Insts.insert(U);
SE->deleteInstructionFromRecords(I); SE->deleteValueFromRecords(I);
DOUT << "INDVARS: Deleting: " << *I; DOUT << "INDVARS: Deleting: " << *I;
I->eraseFromParent(); I->eraseFromParent();
Changed = true; Changed = true;
@ -181,7 +181,7 @@ void IndVarSimplify::EliminatePointerRecurrence(PHINode *PN,
GetElementPtrInst *NGEPI = new GetElementPtrInst( GetElementPtrInst *NGEPI = new GetElementPtrInst(
NCE, Constant::getNullValue(Type::Int32Ty), NewAdd, NCE, Constant::getNullValue(Type::Int32Ty), NewAdd,
GEPI->getName(), GEPI); GEPI->getName(), GEPI);
SE->deleteInstructionFromRecords(GEPI); SE->deleteValueFromRecords(GEPI);
GEPI->replaceAllUsesWith(NGEPI); GEPI->replaceAllUsesWith(NGEPI);
GEPI->eraseFromParent(); GEPI->eraseFromParent();
GEPI = NGEPI; GEPI = NGEPI;
@ -398,7 +398,7 @@ void IndVarSimplify::RewriteLoopExitValues(Loop *L) {
// the PHI entirely. This is safe, because the NewVal won't be variant // 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. // in the loop, so we don't need an LCSSA phi node anymore.
if (NumPreds == 1) { if (NumPreds == 1) {
SE->deleteInstructionFromRecords(PN); SE->deleteValueFromRecords(PN);
PN->replaceAllUsesWith(ExitVal); PN->replaceAllUsesWith(ExitVal);
PN->eraseFromParent(); PN->eraseFromParent();
break; break;

View File

@ -226,7 +226,7 @@ DeleteTriviallyDeadInstructions(std::set<Instruction*> &Insts) {
for (unsigned i = 0, e = I->getNumOperands(); i != e; ++i) for (unsigned i = 0, e = I->getNumOperands(); i != e; ++i)
if (Instruction *U = dyn_cast<Instruction>(I->getOperand(i))) if (Instruction *U = dyn_cast<Instruction>(I->getOperand(i)))
Insts.insert(U); Insts.insert(U);
SE->deleteInstructionFromRecords(I); SE->deleteValueFromRecords(I);
I->eraseFromParent(); I->eraseFromParent();
Changed = true; Changed = true;
} }
@ -1488,7 +1488,7 @@ bool LoopStrengthReduce::runOnLoop(Loop *L, LPPassManager &LPM) {
DeadInsts.insert(BO); DeadInsts.insert(BO);
// Break the cycle, then delete the PHI. // Break the cycle, then delete the PHI.
PN->replaceAllUsesWith(UndefValue::get(PN->getType())); PN->replaceAllUsesWith(UndefValue::get(PN->getType()));
SE->deleteInstructionFromRecords(PN); SE->deleteValueFromRecords(PN);
PN->eraseFromParent(); PN->eraseFromParent();
} }
} }