[PATCH] D104513: [AMDGPU] Simplify getReservedNumSGPRs

Madhur Amilkanthwar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 30 03:49:59 PDT 2021


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa7ed55f64c5f: [AMDGPU] Simplify getReservedNumSGPRs (authored by madhur13490).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D104513/new/

https://reviews.llvm.org/D104513

Files:
  llvm/lib/Target/AMDGPU/AMDGPUSubtarget.cpp


Index: llvm/lib/Target/AMDGPU/AMDGPUSubtarget.cpp
===================================================================
--- llvm/lib/Target/AMDGPU/AMDGPUSubtarget.cpp
+++ llvm/lib/Target/AMDGPU/AMDGPUSubtarget.cpp
@@ -821,15 +821,17 @@
 
 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 different 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);
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D104513.355499.patch
Type: text/x-patch
Size: 1488 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210630/efaa5a52/attachment.bin>


More information about the llvm-commits mailing list