diff --git a/src/coreclr/jit/gentree.cpp b/src/coreclr/jit/gentree.cpp index ae63956e86294..5106e7931a555 100644 --- a/src/coreclr/jit/gentree.cpp +++ b/src/coreclr/jit/gentree.cpp @@ -17974,14 +17974,11 @@ GenTreeLclVarCommon* GenTree::IsImplicitByrefParameterValuePreMorph(Compiler* co // compiler - compiler instance // addr - [out] tree representing the address computation on top of the implicit byref. // Will be the same as the return value if the whole implicit byref is used, for example. -// offset - [out] Offset that "addr" is adding on top of the returned local. // // Return Value: // Node for the local, or nullptr. // -GenTreeLclVar* GenTree::IsImplicitByrefParameterValuePostMorph(Compiler* compiler, - GenTree** addr, - target_ssize_t* offset) +GenTreeLclVar* GenTree::IsImplicitByrefParameterValuePostMorph(Compiler* compiler, GenTree** addr) { #if FEATURE_IMPLICIT_BYREFS && !defined(TARGET_LOONGARCH64) // TODO-LOONGARCH64-CQ: enable this. @@ -17990,10 +17987,13 @@ GenTreeLclVar* GenTree::IsImplicitByrefParameterValuePostMorph(Compiler* c return nullptr; } - *addr = AsIndir()->Addr(); - + *addr = AsIndir()->Addr(); GenTree* innerAddr = *addr; - compiler->gtPeelOffsets(&innerAddr, offset); + + while (innerAddr->OperIs(GT_ADD) && innerAddr->gtGetOp2()->IsCnsIntOrI()) + { + innerAddr = innerAddr->gtGetOp1(); + } if (innerAddr->OperIs(GT_LCL_VAR)) { diff --git a/src/coreclr/jit/gentree.h b/src/coreclr/jit/gentree.h index ec56b4d248d20..ec043090da346 100644 --- a/src/coreclr/jit/gentree.h +++ b/src/coreclr/jit/gentree.h @@ -1972,7 +1972,7 @@ struct GenTree unsigned* pSize = nullptr); GenTreeLclVarCommon* IsImplicitByrefParameterValuePreMorph(Compiler* compiler); - GenTreeLclVar* IsImplicitByrefParameterValuePostMorph(Compiler* compiler, GenTree** addr, target_ssize_t* offset); + GenTreeLclVar* IsImplicitByrefParameterValuePostMorph(Compiler* compiler, GenTree** addr); unsigned IsLclVarUpdateTree(GenTree** otherTree, genTreeOps* updateOper); diff --git a/src/coreclr/jit/morph.cpp b/src/coreclr/jit/morph.cpp index 981669da08e62..0205f020825ff 100644 --- a/src/coreclr/jit/morph.cpp +++ b/src/coreclr/jit/morph.cpp @@ -3157,15 +3157,13 @@ void Compiler::fgMakeOutgoingStructArgCopy(GenTreeCall* call, CallArg* arg) if (opts.OptimizationEnabled() && arg->AbiInfo.PassedByRef) { GenTree* implicitByRefLclAddr; - target_ssize_t implicitByRefLclOffs; GenTreeLclVarCommon* implicitByRefLcl = - argx->IsImplicitByrefParameterValuePostMorph(this, &implicitByRefLclAddr, &implicitByRefLclOffs); + argx->IsImplicitByrefParameterValuePostMorph(this, &implicitByRefLclAddr); GenTreeLclVarCommon* lcl = implicitByRefLcl; if ((lcl == nullptr) && argx->OperIsLocal()) { - lcl = argx->AsLclVarCommon(); - implicitByRefLclOffs = lcl->GetLclOffs(); + lcl = argx->AsLclVarCommon(); } if (lcl != nullptr) @@ -3193,28 +3191,6 @@ void Compiler::fgMakeOutgoingStructArgCopy(GenTreeCall* call, CallArg* arg) !varDsc->lvPromoted && !varDsc->lvIsStructField && ((lcl->gtFlags & GTF_VAR_DEATH) != 0); } - // Disallow the argument from potentially aliasing the return - // buffer. - if (omitCopy) - { - GenTreeLclVarCommon* retBuffer = gtCallGetDefinedRetBufLclAddr(call); - if ((retBuffer != nullptr) && (retBuffer->GetLclNum() == varNum)) - { - unsigned retBufferSize = typGetObjLayout(call->gtRetClsHnd)->GetSize(); - target_ssize_t retBufferStart = retBuffer->GetLclOffs(); - target_ssize_t retBufferEnd = retBufferStart + static_cast(retBufferSize); - - unsigned argSize = arg->GetSignatureType() == TYP_STRUCT - ? typGetObjLayout(arg->GetSignatureClassHandle())->GetSize() - : genTypeSize(arg->GetSignatureType()); - target_ssize_t implByrefStart = implicitByRefLclOffs; - target_ssize_t implByrefEnd = implByrefStart + static_cast(argSize); - - bool disjoint = (retBufferEnd <= implByrefStart) || (implByrefEnd <= retBufferStart); - omitCopy = disjoint; - } - } - if (omitCopy) { if (implicitByRefLcl != nullptr) @@ -3242,7 +3218,6 @@ void Compiler::fgMakeOutgoingStructArgCopy(GenTreeCall* call, CallArg* arg) #endif JITDUMP("making an outgoing copy for struct arg\n"); - assert(!call->IsTailCall() || !arg->AbiInfo.PassedByRef); CORINFO_CLASS_HANDLE copyBlkClass = arg->GetSignatureClassHandle(); unsigned tmp = 0;