From 67f07aac0874294ee5c038fbc4b30736bbd1d8f3 Mon Sep 17 00:00:00 2001 From: Andy Ayers Date: Mon, 4 Jun 2018 16:02:01 -0700 Subject: [PATCH] JIT: tolerate byref/nint return type mismatches during inlining (#18274) Have the jit tolerate byref/nint return type mismatches for inlines same way that it tolerates them for ret instructions. Fixes #18270. --- src/jit/importer.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/jit/importer.cpp b/src/jit/importer.cpp index 0811e7b..d7f0fe8 100644 --- a/src/jit/importer.cpp +++ b/src/jit/importer.cpp @@ -15777,10 +15777,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 -- 2.7.4