[llvm] [AssumptionCache] Limit the number of assumptions inspected per value (PR #217525)

Yingwei Zheng via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 21 11:06:21 PDT 2026


================
@@ -225,18 +254,14 @@ void AssumptionCache::registerAssumption(AssumeInst *CI) {
 
   // We expect the number of assumptions to be small, so in an asserts build
   // check that we don't accumulate duplicates and that all assumptions point
-  // to the same function.
-  SmallPtrSet<Value *, 16> AssumptionSet;
-  for (auto &VH : AssumeHandles) {
-    if (!VH)
-      continue;
-
-    assert(&F == cast<Instruction>(VH)->getParent()->getParent() &&
-           "Cached assumption not inside this function!");
-    assert(match(cast<CallInst>(VH), m_Intrinsic<Intrinsic::assume>()) &&
-           "Cached something other than a call to @llvm.assume!");
-    assert(AssumptionSet.insert(VH).second &&
-           "Cache contains multiple copies of a call!");
+  // to the same function. Scanning the whole cache on every registration is
+  // quadratic, so stop once it outgrows that expectation. Larger caches are
+  // checked by AssumptionCacheTracker::verifyAnalysis() instead.
+  constexpr unsigned MaxAssumesToVerify = 64;
----------------
dtcxzyw wrote:

We can enable the full check under the EXPENSIVE_CHECKS macro.


https://github.com/llvm/llvm-project/pull/217525


More information about the llvm-commits mailing list