Repository navigation
Decouple call store operands from local ret buf optimization - #68469
Conversation
* Move GenTreeCall::GetLclRetBufArgNode -> Compiler::gtCallGetDefinedRetBufLclAddr and change it to not try to look into stores * Assert that the node we are returning actually defines a local that has lvHiddenBufferStructArg set * Assert that call morphing does break our recognition of the defined local when optimizing
|
Tagging subscribers to this area: @JulieLeeMSFT Issue Details
|
SingleAccretion
left a comment
There was a problem hiding this comment.
Thank you for addressing this!
I would say it would probably be prudent to run some stress over this to avoid surprises with struct field addresses being GLOB_REF-ed.
| // This may be called very late to check validity of LIR. | ||
| if (node->IsCopyOrReload()) | ||
| { | ||
| node = node->AsCopyOrReload()->gtGetOp1(); | ||
| } |
There was a problem hiding this comment.
Nit: this is gtSkipReloadOrCopy.
|
|
||
| call->gtArgs.Remove(call->gtArgs.GetRetBufferArg()); | ||
| call->gtCallMoreFlags &= ~GTF_CALL_M_RETBUFFARG; | ||
| call->gtCallMoreFlags &= ~(GTF_CALL_M_RETBUFFARG | GTF_CALL_M_RETBUFFARG_LCLOPT); |
There was a problem hiding this comment.
In general the rule is that if you remove GTF_CALL_M_RETBUFFARG_LCLOPT, you need to address-expose the underlying local (since it makes it invisible to liveness), I suppose here we can elide that because the logical definition occurs outside the method (since it is a tailcall)?
Perhaps worth a comment (or not - maybe it is self-evident).
There was a problem hiding this comment.
Right, things have already gone very wrong if we think we have a tailcall with a retbuf that can be optimized with this optimization.
I will just revert this change, we will hit the assert inside of gtCallGetDefinedRetBufLclAddr if the flag is set and we don't have a retbuf.
| bool GenTree::DefinesLocalAddr(Compiler* comp, unsigned width, GenTreeLclVarCommon** pLclVarTree, bool* pIsEntire) | ||
| { | ||
| if (OperGet() == GT_ADDR || OperGet() == GT_LCL_VAR_ADDR) | ||
| if (OperIs(GT_ADDR, GT_LCL_VAR_ADDR, GT_LCL_FLD_ADDR)) |
There was a problem hiding this comment.
Do you know why DefinesLocalAddr was not recognizing the pattern in the first place? Since it supports communicating "entirety" it seems pretty uncontroversial.
There was a problem hiding this comment.
Do you know why DefinesLocalAddr was not recognizing the pattern in the first place?
Not really I suppose. If I were to guess, it is the result of LCL_FLD being a somewhat late addition, and the original version of the function only recognizing ADDR(LCL_VAR).
I do believe there are no correctness dependencies on it not recognizing LCL_FLD_ADDR.
(Side note: the contract of DefinesLocalAddr is that it must recognize a superset of addresses LocalAddressVisitor recognizes, absence of FLD_ADDR seemingly violates this, but not actually, because it does recognize ADDR(LCL_FLD), and in LIR we rely on use-def flags set by the front-end)
|
|
|
/azp run runtime-coreclr jitstress, runtime-coreclr outerloop |
|
Azure Pipelines successfully started running 2 pipeline(s). |
kunalspathak
left a comment
There was a problem hiding this comment.
Looks good, just a question in sideeffects.cpp.
|
|
||
| //------------------------------------------------------------------------ | ||
| // gtCallGetDefinedRetBufLclAddr: | ||
| // Get the tree corresponding to the address of the retbuf taht this call defines. |
There was a problem hiding this comment.
| // Get the tree corresponding to the address of the retbuf taht this call defines. | |
| // Get the tree corresponding to the address of the retbuf that this call defines. |
There was a problem hiding this comment.
Let me include it as part of #68460 unless there are other changes.
| GenTree* retBufArgNode = compiler->gtCallGetDefinedRetBufLclAddr(node->AsCall()); | ||
| if (retBufArgNode != nullptr) | ||
| { | ||
| // If a copy/reload is inserted by LSRA, retrieve the returnBuffer |
There was a problem hiding this comment.
Why is this no longer needed? I don't recall which test, but I added it much later when trying to debug a test failure.
There was a problem hiding this comment.
I have moved it into gtCallGetDefinedRetBufLclAddr instead, since it also needs to skip it for the assertion there.
There was a problem hiding this comment.
Ah, didn't notice that. Thanks!
|
Some of the helix jobs on outerloop/jitstress windows-arm64 machines timed out. Not sure why as the job lists all seem to have OSX x64 failure is #67816. |
Compiler::gtCallGetDefinedRetBufLclAddr and change it to not try to
look into stores
has lvHiddenBufferStructArg set
local when optimizing
Compiler::DefinesLocalAddrto check forGT_LCL_FLD_ADDR