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

JIT: generalize checking for valid IR after a tail call #51903

Merged
merged 1 commit into from
Apr 27, 2021
Merged
Changes from all 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
20 changes: 17 additions & 3 deletions src/coreclr/jit/morph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7659,6 +7659,9 @@ GenTree* Compiler::fgMorphPotentialTailCall(GenTreeCall* call)

// Check if we have a sequence of GT_ASG blocks where the same variable is assigned
// to temp locals over and over.
//
// Also allow casts on the RHSs of the assignments, and blocks with GT_NOPs.
//
if (nextNextBlock->bbJumpKind != BBJ_RETURN)
{
// Make sure the block has a single statement
Expand All @@ -7673,9 +7676,20 @@ GenTree* Compiler::fgMorphPotentialTailCall(GenTreeCall* call)
{
assert(nextNextBlock->firstStmt() == nextNextBlock->lastStmt());
asgNode = nextNextBlock->firstStmt()->GetRootNode();
assert(asgNode->OperIs(GT_ASG));
assert(lcl == asgNode->gtGetOp2()->AsLclVarCommon()->GetLclNum());
lcl = asgNode->gtGetOp1()->AsLclVarCommon()->GetLclNum();
if (!asgNode->OperIs(GT_NOP))
{
assert(asgNode->OperIs(GT_ASG));

GenTree* rhs = asgNode->gtGetOp2();
while (rhs->OperIs(GT_CAST))
{
assert(!rhs->gtOverflow());
rhs = rhs->gtGetOp1();
}

assert(lcl == rhs->AsLclVarCommon()->GetLclNum());
lcl = rhs->AsLclVarCommon()->GetLclNum();
}
nextNextBlock = nextNextBlock->GetUniqueSucc();
}
}
Expand Down