Fix contained LCL_VAR_ADDR in RMW. #50669
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Call
emitIns_S_I(stack immediate) to generate instruction like:Questions that I had:
emitHandleMemOp?no, because
emitHandleMemOpalready has an instruction descriptor and it is wrong for this situation because it expectsAmeaningdereference Address in a register. We could change the fmt inside like we do for:runtime/src/coreclr/jit/emitxarch.cpp
Lines 2931 to 2932 in 5265305
but it would require a copy-paste of
emitIns_S_Iinto this function.Another argument is that we already treat
LCL_VAR_ADDR/LCL_FLD_ADDRdifferently, to show such cases I have changedOperIs(GT_LCL_VAR_ADDR, GT_LCL_FLD_ADDR)toOperIsLocalAddr().A better long-term solution would be to rewrite
emitHandleMemOpto createidbut we don't have time for it now.Do we need to call
genUpdateLifefor the local?It appears not to be necessary because the variable liveness does not change there so we can skip it.
However, we can do this, as you see
000000is markedVAR_USEASGso call togenUpdateLife(storeInd)will give us the correct result,UpdateLifeVarjust won't do anything with it. I could still add these calls if I hear an opinion that it will be less confusing.Have I caught all places that need this fix?
I checked all calls to
emitHandleMemOpand found 1 more place that was fixed in this PR, others already have it or don't work with contained LCL_VAR_ADDR.Fixes #41073 and #49880.
No spmi-diffs.