[llvm] 5961f03 - [SCEV][NFC] Verify intergity of SCEVUsers

Max Kazantsev via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 26 19:55:24 PDT 2021


Author: Max Kazantsev
Date: 2021-10-27T09:54:49+07:00
New Revision: 5961f0308f5b793f5944ebf0ae5b36e888da4bc0

URL: https://github.com/llvm/llvm-project/commit/5961f0308f5b793f5944ebf0ae5b36e888da4bc0
DIFF: https://github.com/llvm/llvm-project/commit/5961f0308f5b793f5944ebf0ae5b36e888da4bc0.diff

LOG: [SCEV][NFC] Verify intergity of SCEVUsers

Make sure that, for every living SCEV, we have all its direct
operand tracking it as their user.

Differential Revision: https://reviews.llvm.org/D112402
Reviewed By: reames

Added: 
    

Modified: 
    llvm/lib/Analysis/ScalarEvolution.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp
index 3168ef91d8ba9..3624a7fd23c50 100644
--- a/llvm/lib/Analysis/ScalarEvolution.cpp
+++ b/llvm/lib/Analysis/ScalarEvolution.cpp
@@ -12893,6 +12893,30 @@ void ScalarEvolution::verify() const {
     assert(ValidLoops.contains(AR->getLoop()) &&
            "AddRec references invalid loop");
   }
+
+  // Verify intergity of SCEV users.
+  for (const auto &S : UniqueSCEVs) {
+    SmallPtrSet<const SCEV *, 4> Ops;
+    if (const auto *NS = dyn_cast<SCEVNAryExpr>(&S))
+      Ops.insert(NS->op_begin(), NS->op_end());
+    else if (const auto *CS = dyn_cast<SCEVCastExpr>(&S))
+      Ops.insert(CS->getOperand());
+    else if (const auto *DS = dyn_cast<SCEVUDivExpr>(&S)) {
+      Ops.insert(DS->getLHS());
+      Ops.insert(DS->getRHS());
+    }
+    for (const auto *Op : Ops) {
+      // We do not store dependencies of constants.
+      if (isa<SCEVConstant>(Op))
+        continue;
+      auto It = SCEVUsers.find(Op);
+      if (It != SCEVUsers.end() && It->second.count(&S))
+        continue;
+      dbgs() << "Use of operand  " << *Op << " by user " << S
+             << " is not being tracked!\n";
+      std::abort();
+    }
+  }
 }
 
 bool ScalarEvolution::invalidate(


        


More information about the llvm-commits mailing list