Tell ScalarEvolution that the loop is being deleted before actually
authorDan Gohman <gohman@apple.com>
Sat, 2 May 2009 17:29:26 +0000 (17:29 +0000)
committerDan Gohman <gohman@apple.com>
Sat, 2 May 2009 17:29:26 +0000 (17:29 +0000)
deleting it.  This will let ScalarEvolution be more complete about
updating its records.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@70632 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/LoopDeletion.cpp

index d7be820e74f6b49881c23326d2d9478f1885cc29..83c25619bfc75f73b2d863b21a98aa4c6046afcc 100644 (file)
@@ -258,6 +258,11 @@ bool LoopDeletion::runOnLoop(Loop* L, LPPassManager& LPM) {
     (*LI)->dropAllReferences();
   }
   
+  // Tell ScalarEvolution that the loop is deleted. Do this before
+  // deleting the loop so that ScalarEvolution can look at the loop
+  // to determine what it needs to clean up.
+  SE.forgetLoopBackedgeTakenCount(L);
+
   // Erase the instructions and the blocks without having to worry
   // about ordering because we already dropped the references.
   // NOTE: This iteration is safe because erasing the block does not remove its
@@ -266,9 +271,6 @@ bool LoopDeletion::runOnLoop(Loop* L, LPPassManager& LPM) {
        LI != LE; ++LI)
     (*LI)->eraseFromParent();
 
-  // Tell ScalarEvolution that the loop is deleted.
-  SE.forgetLoopBackedgeTakenCount(L);
-
   // Finally, the blocks from loopinfo.  This has to happen late because
   // otherwise our loop iterators won't work.
   LoopInfo& loopInfo = getAnalysis<LoopInfo>();