diff --git a/llvm/lib/Target/AMDGPU/AMDGPUMachineFunction.h b/llvm/lib/Target/AMDGPU/AMDGPUMachineFunction.h index 06d4a6c0d0274..25c0b4953ab7f 100644 --- a/llvm/lib/Target/AMDGPU/AMDGPUMachineFunction.h +++ b/llvm/lib/Target/AMDGPU/AMDGPUMachineFunction.h @@ -90,6 +90,11 @@ class AMDGPUMachineFunction : public MachineFunctionInfo { bool isChainFunction() const { return IsChainFunction; } + // The stack is empty upon entry to this function. + bool isBottomOfStack() const { + return isEntryFunction() || isChainFunction(); + } + bool hasNoSignedZerosFPMath() const { return NoSignedZerosFPMath; } diff --git a/llvm/lib/Target/AMDGPU/SIMachineFunctionInfo.cpp b/llvm/lib/Target/AMDGPU/SIMachineFunctionInfo.cpp index 7645c6da03388..f8eb67199f623 100644 --- a/llvm/lib/Target/AMDGPU/SIMachineFunctionInfo.cpp +++ b/llvm/lib/Target/AMDGPU/SIMachineFunctionInfo.cpp @@ -519,7 +519,7 @@ int SIMachineFunctionInfo::getScavengeFI(MachineFrameInfo &MFI, const SIRegisterInfo &TRI) { if (ScavengeFI) return *ScavengeFI; - if (isEntryFunction() || isChainFunction()) { + if (isBottomOfStack()) { ScavengeFI = MFI.CreateFixedObject( TRI.getSpillSize(AMDGPU::SGPR_32RegClass), 0, false); } else { diff --git a/llvm/lib/Target/AMDGPU/SIRegisterInfo.cpp b/llvm/lib/Target/AMDGPU/SIRegisterInfo.cpp index a7b0dfda7852a..1ce596de0403e 100644 --- a/llvm/lib/Target/AMDGPU/SIRegisterInfo.cpp +++ b/llvm/lib/Target/AMDGPU/SIRegisterInfo.cpp @@ -503,7 +503,7 @@ Register SIRegisterInfo::getFrameRegister(const MachineFunction &MF) const { // functions, but never actually want to reference it when accessing our own // frame. If we need a frame pointer we use it, but otherwise we can just use // an immediate "0" which we represent by returning NoRegister. - if (FuncInfo->isEntryFunction() || FuncInfo->isChainFunction()) { + if (FuncInfo->isBottomOfStack()) { return TFI->hasFP(MF) ? FuncInfo->getFrameOffsetReg() : Register(); } return TFI->hasFP(MF) ? FuncInfo->getFrameOffsetReg() @@ -738,7 +738,7 @@ bool SIRegisterInfo::shouldRealignStack(const MachineFunction &MF) const { // FIXME: Should be able to specify the entry frame alignment per calling // convention instead. - if (Info->isEntryFunction() || Info->isChainFunction()) + if (Info->isBottomOfStack()) return false; return TargetRegisterInfo::shouldRealignStack(MF); @@ -1649,7 +1649,7 @@ void SIRegisterInfo::buildSpillLoadStore( if (UseVGPROffset && ScratchOffsetReg) { MIB.addReg(ScratchOffsetReg); } else { - assert(FuncInfo->isEntryFunction() || FuncInfo->isChainFunction()); + assert(FuncInfo->isBottomOfStack()); MIB.addImm(0); } } @@ -2424,7 +2424,7 @@ bool SIRegisterInfo::eliminateFrameIndex(MachineBasicBlock::iterator MI, bool IsMUBUF = TII->isMUBUF(*MI); - if (!IsMUBUF && !MFI->isEntryFunction() && !MFI->isChainFunction()) { + if (!IsMUBUF && !MFI->isBottomOfStack()) { // Convert to a swizzled stack address by scaling by the wave size. // In an entry function/kernel the offset is already swizzled. bool IsSALU = isSGPRClass(TII->getOpRegClass(*MI, FIOperandNum));