[llvm] 2b23a58 - [LoopDeletion] Forget block and loop dispositions after deleting loop.

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 28 03:34:09 PDT 2022


Author: Florian Hahn
Date: 2022-09-28T11:33:43+01:00
New Revision: 2b23a58924402857c4d868463f536f5b932d5629

URL: https://github.com/llvm/llvm-project/commit/2b23a58924402857c4d868463f536f5b932d5629
DIFF: https://github.com/llvm/llvm-project/commit/2b23a58924402857c4d868463f536f5b932d5629.diff

LOG: [LoopDeletion] Forget block and loop dispositions after deleting loop.

After deleting a loop, the block and loop dispositions need to be
cleared. As we don't know which SCEVs in the loop/blocks may be
impacted, completely clear the cache. This should also fix some cases
where deleted loops remained in the LoopDispositions cache.

This fixes a verification failure surfaced by D134531.

Reviewed By: mkazantsev

Differential Revision: https://reviews.llvm.org/D134613

Added: 
    

Modified: 
    llvm/lib/Transforms/Utils/LoopUtils.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Utils/LoopUtils.cpp b/llvm/lib/Transforms/Utils/LoopUtils.cpp
index 09e1d0829fbf3..2cef827a58c33 100644
--- a/llvm/lib/Transforms/Utils/LoopUtils.cpp
+++ b/llvm/lib/Transforms/Utils/LoopUtils.cpp
@@ -486,8 +486,10 @@ void llvm::deleteDeadLoop(Loop *L, DominatorTree *DT, ScalarEvolution *SE,
   // 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.
-  if (SE)
+  if (SE) {
     SE->forgetLoop(L);
+    SE->forgetBlockAndLoopDispositions();
+  }
 
   Instruction *OldTerm = Preheader->getTerminator();
   assert(!OldTerm->mayHaveSideEffects() &&


        


More information about the llvm-commits mailing list