Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Propagate typeof() during inlining #71778

Merged
merged 8 commits into from
Jul 10, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 2 additions & 11 deletions src/coreclr/jit/fginline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1604,21 +1604,12 @@ Statement* Compiler::fgInlinePrependStatements(InlineInfo* inlineInfo)
}
else
{
/* The argument is either not used or a const or lcl var */

// The argument is either not used or a const or lcl var
noway_assert(!argInfo.argIsUsed || argInfo.argIsInvariant || argInfo.argIsLclVar);

/* Make sure we didnt change argNode's along the way, or else
subsequent uses of the arg would have worked with the bashed value */
if (argInfo.argIsInvariant)
{
assert(argNode->OperIsConst() || argNode->gtOper == GT_ADDR);
}
noway_assert((argInfo.argIsLclVar == 0) ==
(argNode->gtOper != GT_LCL_VAR || (argNode->gtFlags & GTF_GLOB_REF)));

/* If the argument has side effects, append it */

// If the argument has side effects, append it
if (argInfo.argHasSideEff)
{
noway_assert(argInfo.argIsUsed == false);
Expand Down
19 changes: 14 additions & 5 deletions src/coreclr/jit/importer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20206,6 +20206,17 @@ void Compiler::impInlineRecordArgInfo(InlineInfo* pInlineInfo,
return;
}
}
else
{
if (curArgVal->IsCall() &&
(curArgVal->AsCall()->gtCallMethHnd == eeFindHelper(CORINFO_HELP_TYPEHANDLE_TO_RUNTIMETYPE)) &&
(gtGetHelperArgClassHandle(curArgVal->AsCall()->gtArgs.GetArgByIndex(0)->GetEarlyNode()) !=
NO_CLASS_HANDLE))
EgorBo marked this conversation as resolved.
Show resolved Hide resolved
{
inlCurArgInfo->argIsInvariant = true;
inlCurArgInfo->argHasSideEff = false;
}
}

bool isExact = false;
bool isNonNull = false;
Expand Down Expand Up @@ -20242,7 +20253,7 @@ void Compiler::impInlineRecordArgInfo(InlineInfo* pInlineInfo,
}
if (inlCurArgInfo->argIsInvariant)
{
printf(" is a constant");
printf(" is a constant or invariant");
}
if (inlCurArgInfo->argHasGlobRef)
{
Expand Down Expand Up @@ -20508,10 +20519,9 @@ void Compiler::impInlineInitVars(InlineInfo* pInlineInfo)

inlArgInfo[i].argIsLclVar = false;
// Try to fold the node in case we have constant arguments.
if (inlArgInfo[i].argIsInvariant)
if (inlArgInfo[i].argIsInvariant && inlArgNode->OperIsConst())
{
inlArgNode = gtFoldExprConst(inlArgNode);
assert(inlArgNode->OperIsConst());
}
*pInlArgNode = inlArgNode;
}
Expand All @@ -20525,10 +20535,9 @@ void Compiler::impInlineInitVars(InlineInfo* pInlineInfo)

/* Try to fold the node in case we have constant arguments */

if (inlArgInfo[i].argIsInvariant)
if (inlArgInfo[i].argIsInvariant && inlArgNode->OperIsConst())
{
inlArgNode = gtFoldExprConst(inlArgNode);
assert(inlArgNode->OperIsConst());
}
*pInlArgNode = inlArgNode;
}
Expand Down