forked from OSchip/llvm-project
[RegisterClassInfo] Return non-zero for RC without allocatable reg
In some case, the RC may have 0 allocatable reg. eg: VRSAVERC in PowerPC, which has only 1 reg, but it is also reserved. The curreent implementation will keep calling the computePSetLimit because getRegPressureSetLimit assume computePSetLimit will return a non-zero value. The fix simply early return the value from TableGen for such special case. Reviewed By: RKSimon Differential Revision: https://reviews.llvm.org/D92907
This commit is contained in:
parent
51d5991f04
commit
f26bc0ddd5
|
@ -188,7 +188,14 @@ unsigned RegisterClassInfo::computePSetLimit(unsigned Idx) const {
|
|||
}
|
||||
assert(RC && "Failed to find register class");
|
||||
compute(RC);
|
||||
unsigned NReserved = RC->getNumRegs() - getNumAllocatableRegs(RC);
|
||||
return TRI->getRegPressureSetLimit(*MF, Idx) -
|
||||
TRI->getRegClassWeight(RC).RegWeight * NReserved;
|
||||
unsigned NAllocatableRegs = getNumAllocatableRegs(RC);
|
||||
unsigned RegPressureSetLimit = TRI->getRegPressureSetLimit(*MF, Idx);
|
||||
// If all the regs are reserved, return raw RegPressureSetLimit.
|
||||
// One example is VRSAVERC in PowerPC.
|
||||
// Avoid returning zero, getRegPressureSetLimit(Idx) assumes computePSetLimit
|
||||
// return non-zero value.
|
||||
if (NAllocatableRegs == 0)
|
||||
return RegPressureSetLimit;
|
||||
unsigned NReserved = RC->getNumRegs() - NAllocatableRegs;
|
||||
return RegPressureSetLimit - TRI->getRegClassWeight(RC).RegWeight * NReserved;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
; REQUIRES: asserts
|
||||
; RUN: llc -debug-only=regalloc < %s 2>&1 |FileCheck %s --check-prefix=DEBUG
|
||||
|
||||
; DEBUG-COUNT-3: AllocationOrder(VRSAVERC) = [ ]
|
||||
; DEBUG-COUNT-1: AllocationOrder(VRSAVERC) = [ ]
|
||||
|
||||
target triple = "powerpc64le-unknown-linux-gnu"
|
||||
|
||||
|
|
Loading…
Reference in New Issue