Repository navigation
JIT: Fix MD array store evaluation order - #133740
Merged
Merged
Conversation
Multidimensional array stores performed null and bounds checks before side-effecting RHS values. Spill the RHS first to preserve evaluation order. Fixes #133717. Co-authored-by: Copilot <[email protected]>
|
Azure Pipelines: Successfully started running 5 pipeline(s). 11 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
|
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
Contributor
There was a problem hiding this comment.
🔵 Needs a closer look
The spill guard does not handle GTF_ORDER_SIDEEFF, allowing some RHS values to remain embedded in the store.
Pull request overview
Fixes JIT evaluation order for multidimensional array stores by spilling side-effecting RHS values before array checks.
Changes:
- Updates MD-array store expansion.
- Adds 2D/3D evaluation-order regression tests.
File summaries
| File | Summary |
|---|---|
src/tests/JIT/opt/MDArray/MDArrayIntrinsicExpansion.cs |
Adds regression coverage for MD-array store evaluation order. |
src/coreclr/jit/importercalls.cpp |
Spills side-effecting RHS values before MD-array checks. |
Review details
Suppressed comments (1)
src/coreclr/jit/importercalls.cpp:13564
- This guard only recognizes GTF_SIDE_EFFECT, but GT_CATCH_ARG carries only GTF_ORDER_SIDEEFF (src/coreclr/jit/importer.cpp:1994-1999). A valid low-level handler can pass the catch argument directly to Set; because the value is popped without calling impSpillSpecialSideEff, it can remain embedded in the store instead of being the first evaluated statement, violating the invariant checked in fgdiagnostic.cpp:3738-3746. Include GTF_ORDER_SIDEEFF in the guard (or call impSpillSpecialSideEff unconditionally) before popping the value.
if ((impStackTop().val->gtFlags & GTF_SIDE_EFFECT) != 0)
- Files reviewed: 2/2 changed files
- Comments generated: 0
- Review effort level: Lite
Member
Author
|
@jakobbotsch PTAL |
jakobbotsch
approved these changes
Sep 14, 2026
Member
Author
|
/ba-g known mono test failures |
jtschuster
pushed a commit
to jtschuster/runtime
that referenced
this pull request
Sep 18, 2026
Multidimensional array stores performed null and bounds checks before side-effecting RHS values. Spill the RHS first to preserve evaluation order. Fixes dotnet#133717. > [!NOTE] > This pull request description was created by GitHub Copilot. Co-authored-by: Copilot <[email protected]>
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.
Multidimensional array stores performed null and bounds checks before
side-effecting RHS values. Spill the RHS first to preserve evaluation
order.
Fixes #133717.
Note
This pull request description was created by GitHub Copilot.