[SCEV] Verify block disposition cache.
authorFlorian Hahn <flo@fhahn.com>
Mon, 10 Oct 2022 19:42:18 +0000 (20:42 +0100)
committerFlorian Hahn <flo@fhahn.com>
Mon, 10 Oct 2022 19:42:19 +0000 (20:42 +0100)
This extends the existing SCEV verification to catch cache invalidation
issues as in #57837.

The validation logic is similar to the recently added loop disposition
cache validation in bb68b2402daa9.

Reviewed By: nikic

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

llvm/lib/Analysis/ScalarEvolution.cpp

index 189245e..d8ba9c6 100644 (file)
@@ -14021,6 +14021,22 @@ void ScalarEvolution::verify() const {
       }
     }
   }
+
+  // Verify integrity of the block disposition cache.
+  for (const auto &It : BlockDispositions) {
+    const SCEV *S = It.first;
+    auto &Values = It.second;
+    for (auto &V : Values) {
+      auto CachedDisposition = V.getInt();
+      const BasicBlock *BB = V.getPointer();
+      const auto RecomputedDisposition = SE2.getBlockDisposition(S, BB);
+      if (CachedDisposition != RecomputedDisposition) {
+        dbgs() << "Cached disposition of " << *S << " for block %"
+               << BB->getName() << " is incorrect! \n";
+        std::abort();
+      }
+    }
+  }
 }
 
 bool ScalarEvolution::invalidate(