Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions src/coreclr/jit/importercalls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7243,6 +7243,38 @@ bool Compiler::isCompatibleMethodGDV(GenTreeCall* call, CORINFO_METHOD_HANDLE gd
CORINFO_ARG_LIST_HANDLE sigParam = sig.args;
unsigned numParams = sig.numArgs;
unsigned numArgs = 0;

var_types gdvType = JITtype2varType(sig.retType);
var_types callType = call->gtReturnType;

const bool sameRetTypes =
(genActualType(callType) == genActualType(gdvType)) || (varTypeIsStruct(callType) && varTypeIsStruct(gdvType));
if (!sameRetTypes)
{
JITDUMP("Incompatible method GDV: Return types do not match - bail out.\n");
return false;
}

if (varTypeIsStruct(gdvType))
{
assert(varTypeIsStruct(callType));

CORINFO_SIG_INFO callSig;
info.compCompHnd->getMethodSig(call->gtCallMethHnd, &callSig);

structPassingKind callRetKind;
structPassingKind gdvRetKind;
getReturnTypeForStruct(callSig.retTypeClass, call->GetUnmanagedCallConv(), &callRetKind);
getReturnTypeForStruct(sig.retTypeClass, call->GetUnmanagedCallConv(), &gdvRetKind);

if ((callRetKind != gdvRetKind) ||
!ClassLayout::AreCompatible(typGetObjLayout(callSig.retTypeClass), typGetObjLayout(sig.retTypeClass)))
{
JITDUMP("Incompatible method GDV: Return struct types do not match - bail out.\n");
return false;
}
}

for (CallArg& arg : call->gtArgs.Args())
{
switch (arg.GetWellKnownArg())
Expand Down
Loading