Skip to content

Commit

Permalink
Remove popped trees more aggressively. (#31677)
Browse files Browse the repository at this point in the history
When processing CEE_POP the importer sometimes created trees
like
ASG(tmp1, expr)
followed by
COMMA(ADDR(tmp1), NOP))
and that was causing some CQ issues.

LocalAddressVisitor was then marking tmp1 as address-exposed
and we never get rid of the dead ASG(tmp1, expr). What's worse, we
then were adding a zero-initialization for tmp1 in the prolog.

The fix here is to create a NOP instead of a COMMA is there are
no side-effects in the first operand of the COMMA.

This addresses the first example in #2325.
  • Loading branch information
erozenfeld authored Feb 3, 2020
1 parent ca86075 commit 9b2f32d
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/coreclr/src/jit/importer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13043,12 +13043,16 @@ void Compiler::impImportBlockCode(BasicBlock* block)
op1 = op1->AsOp()->gtOp1;
}

// If 'op1' is an expression, create an assignment node.
// Helps analyses (like CSE) to work fine.

if (op1->gtOper != GT_CALL)
{
op1 = gtUnusedValNode(op1);
if ((op1->gtFlags & GTF_SIDE_EFFECT) != 0)
{
op1 = gtUnusedValNode(op1);
}
else
{
op1->gtBashToNOP();
}
}

/* Append the value to the tree list */
Expand Down

0 comments on commit 9b2f32d

Please sign in to comment.