[PATCH] D150609: [AMDGPU] Do not assume stack size for PAL code object indirect calls

Baptiste Saleil via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 12 07:15:34 PDT 2023


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3604fdf18d35: [AMDGPU] Do not assume stack size for PAL code object indirect calls (authored by bsaleil).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150609

Files:
  llvm/lib/Target/AMDGPU/AMDGPUResourceUsageAnalysis.cpp
  llvm/test/CodeGen/AMDGPU/resource-usage-pal.ll


Index: llvm/test/CodeGen/AMDGPU/resource-usage-pal.ll
===================================================================
--- /dev/null
+++ llvm/test/CodeGen/AMDGPU/resource-usage-pal.ll
@@ -0,0 +1,17 @@
+; RUN llc -mtriple=amdgcn-amd-amdpal -mcpu=gfx1100 -verify-machineinstrs < %s | FileCheck %s
+
+; Check that we do not assume any default stack size for PAL code object
+; indirect calls. The driver knows the max recursion depth, so it can compute
+; a more accurate value.
+
+; CHECK: ScratchSize: 0
+; CHECK: scratch_memory_size: 0
+define amdgpu_vs void @test() {
+.entry:
+  %0 = call i64 @llvm.amdgcn.s.getpc()
+  %1 = inttoptr i64 %0 to ptr
+  call amdgpu_gfx void %1()
+  ret void
+}
+
+declare i64 @llvm.amdgcn.s.getpc()
Index: llvm/lib/Target/AMDGPU/AMDGPUResourceUsageAnalysis.cpp
===================================================================
--- llvm/lib/Target/AMDGPU/AMDGPUResourceUsageAnalysis.cpp
+++ llvm/lib/Target/AMDGPU/AMDGPUResourceUsageAnalysis.cpp
@@ -104,6 +104,7 @@
 
   MachineModuleInfo &MMI = getAnalysis<MachineModuleInfoWrapperPass>().getMMI();
   const TargetMachine &TM = TPC->getTM<TargetMachine>();
+  const MCSubtargetInfo &STI = *TM.getMCSubtargetInfo();
   bool HasIndirectCall = false;
 
   CallGraph CG = CallGraph(M);
@@ -111,7 +112,8 @@
 
   // By default, for code object v5 and later, track only the minimum scratch
   // size
-  if (AMDGPU::getCodeObjectVersion(M) >= AMDGPU::AMDHSA_COV5) {
+  if (AMDGPU::getCodeObjectVersion(M) >= AMDGPU::AMDHSA_COV5 ||
+      STI.getTargetTriple().getOS() == Triple::AMDPAL) {
     if (!AssumedStackSizeForDynamicSizeObjects.getNumOccurrences())
       AssumedStackSizeForDynamicSizeObjects = 0;
     if (!AssumedStackSizeForExternalCall.getNumOccurrences())


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D150609.530499.patch
Type: text/x-patch
Size: 1751 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230612/32d8df8c/attachment.bin>


More information about the llvm-commits mailing list