[PATCH] D143498: Reapply "[AMDGPU] Modify adjustInliningThreshold to also consider the cost of passing function arguments through the stack"

Janek van Oirschot via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 7 07:11:34 PST 2023


JanekvO created this revision.
Herald added subscribers: kosarev, foad, kerbowa, hiraditya, tpr, dstuttard, yaxunl, jvesely, kzhuravl, arsenm.
Herald added a project: All.
JanekvO requested review of this revision.
Herald added subscribers: llvm-commits, sstefan1, wdng.
Herald added a reviewer: jdoerfert.
Herald added a project: LLVM.

Reapplies 142c28ffa1323e9a8d53200a22c80d5d778e0d0f <https://reviews.llvm.org/rG142c28ffa1323e9a8d53200a22c80d5d778e0d0f> as part of D140242 <https://reviews.llvm.org/D140242> which got reverted due to amdgpu openmp test failures.

This diff fixes said failures by eliding most of `adjustInliningThresholdUsingCallee` for indirect calls as the callee function is unavailable for indirect calls.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D143498

Files:
  llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.cpp
  llvm/test/Transforms/Inline/AMDGPU/amdgpu-inline-stack-indirect-call-argument.ll


Index: llvm/test/Transforms/Inline/AMDGPU/amdgpu-inline-stack-indirect-call-argument.ll
===================================================================
--- /dev/null
+++ llvm/test/Transforms/Inline/AMDGPU/amdgpu-inline-stack-indirect-call-argument.ll
@@ -0,0 +1,22 @@
+; REQUIRES: asserts
+; RUN: opt -mtriple=amdgcn-amd-amdhsa -S -passes=inline -inline-cost-full=true -debug-only=inline-cost < %s 2>&1 | FileCheck %s
+
+; CHECK: Analyzing call of Dummy... (caller:Caller) 
+
+define void @Wrapper(ptr nocapture nofree noundef readonly %func, ptr noundef %arg, i32 noundef %a) {
+entry:
+  call void %func(ptr noundef %arg, i32 noundef %a)
+  ret void
+}
+
+define internal void @Dummy(ptr noundef %ptrarg, i32 noundef %intarg) {
+entry:
+  ret void
+}
+
+define void @Caller() {
+entry:
+  %arg = alloca ptr
+  call void @Wrapper(ptr noundef @Dummy, ptr noundef %arg, i32 42)
+  ret void
+}
Index: llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.cpp
===================================================================
--- llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.cpp
+++ llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.cpp
@@ -1175,6 +1175,11 @@
   const int NrOfSGPRUntilSpill = 26;
   const int NrOfVGPRUntilSpill = 32;
 
+  // In case of indirect calls, callee Function may not be retrievable from the
+  // CallBase.
+  if (!Callee)
+    return 0;
+
   const DataLayout &DL = TTIImpl->getDataLayout();
 
   unsigned adjustThreshold = 0;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D143498.495529.patch
Type: text/x-patch
Size: 1456 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230207/a5745c55/attachment.bin>


More information about the llvm-commits mailing list