JIT: Strip GC/reloc flags from the size in arm64 instGen_Set_Reg_To_Imm - #132269
Open
jakobbotsch wants to merge 1 commit into
Open
JIT: Strip GC/reloc flags from the size in arm64 instGen_Set_Reg_To_Imm#132269jakobbotsch wants to merge 1 commit into
jakobbotsch wants to merge 1 commit into
Conversation
The immediate encoding helpers (emitIns_valid_imm_for_mov, canEncodeHalfwordImm,
canEncodeBitMaskImm) take a plain 4/8 byte data size and assert on anything else.
Every other caller strips the flags first, but instGen_Set_Reg_To_Imm only did so
when relocations were disabled, so with relocations enabled a non-null byref
constant reached them as EA_BYREF and tripped
Assertion failed 'isValidGeneralDatasize(size)' in emitarm64.cpp:3025
The movz/movk fallback had the same problem: its 'size == EA_8BYTE' tests would
compute a 32 bit width for EA_BYREF and drop the upper halfwords.
Only reproduces when compiling ahead of time (crossgen2/NativeAOT), where
compReloc is set.
Fixes dotnet#132268
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 17ed5289-947f-4243-a31e-6468f680a54c
|
Azure Pipelines: Successfully started running 6 pipeline(s). 10 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.
Pull request overview
Fixes an arm64 JIT correctness bug where instGen_Set_Reg_To_Imm could pass an emitAttr with GC/reloc flags (e.g., EA_BYREF) into immediate-encoding helpers that require a plain 4/8-byte size, causing assertions (and incorrect movz/movk width decisions) when relocations are enabled (AOT scenarios).
Changes:
- In
CodeGen::instGen_Set_Reg_To_Imm, computeimmSize = EA_SIZE(size)and use it foremitIns_valid_imm_for_movand the movz/movn/movk fallback width decisions. - Add a new JIT regression test for issue #132268.
- Register the new test in
Regression_ro_2.csproj.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/coreclr/jit/codegenarm64.cpp | Strips flags from the size used by immediate-encoding decisions while preserving full emitAttr for emission/reloc handling. |
| src/tests/JIT/Regression/Regression_ro_2.csproj | Includes the new JitBlue regression test source file in the merged regression project. |
| src/tests/JIT/Regression/JitBlue/Runtime_132268/Runtime_132268.cs | Adds a repro-based xUnit regression test targeting the byref-constant path that triggered the arm64 AOT assertion. |
This was referenced Aug 13, 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 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.
The immediate encoding helpers (emitIns_valid_imm_for_mov, canEncodeHalfwordImm, canEncodeBitMaskImm) take a plain 4/8 byte data size and assert on anything else. Every other caller strips the flags first, but instGen_Set_Reg_To_Imm only did so when relocations were disabled, so with relocations enabled a non-null byref constant reached them as EA_BYREF and tripped
The movz/movk fallback had the same problem: its 'size == EA_8BYTE' tests would compute a 32 bit width for EA_BYREF and drop the upper halfwords.
Only reproduces when compiling ahead of time (crossgen2/NativeAOT), where compReloc is set.
Fixes #132268