From 2a6820bf0c1a835aeedc6ed4c75e35b632f1fc56 Mon Sep 17 00:00:00 2001 From: Andy Ayers Date: Tue, 25 Apr 2017 16:06:44 -0700 Subject: [PATCH] JIT: fix return type mismatch inlining block If caller passes a directly substitutable expression whose type is compatible with but not the same as the callee argument type, and that argument is the callee's return value, the jit may reject inlining the method because of a return type mismatch. Fix is to retype the expressions we use in the callee's body as the callee's type. Closes dotnet/coreclr#11211. Commit migrated from https://github.com/dotnet/coreclr/commit/7f8a620ea74dfb57e52320601addda68e2f53f53 --- src/coreclr/src/jit/importer.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/coreclr/src/jit/importer.cpp b/src/coreclr/src/jit/importer.cpp index 2e3ca81..c55aaf1 100644 --- a/src/coreclr/src/jit/importer.cpp +++ b/src/coreclr/src/jit/importer.cpp @@ -17947,8 +17947,12 @@ GenTreePtr Compiler::impInlineFetchArg(unsigned lclNum, InlArgInfo* inlArgInfo, op1 = argInfo.argNode; argInfo.argTmpNum = op1->gtLclVarCommon.gtLclNum; - // Use an equivalent copy if this is the second or subsequent use. - if (argInfo.argIsUsed) + // Use an equivalent copy if this is the second or subsequent + // use, or if we need to retype. + // + // Note argument type mismatches that prevent inlining should + // have been caught in impInlineInitVars. + if (argInfo.argIsUsed || (op1->TypeGet() != lclTyp)) { assert(op1->gtOper == GT_LCL_VAR); assert(lclNum == op1->gtLclVar.gtLclILoffs); -- 2.7.4