[llvm] 8ae0d9a - [LoopDeletion] Clear block & loop dispo cache after breaking backedge.

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 30 03:22:24 PDT 2022


Author: Florian Hahn
Date: 2022-09-30T11:21:58+01:00
New Revision: 8ae0d9aa072643a7c596e147e3fc7ee0b4dede1f

URL: https://github.com/llvm/llvm-project/commit/8ae0d9aa072643a7c596e147e3fc7ee0b4dede1f
DIFF: https://github.com/llvm/llvm-project/commit/8ae0d9aa072643a7c596e147e3fc7ee0b4dede1f.diff

LOG: [LoopDeletion] Clear block & loop dispo cache after breaking backedge.

breakLoopBackedge may remove blocks and loops. Also clear block &
loop disposition to avoid the cache containing invalid blocks and loops.

The coverage for the change is provided when using an ASAN build of opt
to run the LoopDeletion unit tests; without the fix, pointers to invalid
objects would be used.

Reviewed By: nikic

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

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp
index f56b9e7950c1c..ac36aba386682 100644
--- a/llvm/lib/Analysis/ScalarEvolution.cpp
+++ b/llvm/lib/Analysis/ScalarEvolution.cpp
@@ -13981,9 +13981,6 @@ void ScalarEvolution::verify() const {
     for (auto &V : Values) {
       auto CachedDisposition = V.getInt();
       const auto *Loop = V.getPointer();
-      // TODO: Make sure LoopDispositions contains no invalid loops.
-      if (!ValidLoops.contains(Loop))
-        continue;
       const auto RecomputedDisposition = SE2.getLoopDisposition(S, Loop);
       if (CachedDisposition != RecomputedDisposition) {
         dbgs() << "Cached disposition of " << *S << " for loop " << *Loop

diff  --git a/llvm/lib/Transforms/Utils/LoopUtils.cpp b/llvm/lib/Transforms/Utils/LoopUtils.cpp
index 2cef827a58c33..888be821a6002 100644
--- a/llvm/lib/Transforms/Utils/LoopUtils.cpp
+++ b/llvm/lib/Transforms/Utils/LoopUtils.cpp
@@ -696,6 +696,7 @@ void llvm::breakLoopBackedge(Loop *L, DominatorTree &DT, ScalarEvolution &SE,
   Loop *OutermostLoop = L->getOutermostLoop();
 
   SE.forgetLoop(L);
+  SE.forgetBlockAndLoopDispositions();
 
   std::unique_ptr<MemorySSAUpdater> MSSAU;
   if (MSSA)


        


More information about the llvm-commits mailing list