[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:22 PDT 2026


================
@@ -163,7 +166,23 @@ class AssumptionCache {
   }
 
   /// Access the list of assumptions which affect this value.
+  ///
+  /// Callers inspect every assumption returned, so this returns only the first
+  /// -max-assumes-per-value of them.
   MutableArrayRef<ResultElem> assumptionsFor(const Value *V) {
+    MutableArrayRef<ResultElem> Assumptions = allAssumptionsFor(V);
+    if (Assumptions.size() > MaxAssumesPerValue)
+      return Assumptions.take_front(MaxAssumesPerValue);
+
+    return Assumptions;
----------------
dtcxzyw wrote:

```suggestion
    return Assumptions.take_front(MaxAssumesPerValue);
```
The bound has been checked inside `take_front`.


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


More information about the llvm-commits mailing list