================
@@ -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;
----------------
JanekvO wrote:
> What is the reasoning behind the constant value?
I am a bit unsatisfied with the answer: the value covers the specific device
side assert case. I initially took the same addend value as the function arg
case but 4000 seemed a bit overkill for this so 200 seemed a bit more
reasonable while still covering the device side assert case 😅
For a bit more context: the inlining cost is computed by adding a instrcost for
each instruction in a function (and not counting loop iterations), with some
surrounding cost minuses/plusses depending on things like static functions. The
threshold, however, is set and then multiplied through some bonuses and then
multiplied by 11 for AMDGPU so I'm not sure how to fit that in as a mental
model.
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