[PATCH] D112402: [SCEV][NFC] Verify intergity of SCEVUsers
Max Kazantsev via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Oct 24 23:29:00 PDT 2021
mkazantsev created this revision.
mkazantsev added reviewers: reames, nikic, lebedev.ri, efriedma.
Herald added subscribers: javed.absar, hiraditya.
mkazantsev requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Make sure that, for every living SCEV, we have all its direct
operand tracking it as their user.
https://reviews.llvm.org/D112402
Files:
llvm/lib/Analysis/ScalarEvolution.cpp
Index: llvm/lib/Analysis/ScalarEvolution.cpp
===================================================================
--- llvm/lib/Analysis/ScalarEvolution.cpp
+++ llvm/lib/Analysis/ScalarEvolution.cpp
@@ -12898,6 +12898,30 @@
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 (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)) {
+ dbgs() << "Use of operand " << *Op << " by user " << S
+ << " is not being tracked!\n";
+ std::abort();
+ }
+ }
+ }
}
bool ScalarEvolution::invalidate(
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D112402.381843.patch
Type: text/x-patch
Size: 1203 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211025/2297643f/attachment.bin>
More information about the llvm-commits
mailing list