-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Consolidate importer spilling code #72291
Consolidate importer spilling code #72291
Conversation
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch Issue DetailsFixes #72133.
|
9771593
to
230661b
Compare
@dotnet/jit-contrib |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My preference would be to split this into two PRs, one that is just the fix and the other that cleans up the CHECK_SPILL_ALL stuff, so that it's more obvious where the fix lies.
The comment states we don't need it, which is incorrect. Diffs are improvements because we block forward substitution of calls into "ASG(BLK(ADDR(LCL_VAR<field>, ...)))", which allows morph to leave the "can be replaced with its field" local alone.
Spill "glob refs" on stores to "aliased" locals.
ee37049
to
a22fb7c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm ok taking this now, but we are getting quite close to the date when we'll want to hold off on this sort of thing until after we branch off .NET 7 from main (mid-August).
This reverts commit c624626.
* Add tests * Fix losing GLOB_REF on the LHS The comment states we don't need it, which is incorrect. Diffs are improvements because we block forward substitution of calls into "ASG(BLK(ADDR(LCL_VAR<field>, ...)))", which allows morph to leave the "can be replaced with its field" local alone. * Prospective fix Spill "glob refs" on stores to "aliased" locals. * Delete now-not-necessary code * Fix up asserts * Clean out '(unsigned)CHECK_SPILL_ALL/NONE' casts * Don't manually spill for 'st[s]fld' * Revert 'Clean out '(unsigned)CHECK_SPILL_ALL/NONE' casts'
* Consolidate importer spilling code (#72291) * Add tests * Fix losing GLOB_REF on the LHS The comment states we don't need it, which is incorrect. Diffs are improvements because we block forward substitution of calls into "ASG(BLK(ADDR(LCL_VAR<field>, ...)))", which allows morph to leave the "can be replaced with its field" local alone. * Prospective fix Spill "glob refs" on stores to "aliased" locals. * Delete now-not-necessary code * Fix up asserts * Clean out '(unsigned)CHECK_SPILL_ALL/NONE' casts * Don't manually spill for 'st[s]fld' * Revert 'Clean out '(unsigned)CHECK_SPILL_ALL/NONE' casts' * Fix assignments done via return buffers The mistake in logic was that the only trees which could modify unaliased locals are assignments, which is not true, calls can do that as well. One day we will move the return buffer handling out of importer, but until then, special handling is required. An alternative fix would have been to bring back the explicit "impSpillLclRefs" to "stloc/starg" code, but that would contradict the overall goal of consolidating the spilling logic.
* Consolidate importer spilling code (dotnet#72291) * Add tests * Fix losing GLOB_REF on the LHS The comment states we don't need it, which is incorrect. Diffs are improvements because we block forward substitution of calls into "ASG(BLK(ADDR(LCL_VAR<field>, ...)))", which allows morph to leave the "can be replaced with its field" local alone. * Prospective fix Spill "glob refs" on stores to "aliased" locals. * Delete now-not-necessary code * Fix up asserts * Clean out '(unsigned)CHECK_SPILL_ALL/NONE' casts * Don't manually spill for 'st[s]fld' * Revert 'Clean out '(unsigned)CHECK_SPILL_ALL/NONE' casts' * Fix assignments done via return buffers The mistake in logic was that the only trees which could modify unaliased locals are assignments, which is not true, calls can do that as well. One day we will move the return buffer handling out of importer, but until then, special handling is required. An alternative fix would have been to bring back the explicit "impSpillLclRefs" to "stloc/starg" code, but that would contradict the overall goal of consolidating the spilling logic.
Fixes #72133.
Diffs are mostly regressions, with some improvements due to the new logic being less conservative in some cases (not spilling
ADDR(LCL_VAR)
s as much).The most common cause of regression is from
initobj
. Essentially, for IL like below:We will now get this IR:
Instead of:
This is, of course, because the new code (correctly) presumes
<some load>
could be aliased by the store.A solution to this could be to enhance the
impILConsumesAddr
logic to account forinitobj
s. This, however, is both risky and non-trivial, as there are dependencies (e. g. the single-def logic) onlvHasLdAddrOp
. Essentially, it would requires treatingldloca; initobj
as equivalent tostloc
very early on.