Skip to content

Commit

Permalink
Reserve return reg for cross-reg-file copy (dotnet#37863)
Browse files Browse the repository at this point in the history
  • Loading branch information
CarolEidt committed Jun 16, 2020
1 parent 9929c07 commit 382dce3
Showing 1 changed file with 30 additions and 2 deletions.
32 changes: 30 additions & 2 deletions src/coreclr/src/jit/lsrabuild.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3485,12 +3485,36 @@ int LinearScan::BuildReturn(GenTree* tree)
retTypeDesc.GetReturnRegCount());
}
srcCount = pRetTypeDesc->GetReturnRegCount();
// For any source that's coming from a different register file, we need to ensure that
// we reserve the specific ABI register we need.
bool hasMismatchedRegTypes = false;
if (op1->IsMultiRegLclVar())
{
for (int i = 0; i < srcCount; i++)
{
RegisterType srcType = regType(op1->AsLclVar()->GetFieldTypeByIndex(compiler, i));
RegisterType dstType = regType(pRetTypeDesc->GetReturnRegType(i));
if (srcType != dstType)
{
hasMismatchedRegTypes = true;
regMaskTP dstRegMask = genRegMask(pRetTypeDesc->GetABIReturnReg(i));
if (varTypeIsFloating(dstType))
{
buildInternalFloatRegisterDefForNode(tree, dstRegMask);
}
else
{
buildInternalIntRegisterDefForNode(tree, dstRegMask);
}
}
}
}
for (int i = 0; i < srcCount; i++)
{
// We will build uses of the type of the operand registers/fields, and the codegen
// for return will move as needed.
if (!op1->OperIs(GT_LCL_VAR) || (regType(op1->AsLclVar()->GetFieldTypeByIndex(compiler, i)) ==
regType(pRetTypeDesc->GetReturnRegType(i))))
if (!hasMismatchedRegTypes || (regType(op1->AsLclVar()->GetFieldTypeByIndex(compiler, i)) ==
regType(pRetTypeDesc->GetReturnRegType(i))))
{
BuildUse(op1, genRegMask(pRetTypeDesc->GetABIReturnReg(i)), i);
}
Expand All @@ -3499,6 +3523,10 @@ int LinearScan::BuildReturn(GenTree* tree)
BuildUse(op1, RBM_NONE, i);
}
}
if (hasMismatchedRegTypes)
{
buildInternalRegisterUses();
}
return srcCount;
}
}
Expand Down

0 comments on commit 382dce3

Please sign in to comment.