Call ScalarEvolution's deleteValueFromRecords before deleting an

instruction, not after. This fixes some uses of free'd memory.

llvm-svn: 56908
This commit is contained in:
Dan Gohman 2008-10-01 02:02:03 +00:00
parent e8813812eb
commit 67d90de2b0
1 changed files with 3 additions and 3 deletions

View File

@ -1803,15 +1803,15 @@ ICmpInst *LoopStrengthReduce::OptimizeSMax(Loop *L, ICmpInst *Cond,
Cond->getOperand(0), NewRHS, "scmp", Cond); Cond->getOperand(0), NewRHS, "scmp", Cond);
// Delete the max calculation instructions. // Delete the max calculation instructions.
SE->deleteValueFromRecords(Cond);
Cond->replaceAllUsesWith(NewCond); Cond->replaceAllUsesWith(NewCond);
Cond->eraseFromParent(); Cond->eraseFromParent();
SE->deleteValueFromRecords(Cond);
Instruction *Cmp = cast<Instruction>(Sel->getOperand(0)); Instruction *Cmp = cast<Instruction>(Sel->getOperand(0));
Sel->eraseFromParent();
SE->deleteValueFromRecords(Sel); SE->deleteValueFromRecords(Sel);
Sel->eraseFromParent();
if (Cmp->use_empty()) { if (Cmp->use_empty()) {
Cmp->eraseFromParent();
SE->deleteValueFromRecords(Cmp); SE->deleteValueFromRecords(Cmp);
Cmp->eraseFromParent();
} }
CondUse->User = NewCond; CondUse->User = NewCond;
return NewCond; return NewCond;