Skip to content

Commit

Permalink
JIT: Check layout equality of GT_OBJ/GT_BLK nodes in GenTree::Compare
Browse files Browse the repository at this point in the history
  • Loading branch information
jakobbotsch committed Nov 14, 2022
1 parent 16e4b9a commit 0dd9d09
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/coreclr/jit/gentree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2511,15 +2511,27 @@ bool GenTree::Compare(GenTree* op1, GenTree* op2, bool swapOK)

case GT_BLK:
case GT_OBJ:
if ((op1->gtFlags & (GTF_IND_FLAGS)) != (op2->gtFlags & (GTF_IND_FLAGS)))
if (op1->AsBlk()->GetLayout() != op2->AsBlk()->GetLayout())
{
return false;
}

if ((op1->gtFlags & GTF_IND_FLAGS) != (op2->gtFlags & GTF_IND_FLAGS))
{
return false;
}
FALLTHROUGH;

break;

case GT_IND:
case GT_NULLCHECK:
if ((op1->gtFlags & (GTF_IND_FLAGS)) != (op2->gtFlags & (GTF_IND_FLAGS)))
if (op1->TypeIs(TYP_STRUCT))
{
// Rare case -- need contextual information to check equality in some cases.
return false;
}

if ((op1->gtFlags & GTF_IND_FLAGS) != (op2->gtFlags & GTF_IND_FLAGS))
{
return false;
}
Expand Down

0 comments on commit 0dd9d09

Please sign in to comment.