================
@@ -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
_______________________________________________
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits

Reply via email to