[llvm] a7ed55f - [AMDGPU] Simplify getReservedNumSGPRs
via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 30 03:49:54 PDT 2021
Author: madhur13490
Date: 2021-06-30T16:19:39+05:30
New Revision: a7ed55f64c5fdce9af3257458779402fb9de1f8b
URL: https://github.com/llvm/llvm-project/commit/a7ed55f64c5fdce9af3257458779402fb9de1f8b
DIFF: https://github.com/llvm/llvm-project/commit/a7ed55f64c5fdce9af3257458779402fb9de1f8b.diff
LOG: [AMDGPU] Simplify getReservedNumSGPRs
This is a followup patch on D103636 where
it seemed checking on amdgpu-calls and
amdgpu-stack-objects is unnecessary. Removing these
checks didn't regress any tests functionally.
Reviewed By: arsenm
Differential Revision: https://reviews.llvm.org/D104513
Added:
Modified:
llvm/lib/Target/AMDGPU/AMDGPUSubtarget.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUSubtarget.cpp b/llvm/lib/Target/AMDGPU/AMDGPUSubtarget.cpp
index 37480ffbf05a..e67a76eeb4cb 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUSubtarget.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUSubtarget.cpp
@@ -821,15 +821,17 @@ unsigned GCNSubtarget::getReservedNumSGPRs(const MachineFunction &MF) const {
unsigned GCNSubtarget::getReservedNumSGPRs(const Function &F) const {
// The logic to detect if the function has
- // flat scratch init is same as how MachineFunctionInfo derives.
+ // flat scratch init is slightly
diff erent than how
+ // SIMachineFunctionInfo constructor derives.
+ // We don't use amdgpu-calls, amdgpu-stack-objects
+ // attributes and isAmdHsaOrMesa here as it doesn't really matter.
+ // TODO: Outline this derivation logic and have just
+ // one common function in the backend to avoid duplication.
+ 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())
- FunctionHasFlatScratchInit = true;
+ if (hasFlatAddressSpace() && isEntry && !flatScratchIsArchitected() &&
+ enableFlatScratch()) {
+ FunctionHasFlatScratchInit = true;
}
return getBaseReservedNumSGPRs(FunctionHasFlatScratchInit);
}
More information about the llvm-commits
mailing list