Repository navigation
JIT: copy large local structs through their address when decomposing - #135486
Merged
Merged
Conversation
PR description draft: <!-- --> When lowering decomposes a GC-containing struct copy into individual stores, it reads a local source through LCL_FLD nodes. Their offsets are limited to 16 bits, so with structs larger than 64 KiB they wrapped. The copy then read the wrong data, dropping fields past 64 KiB (Checked builds asserted). If the local's fields cannot all be encoded as LCL_FLDs (IsValidLclAddr), take the local's address once and load each piece through it. This is the same path already used for indirect sources. Add a single-file regression copying a 65600-byte struct, with a GC ref and a long beyond 64 KiB, to a heap field and to a ref destination. Fixes dotnet#133581 Co-authored-by: Copilot <[email protected]> Copilot-Session: ae8155d6-f240-4542-a1da-c721ba933c91
|
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 focused fix appears consistent, but cross-platform JIT lowering and GC behavior require completed CI and maintainer validation.
0 open findings
What changed in this PR
Fixes JIT corruption when decomposing copies of GC-containing structs larger than 64 KiB.
Changes:
- Loads oversized local structs through their address instead of overflowing
LCL_FLDoffsets. - Adds regression coverage for heap-field and
refdestinations.
| File | Description |
|---|---|
src/coreclr/jit/lower.cpp |
Adds address-based source loading for large struct copies. |
src/tests/JIT/Regression_ro_2/Runtime_133581.cs |
Verifies fields beyond the 64-KiB boundary are copied correctly. |
🧠 Review effort: Balanced
Member
Author
|
PTAL @dotnet/jit-contrib |
JulieLeeMSFT
approved these changes
Oct 9, 2026
JulieLeeMSFT
left a comment
Member
There was a problem hiding this comment.
LGTM: the LCL_ADDR fallback for non-encodable LCL_FLD sources correctly reuses the ReplaceWithLclVar spill pattern from the GT_IND path, leaves no orphaned or dangling nodes in the post-loop cleanup, and clears the stale contained flag.
adamperlin
approved these changes
Oct 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.
When lowering decomposes a GC-containing struct copy into individual stores, it reads a local source through LCL_FLD nodes. Their offsets are limited to 16 bits, so with structs larger than 64 KiB they wrapped. The copy then read the wrong data, dropping fields past 64 KiB (Checked builds asserted).
If the local's fields cannot all be encoded as LCL_FLDs (IsValidLclAddr), take the local's address once and load each piece through it. This is the same path already used for indirect sources.
Fixes #133581
No diffs