[llvm-branch-commits] [llvm] [AMDGPU] caller/callee scratch awareness in adjustInliningThreshold (PR #227792)
Janek van Oirschot via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Fri Oct 2 05:02:29 PDT 2026
================
@@ -1758,6 +1758,13 @@ unsigned GCNTTIImpl::adjustInliningThreshold(const CallBase *CB) const {
unsigned AllocaSize = getCallArgsTotalAllocaSize(CB, DL);
if (AllocaSize > 0)
Threshold += ArgAllocaCost;
+
+ // Making a call from a non-kernel will require saving return address into
+ // scratch. Add a bonus to threshold to discourage scratch use.
+ static const unsigned ScratchBonus = 200;
+ if (isCallableCC(CB->getCaller()->getCallingConv()))
----------------
JanekvO wrote:
I think generalizing it into the rule/heuristic: "incentivize inlining to prevent caller/callee related scratch use" is more in line with what this function is already doing with e.g., the function args at the top of this function. The unreachable terminated blocks are just a case that is more likely to be affected by this since that case sets the threshold to 0 to de-incentivize the inlining (see related stacked PR: #227789).
https://github.com/llvm/llvm-project/pull/227792
More information about the llvm-branch-commits
mailing list