diff options
| author | Torok Edwin <edwintorok@gmail.com> | 2009-05-24 20:08:21 +0000 |
|---|---|---|
| committer | Torok Edwin <edwintorok@gmail.com> | 2009-05-24 20:08:21 +0000 |
| commit | 26895b518bb8ed715d8c1e5a7e06ab8678c07999 (patch) | |
| tree | 72275aad2b6d38e510bb4ef0818cbc645a509788 /llvm/lib/Transforms | |
| parent | 5349cf5f4b2a2d553658605171701c23a1193601 (diff) | |
| download | bcm5719-llvm-26895b518bb8ed715d8c1e5a7e06ab8678c07999.tar.gz bcm5719-llvm-26895b518bb8ed715d8c1e5a7e06ab8678c07999.zip | |
Move Rewriter.clear() earlier, to avoid triggerring the AssertingVH by
one of the RecursivelyDeleteTriviallyDeadInstructions.
Add a comment explaining why the cache needs to be cleared.
llvm-svn: 72372
Diffstat (limited to 'llvm/lib/Transforms')
| -rw-r--r-- | llvm/lib/Transforms/Scalar/IndVarSimplify.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp b/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp index f0f2d83b6e6..7300bf47fe7 100644 --- a/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp +++ b/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp @@ -414,9 +414,12 @@ bool IndVarSimplify::runOnLoop(Loop *L, LPPassManager &LPM) { Rewriter.setInsertionPoint(Header->getFirstNonPHI()); - // Rewrite IV-derived expressions. + // Rewrite IV-derived expressions. Clears the rewriter cache. RewriteIVExpressions(L, LargestType, Rewriter); + // The Rewriter may only be used for isInsertedInstruction queries from this + // point on. + // Loop-invariant instructions in the preheader that aren't used in the // loop may be sunk below the loop to reduce register pressure. SinkUnusedInvariants(L, Rewriter); @@ -424,7 +427,6 @@ 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) @@ -574,6 +576,10 @@ void IndVarSimplify::RewriteIVExpressions(Loop *L, const Type *LargestType, } } + // Clear the rewriter cache, because values that are in the rewriter's cache + // can be deleted in the loop below, causing the AssertingVH in the cache to + // trigger. + Rewriter.clear(); // Now that we're done iterating through lists, clean up any instructions // which are now dead. while (!DeadInsts.empty()) { |

