Repository navigation
Clarify CoreCLR IL constant emission - #137988
Merged
Merged
Conversation
Replace EmitLDC with EmitLDC_I4 and EmitLDC_I to make stack types explicit. Co-authored-by: Copilot <[email protected]> Copilot-Session: 16f37459-2fa9-4520-85bb-15e9be5208cc
|
Azure Pipelines: Successfully started running 5 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: @agocke |
jakobbotsch
commented
Nov 20, 2026
Member
Author
|
/azp run runtime-coreclr outerloop |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
jkotas
approved these changes
Nov 20, 2026
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain for the changes making integer constant stack types explicit in IL stub generation.
No open issues 🎉
What changed in this PR
This PR makes integer constant stack types explicit in CoreCLR’s IL stub generator, addressing the ambiguity behind pointer-constant bugs such as #137931.
Changes:
- Splits
EmitLDCintoEmitLDC_I4andEmitLDC_I, with native-int conversion handled by the latter. - Removes implicit
ldc.i8-to-ldc.i4lowering and migrates callers to the appropriate typed helper. - Removes
EmitLoadNullPtrand updates the JIT comment describing tolerated function-pointer types.
| File | Description |
|---|---|
| src/coreclr/vm/tailcallhelp.cpp | Uses explicit integer and pointer constants in tail-call stubs. |
| src/coreclr/vm/stubgen.h | Declares typed constant helpers and removes the null-pointer helper. |
| src/coreclr/vm/stubgen.cpp | Implements typed emission and limits constant shortening to ldc.i4. |
| src/coreclr/vm/prestub.cpp | Uses native-int constants for target addresses and generic contexts. |
| src/coreclr/vm/jitinterface.cpp | Uses native-int constants in async resumption stubs. |
| src/coreclr/vm/ilmarshalers.h | Migrates inline marshaler code to typed helpers. |
| src/coreclr/vm/ilmarshalers.cpp | Distinguishes integer constants from native null pointers in marshalers. |
| src/coreclr/vm/dllimport.cpp | Migrates interop stubs to explicit constant types. |
| src/coreclr/vm/comdelegate.cpp | Separates delegate-loop integers from debugger-state addresses. |
| src/coreclr/vm/array.cpp | Uses explicit int32 constants for array offsets, flags, and sizes. |
| src/coreclr/jit/importercalls.cpp | Updates only the comment explaining int32 function-pointer tolerance. |
Review effort: Balanced
Open
3 tasks
This was referenced Nov 20, 2026
jakobbotsch
marked this pull request as ready for review
November 23, 2026 12:54
Member
Author
|
/ba-g Unknown failure is the one fixed by #138094 |
1 similar comment
Member
Author
|
/ba-g Unknown failure is the one fixed by #138094 |
This was referenced Nov 23, 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.
#137931 is not the first time we've had a bug around
EmitLDCand confusion about what type ends up on the stack. This PR:EmitLDCintoEmitLDC_I4andEmitLDC_Ildc_i8intoldc_i4when it fits, which is the source of these bugsEmitLDC_I4orEmitLDC_Iexplicitly depending on what type they want.No caller needs an
int64loaded constant so I didn't add anEmitLDC_I8.