forked from OSchip/llvm-project
AMDGPU: Restore using MRI to find highest used regs
If there are no calls, this is a faster path than searching the entire program for calls. This was supposed to be left in r309781. Fixes unused variable warning. llvm-svn: 309832
This commit is contained in:
parent
5577363a2c
commit
2738ede6b2
|
@ -500,13 +500,31 @@ AMDGPUAsmPrinter::SIFunctionResourceInfo AMDGPUAsmPrinter::analyzeResourceUsage(
|
|||
|
||||
// If there are no calls, MachineRegisterInfo can tell us the used register
|
||||
// count easily.
|
||||
|
||||
MCPhysReg HighestVGPRReg = AMDGPU::NoRegister;
|
||||
for (MCPhysReg Reg : reverse(AMDGPU::VGPR_32RegClass.getRegisters())) {
|
||||
if (MRI.isPhysRegUsed(Reg)) {
|
||||
HighestVGPRReg = Reg;
|
||||
break;
|
||||
if (!FrameInfo.hasCalls()) {
|
||||
MCPhysReg HighestVGPRReg = AMDGPU::NoRegister;
|
||||
for (MCPhysReg Reg : reverse(AMDGPU::VGPR_32RegClass.getRegisters())) {
|
||||
if (MRI.isPhysRegUsed(Reg)) {
|
||||
HighestVGPRReg = Reg;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
MCPhysReg HighestSGPRReg = AMDGPU::NoRegister;
|
||||
for (MCPhysReg Reg : reverse(AMDGPU::SGPR_32RegClass.getRegisters())) {
|
||||
if (MRI.isPhysRegUsed(Reg)) {
|
||||
HighestSGPRReg = Reg;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// We found the maximum register index. They start at 0, so add one to get the
|
||||
// number of registers.
|
||||
Info.NumVGPR = HighestVGPRReg == AMDGPU::NoRegister ? 0 :
|
||||
TRI.getHWRegIndex(HighestVGPRReg) + 1;
|
||||
Info.NumExplicitSGPR = HighestSGPRReg == AMDGPU::NoRegister ? 0 :
|
||||
TRI.getHWRegIndex(HighestSGPRReg) + 1;
|
||||
|
||||
return Info;
|
||||
}
|
||||
|
||||
int32_t MaxVGPR = -1;
|
||||
|
|
Loading…
Reference in New Issue