diff --git a/llvm/lib/Target/AMDGPU/AMDGPUSubtarget.cpp b/llvm/lib/Target/AMDGPU/AMDGPUSubtarget.cpp --- a/llvm/lib/Target/AMDGPU/AMDGPUSubtarget.cpp +++ b/llvm/lib/Target/AMDGPU/AMDGPUSubtarget.cpp @@ -723,13 +723,11 @@ unsigned GCNSubtarget::getReservedNumSGPRs(const Function &F) const { // The logic to detect if the function has // flat scratch init is same as how MachineFunctionInfo derives. + bool isEntry = AMDGPU::isEntryFunctionCC(F.getCallingConv()); bool FunctionHasFlatScratchInit = false; - bool HasCalls = F.hasFnAttribute("amdgpu-calls"); - bool HasStackObjects = F.hasFnAttribute("amdgpu-stack-objects"); - if (hasFlatAddressSpace() && AMDGPU::isEntryFunctionCC(F.getCallingConv()) && - (isAmdHsaOrMesa(F) || enableFlatScratch()) && - !flatScratchIsArchitected()) { - if (HasCalls || HasStackObjects || enableFlatScratch()) + if (hasFlatAddressSpace() && isEntry && !flatScratchIsArchitected() && + (isAmdHsaOrMesa(F) || enableFlatScratch())) { + if (enableFlatScratch()) FunctionHasFlatScratchInit = true; } return getBaseReservedNumSGPRs(FunctionHasFlatScratchInit);