Skip to content

Commit 67f07aa

Browse files
authoredJun 4, 2018
JIT: tolerate byref/nint return type mismatches during inlining (dotnet#18274)
Have the jit tolerate byref/nint return type mismatches for inlines same way that it tolerates them for ret instructions. Fixes #18270.
1 parent e8214ea commit 67f07aa

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed
 

‎src/jit/importer.cpp

+14-4
Original file line numberDiff line numberDiff line change
@@ -15777,10 +15777,20 @@ bool Compiler::impReturnInstruction(BasicBlock* block, int prefixFlags, OPCODE&
1577715777

1577815778
if (returnType != originalCallType)
1577915779
{
15780-
JITDUMP("Return type mismatch, have %s, needed %s\n", varTypeName(returnType),
15781-
varTypeName(originalCallType));
15782-
compInlineResult->NoteFatal(InlineObservation::CALLSITE_RETURN_TYPE_MISMATCH);
15783-
return false;
15780+
// Allow TYP_BYREF to be returned as TYP_I_IMPL and vice versa
15781+
if (((returnType == TYP_BYREF) && (originalCallType == TYP_I_IMPL)) ||
15782+
((returnType == TYP_I_IMPL) && (originalCallType == TYP_BYREF)))
15783+
{
15784+
JITDUMP("Allowing return type mismatch: have %s, needed %s\n", varTypeName(returnType),
15785+
varTypeName(originalCallType));
15786+
}
15787+
else
15788+
{
15789+
JITDUMP("Return type mismatch: have %s, needed %s\n", varTypeName(returnType),
15790+
varTypeName(originalCallType));
15791+
compInlineResult->NoteFatal(InlineObservation::CALLSITE_RETURN_TYPE_MISMATCH);
15792+
return false;
15793+
}
1578415794
}
1578515795

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

0 commit comments

Comments
 (0)
Please sign in to comment.