Skip to content

Commit f1dbc45

Browse files
[MLGO] Properly Handle Counting Evictions of Candidates
This patch makes it so that onEviction actually gets called when the model ends up selecting the candidate to evict. Where we were handling this previously ended up being dead code as we would return earlier with MCRegister::NoRegister. Fixes #129841.
1 parent fc7482e commit f1dbc45

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

llvm/lib/CodeGen/MLRegAllocEvictAdvisor.cpp

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -860,6 +860,7 @@ MCRegister MLEvictAdvisor::tryFindEvictionCandidate(
860860
// Regs[CandidatePos].second)
861861
assert(Regs[CandidatePos].second);
862862
if (CandidatePos == CandidateVirtRegPos) {
863+
onEviction(VirtReg.reg());
863864
assert(!MustFindEviction);
864865
return MCRegister::NoRegister;
865866
}
@@ -869,15 +870,11 @@ MCRegister MLEvictAdvisor::tryFindEvictionCandidate(
869870
// Update information about how many times the virtual registers being
870871
// evicted have been evicted so that we can prevent the model from evicting
871872
// the same ranges continually and eating compile time.
872-
if (CandidatePos == CandidateVirtRegPos) {
873-
onEviction(VirtReg.reg());
874-
} else {
875-
for (MCRegUnit Unit : TRI->regunits(Regs[CandidatePos].first)) {
876-
LiveIntervalUnion::Query &Q = Matrix->query(VirtReg, Unit);
877-
const auto &IFIntervals = Q.interferingVRegs(EvictInterferenceCutoff);
878-
for (const LiveInterval *Intf : reverse(IFIntervals)) {
879-
onEviction(Intf->reg());
880-
}
873+
for (MCRegUnit Unit : TRI->regunits(Regs[CandidatePos].first)) {
874+
LiveIntervalUnion::Query &Q = Matrix->query(VirtReg, Unit);
875+
const auto &IFIntervals = Q.interferingVRegs(EvictInterferenceCutoff);
876+
for (const LiveInterval *Intf : reverse(IFIntervals)) {
877+
onEviction(Intf->reg());
881878
}
882879
}
883880

0 commit comments

Comments
 (0)