Repository navigation
JIT: Handle multi-reg async calls stored to promoted locals - #121749
Merged
Merged
Conversation
In some cases the async transformation needs to introduce a new local to
store the result of an async call to. If the previous store was a
multi-reg call stored to an independently promoted local then we would
produce illegal IR. For example, the IR
```
t79 = ▌ CALL struct <unknown method> (async) $702
┌──▌ t79 struct
▌ STORE_LCL_VAR struct<System.ValueTuple`3, 16>(P) V25 tmp9
▌ ref field V25.Item3 (fldOffset=0x0) -> V275 tmp259 d:2
▌ int field V25.Item2 (fldOffset=0x8) -> V276 tmp260 d:1
▌ ubyte field V25.Item1 (fldOffset=0xc) -> V277 tmp261 d:1 $VN.Void
```
would be canonicalized into
```
t79 = ▌ CALL struct <unknown method> (async) $702
┌──▌ t79 struct
▌ STORE_LCL_VAR struct<System.ValueTuple`3, 16> V337 rat6
t5027 = LCL_VAR struct<System.ValueTuple`3, 16> V337 rat6
┌──▌ t5027 struct
▌ STORE_LCL_VAR struct<System.ValueTuple`3, 16>(P) V25 tmp9
▌ ref field V25.Item3 (fldOffset=0x0) -> V275 tmp259 d:2
▌ int field V25.Item2 (fldOffset=0x8) -> V276 tmp260 d:1
▌ ubyte field V25.Item1 (fldOffset=0xc) -> V277 tmp261 d:1 $VN.Void
```
but that store to the promoted local with a LCL_VAR source is not legal.
Fix the problem by decomposing the store when necessary.
Contributor
|
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR fixes an issue in the JIT's async transformation where multi-register async calls stored to independently promoted locals would produce illegal IR. The problem occurred when ReplaceWithLclVar created an intermediate store, resulting in a LCL_VAR source for a promoted local store, which is not supported.
Key Changes
- Added detection for multi-reg calls stored to independently promoted locals
- Implemented decomposition logic that creates field stores using
LCL_FLDnodes to access individual fields from the intermediate temporary - Removed the illegal promoted local store while keeping the intermediate store
Member
Author
|
cc @dotnet/jit-contrib PTAL @EgorBo |
EgorBo
approved these changes
Nov 20, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
In some cases the async transformation needs to introduce a new local to store the result of an async call to. If the previous store was a multi-reg call stored to an independently promoted local then we would produce illegal IR. For example, the IR
would be canonicalized into
but that store to the promoted local with a LCL_VAR source is not legal.
Fix the problem by decomposing the store when necessary.
Fixes #119432 (comment)