forked from OSchip/llvm-project
[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.
This commit is contained in:
parent
dc3b9365b6
commit
a8a7bf922c
|
@ -615,16 +615,15 @@ MCRegister MLEvictAdvisor::tryFindEvictionCandidate(
|
||||||
for (auto I = Order.begin(), E = Order.getOrderLimitEnd(OrderLimit); I != E;
|
for (auto I = Order.begin(), E = Order.getOrderLimitEnd(OrderLimit); I != E;
|
||||||
++I, ++Pos) {
|
++I, ++Pos) {
|
||||||
MCRegister PhysReg = *I;
|
MCRegister PhysReg = *I;
|
||||||
Regs[Pos] = std::make_pair(PhysReg, true);
|
assert(!Regs[Pos].second);
|
||||||
assert(PhysReg);
|
assert(PhysReg);
|
||||||
if (!canAllocatePhysReg(CostPerUseLimit, PhysReg)) {
|
if (!canAllocatePhysReg(CostPerUseLimit, PhysReg)) {
|
||||||
Regs[Pos].second = false;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (loadInterferenceFeatures(VirtReg, PhysReg, I.isHint(), FixedRegisters,
|
if (loadInterferenceFeatures(VirtReg, PhysReg, I.isHint(), FixedRegisters,
|
||||||
Largest, Pos)) {
|
Largest, Pos)) {
|
||||||
++Available;
|
++Available;
|
||||||
Regs[Pos].second = true;
|
Regs[Pos] = std::make_pair(PhysReg, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (Available == 0) {
|
if (Available == 0) {
|
||||||
|
@ -632,6 +631,7 @@ MCRegister MLEvictAdvisor::tryFindEvictionCandidate(
|
||||||
assert(!MustFindEviction);
|
assert(!MustFindEviction);
|
||||||
return MCRegister::NoRegister;
|
return MCRegister::NoRegister;
|
||||||
}
|
}
|
||||||
|
const size_t ValidPosLimit = Pos;
|
||||||
// If we must find eviction, the candidate should be masked out of the
|
// If we must find eviction, the candidate should be masked out of the
|
||||||
// decision making process.
|
// decision making process.
|
||||||
Regs[CandidateVirtRegPos].second = !MustFindEviction;
|
Regs[CandidateVirtRegPos].second = !MustFindEviction;
|
||||||
|
@ -665,6 +665,7 @@ MCRegister MLEvictAdvisor::tryFindEvictionCandidate(
|
||||||
assert(!MustFindEviction);
|
assert(!MustFindEviction);
|
||||||
return MCRegister::NoRegister;
|
return MCRegister::NoRegister;
|
||||||
}
|
}
|
||||||
|
assert(CandidatePos < ValidPosLimit);
|
||||||
return Regs[CandidatePos].first;
|
return Regs[CandidatePos].first;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue