Call ScalarEvolution's deleteValueFromRecords before deleting an

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@56908 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Dan Gohman 2008-10-01 02:02:03 +00:00
parent ae595dc9da
commit 586b7b7547

View File

@ -1803,15 +1803,15 @@ 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();
SE->deleteValueFromRecords(Cond);
Instruction *Cmp = cast<Instruction>(Sel->getOperand(0));
Sel->eraseFromParent();
SE->deleteValueFromRecords(Sel);
Sel->eraseFromParent();
if (Cmp->use_empty()) {
Cmp->eraseFromParent();
SE->deleteValueFromRecords(Cmp);
Cmp->eraseFromParent();
}
CondUse->User = NewCond;
return NewCond;