Repository navigation
JIT: preserve importer stack for negative constant Log2 - #133725
Merged
Merged
Conversation
|
Azure Pipelines: 16 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: @dotnet/runtime-infrastructure |
Co-authored-by: EgorBo <[email protected]>
Copilot
AI
changed the title
[WIP] Fix int.Log2/long.Log2 with negative constant causing InvalidProgramException
JIT: preserve importer stack for negative constant Log2
Sep 11, 2026
EgorBo
marked this pull request as ready for review
September 11, 2026 18:30
EgorBo
approved these changes
Sep 11, 2026
Member
|
PTAL @AndyAyersMS @dotnet/jit-contrib |
|
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. |
AndyAyersMS
approved these changes
Sep 11, 2026
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Native-sized constants are still incorrectly truncated on 64-bit targets.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Fixes JIT importer stack corruption for negative constant Log2 calls and adds regression coverage.
Changes:
- Preserves arguments when intrinsic folding is declined.
- Adds tests for signed, unsigned, native-sized, and stacked operands.
File summaries
| File | Summary |
|---|---|
src/coreclr/jit/importercalls.cpp |
Updates constant Log2 stack handling. |
src/tests/JIT/Regression_ro_2/Runtime_133711.cs |
Adds regression tests for issue #133711. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 1
- Review effort level: Lite
EgorBo
enabled auto-merge (squash)
September 11, 2026 18:52
tannergooding
approved these changes
Sep 11, 2026
Member
|
/ba-g unrelated mono failures |
jtschuster
pushed a commit
to jtschuster/runtime
that referenced
this pull request
Sep 18, 2026
<!-- --> Calls such as `int.Log2(-1)` and `long.Log2(-1L)` pop their argument before declining intrinsic expansion, corrupting the importer stack and producing `InvalidProgramException` instead of `ArgumentOutOfRangeException`. - **Importer:** Pop the constant argument only when folding succeeds, preserving it for normal-call fallback otherwise. - **Regression coverage:** Exercise negative `int`, `long`, and `nint` constants with and without another value underneath on the stack, plus valid signed and unsigned boundary constants. <!-- START COPILOT CODING AGENT SUFFIX --> - Fixes dotnet#133711 --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: EgorBo <[email protected]>
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.
Calls such as
int.Log2(-1)andlong.Log2(-1L)pop their argument before declining intrinsic expansion, corrupting the importer stack and producingInvalidProgramExceptioninstead ofArgumentOutOfRangeException.int,long, andnintconstants with and without another value underneath on the stack, plus valid signed and unsigned boundary constants.