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

Aiden Grossman via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 16 00:10:52 PST 2024


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

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.

>From a8bdc0164bb4779ba92b5a38e268f6c3d4be26d0 Mon Sep 17 00:00:00 2001
From: Aiden Grossman <aidengrossman at google.com>
Date: Mon, 16 Dec 2024 08:08:39 +0000
Subject: [PATCH] [MLGO] Do not include urgent LRs in max cascade calculation

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.
---
 llvm/lib/CodeGen/MLRegAllocEvictAdvisor.cpp | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

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.



More information about the llvm-commits mailing list