Repository navigation
JIT: expand all stack array allocations in a statement - #133531
Merged
Merged
Conversation
fgExpandStackArrayAllocations stopped after the first expansion in a statement, but splitting only moves the preceding part of the tree out, so any remaining NEWARR helper calls stayed behind with a StackArrayLocal arg. Fixes dotnet#133523 Co-authored-by: Copilot <[email protected]> Copilot-Session: 3b9596b9-f3b3-47d1-b1ca-1a8781e56de7
|
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.
🟢 Approval recommended
The fix is localized, maintains statement side-effect flag correctness via gtUpdateStmtSideEffects, and is backed by a targeted regression test covering the reported scenario.
Pull request overview
This PR fixes a CoreCLR JIT correctness bug where stack-array allocation expansion would only expand the first eligible NEWARR helper call within a statement, potentially leaving later stack-array allocations in the same statement unexpanded and malformed.
Changes:
- Update
Compiler::fgExpandStackArrayAllocationsto rescan a statement after each successful expansion until no more stack-array allocations remain. - Add a JIT regression test covering multiple stack-allocated arrays in one statement (including a 3-array variant).
- Register the new regression test source file in
Regression_ro_2.csproj.
File summaries
| File | Description |
|---|---|
| src/coreclr/jit/helperexpansion.cpp | Rescans a statement until all stack-array allocation helper calls in that statement are expanded. |
| src/tests/JIT/Regression/Regression_ro_2.csproj | Includes the new Runtime_133523 regression test in the build. |
| src/tests/JIT/Regression/JitBlue/Runtime_133523/Runtime_133523.cs | Adds an xUnit regression test reproducing multiple stack-array allocations within one statement. |
Review details
- Files reviewed: 3/3 changed files
- Comments generated: 0
- Review effort level: Lite
AndyAyersMS
approved these changes
Sep 9, 2026
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.
Fixes #133523
fgExpandStackArrayAllocationsstopped after expanding the first allocation in a statement.gtSplitTreeonly moves the part of the tree evaluated before the split point into new statements, so any furtherNEWARRhelper calls stayed in the statement and were never expanded - leaving a helper call with a bogusStackArrayLocalarg (asserts in lowering, AVs in release).No SPMI asm diffs.