diff options
author | Andy Ayers <andya@microsoft.com> | 2018-03-16 08:07:30 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-03-16 08:07:30 -0700 |
commit | f6213ca44958a2868d29f7ec806d24f5e84dde48 (patch) | |
tree | c4166c083b8e87c3cdd3d8f460ce5d76bd811e3c /src | |
parent | 914e684fb155c53db8d33d35c4ecf108f40fca74 (diff) | |
download | coreclr-f6213ca44958a2868d29f7ec806d24f5e84dde48.tar.gz coreclr-f6213ca44958a2868d29f7ec806d24f5e84dde48.tar.bz2 coreclr-f6213ca44958a2868d29f7ec806d24f5e84dde48.zip |
JIT: fix return type mismatch inline block for literal argument (#16966)
When we inline a method that returns one of its arguments, we need to make sure
to apply the callee's view of the argument type.
We fixed this for arguments that are caller locals in #11218. This change applies
similar logic to handle the case where the caller passes a literal constant.
Closes #16944.
Diffstat (limited to 'src')
-rw-r--r-- | src/jit/importer.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/jit/importer.cpp b/src/jit/importer.cpp index 787d758158..30faec23b8 100644 --- a/src/jit/importer.cpp +++ b/src/jit/importer.cpp @@ -15819,6 +15819,8 @@ 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; } @@ -18670,6 +18672,17 @@ GenTree* Compiler::impInlineFetchArg(unsigned lclNum, InlArgInfo* inlArgInfo, In op1 = gtCloneExpr(argInfo.argNode); PREFIX_ASSUME(op1 != nullptr); argInfo.argTmpNum = BAD_VAR_NUM; + + // We may need to retype to ensure we match the callee's view of the type. + // Otherwise callee-pass throughs of arguments can create return type + // mismatches that block inlining. + // + // Note argument type mismatches that prevent inlining should + // have been caught in impInlineInitVars. + if (op1->TypeGet() != lclTyp) + { + op1->gtType = genActualType(lclTyp); + } } else if (argInfo.argIsLclVar && !argCanBeModified && !argInfo.argHasCallerLocalRef) { |