[llvm] a8a7bf9 - [mlgo][regalloc] Fix register masking
Mircea Trofin via llvm-commits
llvm-commits at lists.llvm.org
Sun Jan 30 14:59:16 PST 2022
Author: Mircea Trofin
Date: 2022-01-30T14:59:08-08:00
New Revision: a8a7bf922cea8af01168f7a4adf4ed0365bcc2b4
URL: https://github.com/llvm/llvm-project/commit/a8a7bf922cea8af01168f7a4adf4ed0365bcc2b4
DIFF: https://github.com/llvm/llvm-project/commit/a8a7bf922cea8af01168f7a4adf4ed0365bcc2b4.diff
LOG: [mlgo][regalloc] Fix register masking
If AllocationOrder has less than 32 elements, we were treating the extra
positions as if they were valid. This was detected by a subsequent
assert. The fix also tightens the asserts.
Added:
Modified:
llvm/lib/CodeGen/MLRegallocEvictAdvisor.cpp
Removed:
################################################################################
diff --git a/llvm/lib/CodeGen/MLRegallocEvictAdvisor.cpp b/llvm/lib/CodeGen/MLRegallocEvictAdvisor.cpp
index a74c57690640..f8ba224da7b8 100644
--- a/llvm/lib/CodeGen/MLRegallocEvictAdvisor.cpp
+++ b/llvm/lib/CodeGen/MLRegallocEvictAdvisor.cpp
@@ -615,16 +615,15 @@ MCRegister MLEvictAdvisor::tryFindEvictionCandidate(
for (auto I = Order.begin(), E = Order.getOrderLimitEnd(OrderLimit); I != E;
++I, ++Pos) {
MCRegister PhysReg = *I;
- Regs[Pos] = std::make_pair(PhysReg, true);
+ assert(!Regs[Pos].second);
assert(PhysReg);
if (!canAllocatePhysReg(CostPerUseLimit, PhysReg)) {
- Regs[Pos].second = false;
continue;
}
if (loadInterferenceFeatures(VirtReg, PhysReg, I.isHint(), FixedRegisters,
Largest, Pos)) {
++Available;
- Regs[Pos].second = true;
+ Regs[Pos] = std::make_pair(PhysReg, true);
}
}
if (Available == 0) {
@@ -632,6 +631,7 @@ MCRegister MLEvictAdvisor::tryFindEvictionCandidate(
assert(!MustFindEviction);
return MCRegister::NoRegister;
}
+ const size_t ValidPosLimit = Pos;
// If we must find eviction, the candidate should be masked out of the
// decision making process.
Regs[CandidateVirtRegPos].second = !MustFindEviction;
@@ -665,6 +665,7 @@ MCRegister MLEvictAdvisor::tryFindEvictionCandidate(
assert(!MustFindEviction);
return MCRegister::NoRegister;
}
+ assert(CandidatePos < ValidPosLimit);
return Regs[CandidatePos].first;
}
More information about the llvm-commits
mailing list