diff options
| author | Torok Edwin <edwintorok@gmail.com> | 2009-05-24 14:23:16 +0000 |
|---|---|---|
| committer | Torok Edwin <edwintorok@gmail.com> | 2009-05-24 14:23:16 +0000 |
| commit | d184bc209c2663b74b63d5f2c4d774823e285c4d (patch) | |
| tree | 10250e335f48f1f8cb2b5782dfb0d4ee8b662bff /llvm/lib | |
| parent | fe87034cefd09c87ce90b00ac23bf28b0e714465 (diff) | |
| download | bcm5719-llvm-d184bc209c2663b74b63d5f2c4d774823e285c4d.tar.gz bcm5719-llvm-d184bc209c2663b74b63d5f2c4d774823e285c4d.zip | |
The rewriter may hold references to instructions that are deleted because they are trivially dead.
Fix by clearing the rewriter cache before deleting the trivially dead
instructions.
Also make InsertedExpressions use an AssertingVH to catch these
bugs easier.
llvm-svn: 72364
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/Analysis/ScalarEvolutionExpander.cpp | 2 | ||||
| -rw-r--r-- | llvm/lib/Transforms/Scalar/IndVarSimplify.cpp | 2 |
2 files changed, 3 insertions, 1 deletions
diff --git a/llvm/lib/Analysis/ScalarEvolutionExpander.cpp b/llvm/lib/Analysis/ScalarEvolutionExpander.cpp index 507ced74fd1..fc66ddb6f48 100644 --- a/llvm/lib/Analysis/ScalarEvolutionExpander.cpp +++ b/llvm/lib/Analysis/ScalarEvolutionExpander.cpp @@ -526,7 +526,7 @@ Value *SCEVExpander::expandCodeFor(SCEVHandle SH, const Type *Ty) { Value *SCEVExpander::expand(const SCEV *S) { // Check to see if we already expanded this. - std::map<SCEVHandle, Value*>::iterator I = InsertedExpressions.find(S); + std::map<SCEVHandle, AssertingVH<Value> >::iterator I = InsertedExpressions.find(S); if (I != InsertedExpressions.end()) return I->second; diff --git a/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp b/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp index 89742c55d64..670499062ec 100644 --- a/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp +++ b/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp @@ -298,6 +298,7 @@ void IndVarSimplify::RewriteLoopExitValues(Loop *L, // in the loop, so we don't need an LCSSA phi node anymore. if (NumPreds == 1) { PN->replaceAllUsesWith(ExitVal); + Rewriter.clear(); RecursivelyDeleteTriviallyDeadInstructions(PN); break; } @@ -418,6 +419,7 @@ bool IndVarSimplify::runOnLoop(Loop *L, LPPassManager &LPM) { // Reorder instructions to avoid use-before-def conditions. FixUsesBeforeDefs(L, Rewriter); + Rewriter.clear(); // For completeness, inform IVUsers of the IV use in the newly-created // loop exit test instruction. if (NewICmp) |

