Repository navigation
JIT: preserve GTF_IND_INITCLASS when inlining BOX of Nullable<T> - #135835
Merged
Merged
Conversation
impImportAndPushBoxForNullable gets the indirection flags of the boxed value from impGetNodeAddr (which also splits off the class-init helper into a separate statement) but never applied them to the decomposed hasValue/value loads. Without GTF_IND_INITCLASS, loop hoisting moved a static Nullable<T> field load ahead of the static constructor check. Pass the flags to both loads. Fixes dotnet#135817 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 6ec7c151-8b7f-4bf9-8b1a-8c601a2965ec
|
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
JIT build validation and confirmation that the regression fails before the fix and passes afterward remain unverified.
0 open findings
What changed in this PR
Fixes nullable boxing in the JIT so static field loads retain their class-initialization dependency and cannot be hoisted before initialization.
Changes:
- Preserves indirection flags on both decomposed nullable loads.
- Adds a regression test for boxing a static nullable field inside a loop.
| File | Description |
|---|---|
| src/tests/JIT/Regression_ro_2/Runtime_135817.cs | Adds the reported regression scenario. |
| src/coreclr/jit/importer.cpp | Passes indirection flags to both nullable loads. |
🧠 Review effort: Balanced
This was referenced Oct 15, 2026
Closed
Member
Author
|
PTAL @dotnet/jit-contrib, trivial change, no diffs |
adamperlin
approved these changes
Oct 15, 2026
adamperlin
left a comment
Contributor
There was a problem hiding this comment.
This looks reasonable to me. Very straightforward fix
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
impImportAndPushBoxForNullable gets the indirection flags of the boxed value from impGetNodeAddr (which also splits off the class-init helper into a separate statement) but never applied them to the decomposed hasValue/value loads. Without GTF_IND_INITCLASS, loop hoisting moved a static Nullable field load ahead of the static constructor check. Pass the flags to both loads.
Fixes #135817
No diffs