Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit a27d5cc

Browse files
committed
Merge pull request #1912 from LLITCHEV/Issue1831-for-rc1
The fgCanFastTailCall was not incrementing the callee arg number for the
2 parents 65cb774 + 61d8395 commit a27d5cc

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

src/jit/morph.cpp

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5709,7 +5709,25 @@ bool Compiler::fgCanFastTailCall(GenTreeCall* callee)
57095709
if (argx->OperGet() == GT_LDOBJ)
57105710
{
57115711
#ifdef _TARGET_AMD64_
5712-
hasMultiByteArgs = !VarTypeIsMultiByteAndCanEnreg(TYP_STRUCT, argx->gtLdObj.gtClass, nullptr);
5712+
5713+
unsigned typeSize = 0;
5714+
hasMultiByteArgs = !VarTypeIsMultiByteAndCanEnreg(TYP_STRUCT, argx->gtLdObj.gtClass, &typeSize);
5715+
5716+
#if defined(FEATURE_UNIX_AMD64_STRUCT_PASSING)
5717+
// On System V the args could be a 2 eightbyte struct that is passed in two registers.
5718+
// Account for the second eightbyte in the nCalleeArgs.
5719+
// TODO-CQ-Amd64-Unix: Structs of size between 9 to 16 bytes are conservatively estimated
5720+
// as two args, since they need two registers. Whereas nCallerArgs is
5721+
// counting such an arg as one.This would mean we will not be optimizing
5722+
// certain calls though technically possible.
5723+
5724+
if (typeSize > TARGET_POINTER_SIZE)
5725+
{
5726+
unsigned extraArgRegsToAdd = (typeSize / TARGET_POINTER_SIZE);
5727+
nCalleeArgs += extraArgRegsToAdd;
5728+
}
5729+
#endif // defined(FEATURE_UNIX_AMD64_STRUCT_PASSING)
5730+
57135731
#else
57145732
assert(!"Target platform ABI rules regarding passing struct type args in registers");
57155733
unreached();

0 commit comments

Comments
 (0)