diff --git a/src/coreclr/src/jit/compiler.h b/src/coreclr/src/jit/compiler.h index b0f68bf2420065..31d75cc3af694e 100644 --- a/src/coreclr/src/jit/compiler.h +++ b/src/coreclr/src/jit/compiler.h @@ -3780,11 +3780,7 @@ class Compiler CORINFO_CLASS_HANDLE structHnd, const impAssignPlace& asgPlace, IL_OFFSETX ilOffset = BAD_IL_OFFSET); - GenTree* impAssignStructPtr(GenTree* dest, - GenTree* src, - CORINFO_CLASS_HANDLE structHnd, - const impAssignPlace& asgPlace, - IL_OFFSETX ilOffset = BAD_IL_OFFSET); + GenTree* impAssignStructPtr(GenTree* dest, GenTree* src, CORINFO_CLASS_HANDLE structHnd); GenTree* impGetStructAddr(GenTree* structVal, CORINFO_CLASS_HANDLE structHnd, unsigned curLevel, bool willDeref); diff --git a/src/coreclr/src/jit/gentree.cpp b/src/coreclr/src/jit/gentree.cpp index fc1be8f4cc3907..543da487d7ee07 100644 --- a/src/coreclr/src/jit/gentree.cpp +++ b/src/coreclr/src/jit/gentree.cpp @@ -15055,7 +15055,7 @@ GenTree* Compiler::gtNewRefCOMfield(GenTree* objPtr, { if (varTypeIsStruct(lclTyp)) { - result = impAssignStructPtr(result, assg, structType, impAssignPlace::s_SpillAll); + result = impAssignStructPtr(result, assg, structType); } else { diff --git a/src/coreclr/src/jit/importer.cpp b/src/coreclr/src/jit/importer.cpp index 8aedc7412652b5..e3476120e31387 100644 --- a/src/coreclr/src/jit/importer.cpp +++ b/src/coreclr/src/jit/importer.cpp @@ -1120,7 +1120,7 @@ GenTree* Compiler::impAssignStruct(GenTree* dest, destAddr = gtNewOperNode(GT_ADDR, TYP_BYREF, dest); } - return impAssignStructPtr(destAddr, src, structHnd, asgPlace, ilOffset); + return impAssignStructPtr(destAddr, src, structHnd); } //------------------------------------------------------------------------ @@ -1159,21 +1159,11 @@ GenTree* Compiler::impAssignStruct(GenTree* dest, // // -GenTree* Compiler::impAssignStructPtr(GenTree* destAddr, - GenTree* src, - CORINFO_CLASS_HANDLE structHnd, - const impAssignPlace& asgPlace, - IL_OFFSETX ilOffset /* = BAD_IL_OFFSET */ - ) +GenTree* Compiler::impAssignStructPtr(GenTree* destAddr, GenTree* src, CORINFO_CLASS_HANDLE structHnd) { GenTree* dest = nullptr; unsigned destFlags = 0; - if (ilOffset == BAD_IL_OFFSET) - { - ilOffset = impCurStmtOffs; - } - assert(src->OperIs(GT_LCL_VAR, GT_FIELD, GT_IND, GT_OBJ, GT_CALL, GT_MKREFANY, GT_RET_EXPR, GT_COMMA) || (src->TypeGet() != TYP_STRUCT && (src->OperIsSimdOrHWintrinsic() || src->OperIs(GT_LCL_FLD)))); @@ -1307,14 +1297,12 @@ GenTree* Compiler::impAssignStructPtr(GenTree* destAddr, } else if (src->gtOper == GT_MKREFANY) { - assert(fgImportPhase && !asgPlace.useStmts); // GT_MKREFANY can come only from impImportBlockCode. + assert(fgImportPhase); // GT_MKREFANY can come only from impImportBlockCode. // Since we are assigning the result of a GT_MKREFANY, // "destAddr" must point to a refany. - GenTree* destAddrClone; - destAddr = - impCloneExpr(destAddr, &destAddrClone, structHnd, asgPlace.spillLevel DEBUGARG("MKREFANY assignment")); + GenTree* destAddrClone = gtCloneExpr(destAddr); assert(OFFSETOF__CORINFO_TypedReference__dataPtr == 0); assert(destAddr->gtType == TYP_I_IMPL || destAddr->gtType == TYP_BYREF); @@ -1326,40 +1314,17 @@ GenTree* Compiler::impAssignStructPtr(GenTree* destAddr, GenTree* typeSlot = gtNewOperNode(GT_IND, TYP_I_IMPL, gtNewOperNode(GT_ADD, destAddr->gtType, destAddrClone, typeFieldOffset)); - // append the assign of the pointer value - GenTree* asg = gtNewAssignNode(ptrSlot, src->AsOp()->gtOp1); - impAppendTree(asg, asgPlace.spillLevel, ilOffset); - - // return the assign of the type value, to be appended - return gtNewAssignNode(typeSlot, src->AsOp()->gtOp2); + GenTree* asgOp1 = gtNewAssignNode(ptrSlot, src->AsOp()->gtOp1); + GenTree* asgOp2 = gtNewAssignNode(typeSlot, src->AsOp()->gtOp2); + GenTree* commaOfBoth = gtNewOperNode(GT_COMMA, asgOp2->gtType, asgOp1, asgOp2); + return commaOfBoth; } else if (src->gtOper == GT_COMMA) { // The second thing is the struct or its address. assert(varTypeIsStruct(src->AsOp()->gtOp2) || src->AsOp()->gtOp2->gtType == TYP_BYREF); - if (asgPlace.useStmts) - { - // Insert op1 after '*pAfterStmt' - Statement* newStmt = gtNewStmt(src->AsOp()->gtOp1, ilOffset); - fgInsertStmtAfter(asgPlace.block, *asgPlace.pAfterStmt, newStmt); - *asgPlace.pAfterStmt = newStmt; - } - else if (impLastStmt != nullptr) - { - // Do the side-effect as a separate statement. - impAppendTree(src->AsOp()->gtOp1, asgPlace.spillLevel, ilOffset); - } - else - { - // In this case we have neither been given a statement to insert after, nor are we - // in the importer where we can append the side effect. - // Instead, we're going to sink the assignment below the COMMA. - src->AsOp()->gtOp2 = impAssignStructPtr(destAddr, src->AsOp()->gtOp2, structHnd, asgPlace, ilOffset); - return src; - } - - // Evaluate the second thing using recursion. - return impAssignStructPtr(destAddr, src->AsOp()->gtOp2, structHnd, asgPlace, ilOffset); + // Use the entire comma expression as our rhs. + asgType = impNormStructType(structHnd); } else if (src->IsLocal()) { @@ -6040,7 +6005,7 @@ void Compiler::impImportAndPushBox(CORINFO_RESOLVED_TOKEN* pResolvedToken) if (varTypeIsStruct(exprToBox)) { assert(info.compCompHnd->getClassSize(pResolvedToken->hClass) == info.compCompHnd->getClassSize(operCls)); - op1 = impAssignStructPtr(op1, exprToBox, operCls, impAssignPlace::s_SpillAll); + op1 = impAssignStructPtr(op1, exprToBox, operCls); } else { @@ -15817,7 +15782,7 @@ void Compiler::impImportBlockCode(BasicBlock* block) assertImp(varTypeIsStruct(op2)); - op1 = impAssignStructPtr(op1, op2, resolvedToken.hClass, impAssignPlace::s_SpillAll); + op1 = impAssignStructPtr(op1, op2, resolvedToken.hClass); if (op1->OperIsBlkOp() && (prefixFlags & PREFIX_UNALIGNED)) { @@ -16626,12 +16591,12 @@ bool Compiler::impReturnInstruction(BasicBlock* block, int prefixFlags, OPCODE& { impInlineInfo->retExpr = impAssignStructPtr(dest, gtNewLclvNode(lvaInlineeReturnSpillTemp, info.compRetType), - retClsHnd, impAssignPlace::s_SpillAll); + retClsHnd); } } else { - impInlineInfo->retExpr = impAssignStructPtr(dest, op2, retClsHnd, impAssignPlace::s_SpillAll); + impInlineInfo->retExpr = impAssignStructPtr(dest, op2, retClsHnd); } } } @@ -16653,7 +16618,7 @@ bool Compiler::impReturnInstruction(BasicBlock* block, int prefixFlags, OPCODE& // Assign value to return buff (first param) GenTree* retBuffAddr = gtNewLclvNode(info.compRetBuffArg, TYP_BYREF DEBUGARG(impCurStmtOffs)); - op2 = impAssignStructPtr(retBuffAddr, op2, retClsHnd, impAssignPlace::s_SpillAll); + op2 = impAssignStructPtr(retBuffAddr, op2, retClsHnd); impAppendTree(op2, (unsigned)CHECK_SPILL_NONE, impCurStmtOffs); // There are cases where the address of the implicit RetBuf should be returned explicitly (in RAX).