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
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);