From 189b03c8a22d83140da6a5449d5b2022e3a9792a Mon Sep 17 00:00:00 2001 From: SingleAccretion Date: Sat, 5 Mar 2022 21:44:58 +0300 Subject: [PATCH] Fix a couple issues with GTF_GLOB_REF setting 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 cc532365a6e8f..aff46b844dacc 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 @@ 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)) {