From 380a4723ea98067c28d54f30e1a652483a6a257a Mon Sep 17 00:00:00 2001 From: SingleAccretion <62474226+SingleAccretion@users.noreply.github.com> Date: Mon, 7 Mar 2022 21:10:39 +0300 Subject: [PATCH] Fix a couple issues with GTF_GLOB_REF setting (#66247) Add it to INDs and BLKs off of exposed ADDRs in addition to OBJs. Remove code from args morphing which was re-deriving the side effects flags for an OBJ argument, it was: a) Unnecessary, as morph has already done all the work. b) Incorrect, as it lost GTF_GLOB_REF for OBJ(ADDR(LCL (AX)))-like trees. --- src/coreclr/jit/morph.cpp | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/src/coreclr/jit/morph.cpp b/src/coreclr/jit/morph.cpp index a99d7b9b5bb..2d61a13ba4c 100644 --- a/src/coreclr/jit/morph.cpp +++ b/src/coreclr/jit/morph.cpp @@ -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); @@ -12419,19 +12413,22 @@ DONE_MORPHING_CHILDREN: 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)) { -- GitLab