[llvm] [RegAllocEvictionAdvisor] Make the local reassign option more useful (PR #223115)
Quentin Colombet via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 11 19:10:10 PDT 2026
https://github.com/qcolombet created https://github.com/llvm/llvm-project/pull/223115
Prior to this patch the CLI option for the local reassignment heuristic could only force enabling the local reassignment heuristic. In other words, there was no way to disable the heuristic if the target hook said otherwise, which defeated the purpose of the option.
Fix this by ensuring that when the option is set it takes precedence over the target hook. This makes experimenting with the local reassignment heuristic much easier.
The patch is NFC unless you set the option.
>From ca91589204a3d3a0e8a8b0fc3fdbdf71cf0fc634 Mon Sep 17 00:00:00 2001
From: Quentin Colombet <quentin.colombet at gmail.com>
Date: Fri, 11 Sep 2026 18:57:06 -0700
Subject: [PATCH] [RegAllocEvictionAdvisor] Make the local reassign option more
useful
Prior to this patch the CLI option for the local reassignment heuristic
could only force enabling the local reassignment heuristic. In other
words, there was no way to disable the heuristic if the target hook said
otherwise, which defeated the purpose of the option.
Fix this by ensuring that when the option is set it takes precedence over
the target hook. This makes experimenting with the local reassignment
heuristic much easier.
The patch is NFC unless you set the option.
---
llvm/lib/CodeGen/RegAllocEvictionAdvisor.cpp | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/llvm/lib/CodeGen/RegAllocEvictionAdvisor.cpp b/llvm/lib/CodeGen/RegAllocEvictionAdvisor.cpp
index 7734d66f6b42c..0c65e5e1c520f 100644
--- a/llvm/lib/CodeGen/RegAllocEvictionAdvisor.cpp
+++ b/llvm/lib/CodeGen/RegAllocEvictionAdvisor.cpp
@@ -40,11 +40,10 @@ static cl::opt<RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode> Mode(
RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Development,
"development", "for training")));
-static cl::opt<bool> EnableLocalReassignment(
+static cl::opt<cl::boolOrDefault> EnableLocalReassignment(
"enable-local-reassign", cl::Hidden,
cl::desc("Local reassignment can yield better allocation decisions, but "
- "may be compile time intensive"),
- cl::init(false));
+ "may be compile time intensive"));
namespace llvm {
cl::opt<unsigned> EvictInterferenceCutoff(
@@ -184,9 +183,11 @@ RegAllocEvictionAdvisor::RegAllocEvictionAdvisor(const MachineFunction &MF,
LIS(RA.getLiveIntervals()), VRM(RA.getVirtRegMap()),
MRI(&VRM->getRegInfo()), TRI(MF.getSubtarget().getRegisterInfo()),
RegClassInfo(RA.getRegClassInfo()), RegCosts(TRI->getRegisterCosts(MF)),
- EnableLocalReassign(EnableLocalReassignment ||
- MF.getSubtarget().enableRALocalReassignment(
- MF.getTarget().getOptLevel())) {}
+ EnableLocalReassign(
+ EnableLocalReassignment == cl::boolOrDefault::BOU_TRUE ||
+ (EnableLocalReassignment != cl::boolOrDefault::BOU_FALSE &&
+ MF.getSubtarget().enableRALocalReassignment(
+ MF.getTarget().getOptLevel()))) {}
/// isUrgentEviction - Returns true if this is an urgent eviction. Once a live
/// range becomes small enough, it is urgent that we find a register for it.
More information about the llvm-commits
mailing list