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

JIT: tolerate byref/nint return type mismatches during inlining #18274

Merged
merged 1 commit into from
Jun 4, 2018
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
18 changes: 14 additions & 4 deletions src/jit/importer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15782,10 +15782,20 @@ bool Compiler::impReturnInstruction(BasicBlock* block, int prefixFlags, OPCODE&

if (returnType != originalCallType)
{
JITDUMP("Return type mismatch, have %s, needed %s\n", varTypeName(returnType),
varTypeName(originalCallType));
compInlineResult->NoteFatal(InlineObservation::CALLSITE_RETURN_TYPE_MISMATCH);
return false;
// Allow TYP_BYREF to be returned as TYP_I_IMPL and vice versa
if (((returnType == TYP_BYREF) && (originalCallType == TYP_I_IMPL)) ||
((returnType == TYP_I_IMPL) && (originalCallType == TYP_BYREF)))
{
JITDUMP("Allowing return type mismatch: have %s, needed %s\n", varTypeName(returnType),
varTypeName(originalCallType));
}
else
{
JITDUMP("Return type mismatch: have %s, needed %s\n", varTypeName(returnType),
varTypeName(originalCallType));
compInlineResult->NoteFatal(InlineObservation::CALLSITE_RETURN_TYPE_MISMATCH);
return false;
}
}

// Below, we are going to set impInlineInfo->retExpr to the tree with the return
Expand Down