Skip to content

Commit

Permalink
JIT: generalize checking for valid IR after a tail call (#51903)
Browse files Browse the repository at this point in the history
Allow NOPs and assignments with non-overflowing casts, in addition
to the assignments we already allowed.

Closes #51898.
  • Loading branch information
AndyAyersMS authored Apr 27, 2021
1 parent d1fed28 commit 2d71fe2
Showing 1 changed file with 17 additions and 3 deletions.
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

0 comments on commit 2d71fe2

Please sign in to comment.