diff options
author | Nick Lewycky <nicholas@mxc.ca> | 2007-06-06 04:12:20 +0000 |
---|---|---|
committer | Nick Lewycky <nicholas@mxc.ca> | 2007-06-06 04:12:20 +0000 |
commit | 3e84212897d9e9859c0d21432b8b3030e0b03baa (patch) | |
tree | 953d4912dc00cf8edf0318426e3be44a58208161 /llvm/lib/Analysis/ScalarEvolution.cpp | |
parent | 3b70bb27788a08971a61d86d53ddf48c2d11f2bc (diff) | |
download | bcm5719-llvm-3e84212897d9e9859c0d21432b8b3030e0b03baa.tar.gz bcm5719-llvm-3e84212897d9e9859c0d21432b8b3030e0b03baa.zip |
Fix PR1487 and Transforms/IndVar/2007-06-06-DeleteDanglesPtr.ll
llvm-svn: 37459
Diffstat (limited to 'llvm/lib/Analysis/ScalarEvolution.cpp')
-rw-r--r-- | llvm/lib/Analysis/ScalarEvolution.cpp | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp index 1ff21a75f94..b1c3a177273 100644 --- a/llvm/lib/Analysis/ScalarEvolution.cpp +++ b/llvm/lib/Analysis/ScalarEvolution.cpp @@ -1196,9 +1196,28 @@ namespace { /// client before it removes an instruction from the program, to make sure /// that no dangling references are left around. void ScalarEvolutionsImpl::deleteInstructionFromRecords(Instruction *I) { - Scalars.erase(I); - if (PHINode *PN = dyn_cast<PHINode>(I)) - ConstantEvolutionLoopExitValue.erase(PN); + SmallVector<Instruction *, 16> Worklist; + + if (Scalars.erase(I)) { + if (PHINode *PN = dyn_cast<PHINode>(I)) + ConstantEvolutionLoopExitValue.erase(PN); + Worklist.push_back(I); + } + + while (!Worklist.empty()) { + Instruction *II = Worklist.back(); + Worklist.pop_back(); + + for (Instruction::use_iterator UI = II->use_begin(), UE = II->use_end(); + UI != UE; ++UI) { + Instruction *Inst = dyn_cast<Instruction>(*UI); + if (Inst && hasSCEV(Inst) && Scalars.erase(Inst)) { + if (PHINode *PN = dyn_cast<PHINode>(II)) + ConstantEvolutionLoopExitValue.erase(PN); + Worklist.push_back(Inst); + } + } + } } |