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

Fix a couple issues with GTF_GLOB_REF setting #66247

Merged
merged 1 commit into from
Mar 7, 2022
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
29 changes: 13 additions & 16 deletions src/coreclr/jit/morph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4917,12 +4917,6 @@ void Compiler::fgMakeOutgoingStructArgCopy(GenTreeCall* call, GenTreeCall::Use*
GenTree* dest = gtNewLclvNode(tmp, lvaTable[tmp].lvType);
dest->gtFlags |= (GTF_DONT_CSE | GTF_VAR_DEF); // This is a def of the local, "entire" by construction.

if (argx->gtOper == GT_OBJ)
{
argx->gtFlags &= ~(GTF_ALL_EFFECT) | (argx->AsBlk()->Addr()->gtFlags & GTF_ALL_EFFECT);
argx->SetIndirExceptionFlags(this);
}

// Copy the valuetype to the temp
GenTree* copyBlk = gtNewBlkOpNode(dest, argx, false /* not volatile */, true /* copyBlock */);
copyBlk = fgMorphCopyBlock(copyBlk);
Expand Down Expand Up @@ -12419,19 +12413,22 @@ GenTree* Compiler::fgMorphSmpOp(GenTree* tree, MorphAddrContext* mac)
break;

case GT_OBJ:
// If we have GT_OBJ(GT_ADDR(X)) and X has GTF_GLOB_REF, we must set GTF_GLOB_REF on
// the GT_OBJ. Note that the GTF_GLOB_REF will have been cleared on ADDR(X) where X
// is a local or clsVar, even if it has been address-exposed.
if (op1->OperGet() == GT_ADDR)
case GT_BLK:
case GT_IND:
{
// If we have IND(ADDR(X)) and X has GTF_GLOB_REF, we must set GTF_GLOB_REF on
// the OBJ. Note that the GTF_GLOB_REF will have been cleared on ADDR(X) where X
// is a local or CLS_VAR, even if it has been address-exposed.
if (op1->OperIs(GT_ADDR))
{
GenTreeUnOp* addr = op1->AsUnOp();
GenTree* addrOp = addr->gtGetOp1();
tree->gtFlags |= (addrOp->gtFlags & GTF_GLOB_REF);
tree->gtFlags |= (op1->AsUnOp()->gtGetOp1()->gtFlags & GTF_GLOB_REF);
}

if (!tree->OperIs(GT_IND))
{
break;
}
break;

case GT_IND:
{
// Can not remove a GT_IND if it is currently a CSE candidate.
if (gtIsActiveCSE_Candidate(tree))
{
Expand Down