Skip to content

Commit

Permalink
Compute ByteSize the old way
Browse files Browse the repository at this point in the history
  • Loading branch information
jakobbotsch committed Jun 16, 2024
1 parent 00f5bbc commit d37cba7
Showing 1 changed file with 22 additions and 9 deletions.
31 changes: 22 additions & 9 deletions src/coreclr/jit/morph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2145,14 +2145,12 @@ void CallArgs::AddFinalArgsAndDetermineABIInfo(Compiler* comp, GenTreeCall* call

arg.AbiInfo.SetSplit(true);
arg.AbiInfo.ByteOffset = 0;
arg.AbiInfo.ByteSize = 0;
unsigned regNumIndex = 0;
for (unsigned i = 0; i < abiInfo.NumSegments; i++)
{
const ABIPassingSegment& segment = abiInfo.Segments[i];
if (segment.IsPassedInRegister())
{
arg.AbiInfo.ByteSize += segment.Size;
if (regNumIndex < MAX_ARG_REG_COUNT)
{
arg.AbiInfo.SetRegNum(regNumIndex, segment.GetRegister());
Expand All @@ -2163,7 +2161,6 @@ void CallArgs::AddFinalArgsAndDetermineABIInfo(Compiler* comp, GenTreeCall* call
}
else
{
arg.AbiInfo.ByteSize += roundUp(segment.Size, TARGET_POINTER_SIZE);
assert(segment.GetStackOffset() == 0);
}
}
Expand All @@ -2173,7 +2170,6 @@ void CallArgs::AddFinalArgsAndDetermineABIInfo(Compiler* comp, GenTreeCall* call
// This is a register argument
m_hasRegArgs = true;

arg.AbiInfo.ByteSize = 0;
unsigned regNumIndex = 0;
for (unsigned i = 0; i < abiInfo.NumSegments; i++)
{
Expand All @@ -2185,7 +2181,6 @@ void CallArgs::AddFinalArgsAndDetermineABIInfo(Compiler* comp, GenTreeCall* call
regNumIndex++;
}

arg.AbiInfo.ByteSize += segment.Size;
arg.AbiInfo.NumRegs++;

#ifdef TARGET_ARM
Expand Down Expand Up @@ -2216,7 +2211,6 @@ void CallArgs::AddFinalArgsAndDetermineABIInfo(Compiler* comp, GenTreeCall* call
m_hasStackArgs = true;
const ABIPassingSegment& segment = abiInfo.Segments[0];
arg.AbiInfo.SetRegNum(0, REG_STK);
arg.AbiInfo.ByteSize = roundUp(segment.Size, TARGET_POINTER_SIZE);
arg.AbiInfo.ByteOffset = segment.GetStackOffset();
}

Expand Down Expand Up @@ -2249,6 +2243,28 @@ void CallArgs::AddFinalArgsAndDetermineABIInfo(Compiler* comp, GenTreeCall* call
}
}

if (arg.AbiInfo.PassedByRef)
{
arg.AbiInfo.ByteSize = TARGET_POINTER_SIZE;
}
else
{
unsigned size = argLayout != nullptr ? argLayout->GetSize() : genTypeSize(argSigType);

// Apple arm64 reuses the same stack slot for multiple args in some
// cases; old ABI info reflects that in the size.
// Primitives and float HFAs do not necessarily take up full stack
// slots.
if (compAppleArm64Abi() && (!varTypeIsStruct(argSigType) || (isHfaArg && (hfaType == TYP_FLOAT))))
{
arg.AbiInfo.ByteSize = size;
}
else
{
arg.AbiInfo.ByteSize = roundUp(size, TARGET_POINTER_SIZE);
}
}

if (isHfaArg)
{
arg.AbiInfo.SetHfaType(hfaType, hfaSlots);
Expand Down Expand Up @@ -4607,9 +4623,6 @@ bool Compiler::fgCanFastTailCall(GenTreeCall* callee, const char** failReason)
unsigned calleeArgStackSize = callee->gtArgs.OutgoingArgsStackSize();
unsigned callerArgStackSize = roundUp(lvaParameterStackSize, TARGET_POINTER_SIZE);

JITDUMP("Caller parameter stack size: %u\n", callerArgStackSize);
JITDUMP("Callee arguments stack size: %u", calleeArgStackSize);

auto reportFastTailCallDecision = [&](const char* thisFailReason) {
if (failReason != nullptr)
{
Expand Down

0 comments on commit d37cba7

Please sign in to comment.