[llvm] [MLGO] Do not include urgent LRs in max cascade calculation (PR #120052)

via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 16 00:11:30 PST 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-mlgo

Author: Aiden Grossman (boomanaiden154)

<details>
<summary>Changes</summary>

A previous PR introduced a threshold where we would mask out a LR that had been evicted a certain number of times to combat pathological compile time cases with a somewhat adversarial model. However, this patch did not take into account urgent LRs which led to compilation failures when greedy would expect us to provide an eviction and we could not due to the newly introduced logic.

---
Full diff: https://github.com/llvm/llvm-project/pull/120052.diff


1 Files Affected:

- (modified) llvm/lib/CodeGen/MLRegAllocEvictAdvisor.cpp (+4-2) 


``````````diff
diff --git a/llvm/lib/CodeGen/MLRegAllocEvictAdvisor.cpp b/llvm/lib/CodeGen/MLRegAllocEvictAdvisor.cpp
index 23ab021c099456..9c6487b40d6061 100644
--- a/llvm/lib/CodeGen/MLRegAllocEvictAdvisor.cpp
+++ b/llvm/lib/CodeGen/MLRegAllocEvictAdvisor.cpp
@@ -654,8 +654,10 @@ bool MLEvictAdvisor::loadInterferenceFeatures(
       // There is a potential that the model could be adversarial and
       // continually evict live ranges over and over again, leading to a
       // large amount of compile time being spent in regalloc. If we hit the
-      // threshold, prevent the range from being evicted.
-      if (IntfCascade >= MaxCascade)
+      // threshold, prevent the range from being evicted. We still let the
+      // range through if it is urgent as we are required to produce an
+      // eviction if the candidate is not spillable.
+      if (IntfCascade >= MaxCascade && !Urgent)
         return false;
 
       // Only evict older cascades or live ranges without a cascade.

``````````

</details>


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


More information about the llvm-commits mailing list