Skip to content

Commit ed2deab

Browse files
committed
[nfc][regalloc] Make the max inference cutoff configurable
Added a flag to make configurable the number of interferences after which we 'bail out' and treat a set of intervals as un-evictable. Also using it on the ML side, as it turns out to be a good control for compile-time. With this configurable, we can do a bit of trial and error and see if bumping it has any effect on heuristic/policy quality. Differential Revision: https://reviews.llvm.org/D118707
1 parent b4bb622 commit ed2deab

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

llvm/lib/CodeGen/MLRegallocEvictAdvisor.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ static cl::opt<std::string> ModelUnderTraining(
5858
"regalloc-model", cl::Hidden,
5959
cl::desc("The model being trained for register allocation eviction"));
6060

61+
extern cl::opt<unsigned> EvictInterferenceCutoff;
62+
6163
#endif // #ifdef LLVM_HAVE_TF_API
6264

6365
/// The score injection pass.
@@ -544,9 +546,11 @@ bool MLEvictAdvisor::loadInterferenceFeatures(
544546
LiveIntervalUnion::Query &Q = Matrix->query(VirtReg, *Units);
545547
// Different from the default heuristic, we don't make any assumptions about
546548
// what having more than 10 results in the query may mean.
547-
const auto &IFIntervals = Q.interferingVRegs();
549+
const auto &IFIntervals = Q.interferingVRegs(EvictInterferenceCutoff);
548550
if (IFIntervals.empty() && InterferingIntervals.empty())
549551
continue;
552+
if (IFIntervals.size() >= EvictInterferenceCutoff)
553+
return false;
550554
InterferingIntervals.append(IFIntervals.begin(), IFIntervals.end());
551555
for (LiveInterval *Intf : reverse(IFIntervals)) {
552556
assert(Register::isVirtualRegister(Intf->reg()) &&

llvm/lib/CodeGen/RegAllocEvictionAdvisor.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,14 @@ static cl::opt<bool> EnableLocalReassignment(
4242
"may be compile time intensive"),
4343
cl::init(false));
4444

45+
cl::opt<unsigned> EvictInterferenceCutoff(
46+
"regalloc-eviction-max-interference-cutoff", cl::Hidden,
47+
cl::desc("Number of interferences after which we declare "
48+
"an interference unevictable and bail out. This "
49+
"is a compilation cost-saving consideration. To "
50+
"disable, pass a very large number."),
51+
cl::init(10));
52+
4553
#define DEBUG_TYPE "regalloc"
4654
#ifdef LLVM_HAVE_TF_AOT_REGALLOCEVICTMODEL
4755
#define LLVM_HAVE_TF_AOT
@@ -195,8 +203,8 @@ bool DefaultEvictionAdvisor::canEvictInterferenceBasedOnCost(
195203
for (MCRegUnitIterator Units(PhysReg, TRI); Units.isValid(); ++Units) {
196204
LiveIntervalUnion::Query &Q = Matrix->query(VirtReg, *Units);
197205
// If there is 10 or more interferences, chances are one is heavier.
198-
const auto &Interferences = Q.interferingVRegs(10);
199-
if (Interferences.size() >= 10)
206+
const auto &Interferences = Q.interferingVRegs(EvictInterferenceCutoff);
207+
if (Interferences.size() >= EvictInterferenceCutoff)
200208
return false;
201209

202210
// Check if any interfering live range is heavier than MaxWeight.

0 commit comments

Comments
 (0)