Skip to content

[mono][interp] Remove invalid addition of conversion opcodes #116130

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 2, 2025

Conversation

BrzVlad
Copy link
Member

@BrzVlad BrzVlad commented May 30, 2025

As part of a conditional branch we were adding an implicit conversion opcode (if needed) after td->last_ins. If the branch is the first opcode in the basic block then this actually adds an instruction in another basic block, which is clearly incorrect. This seems to have been done like this early in the implementation, in order to achieve certain il offset mapping of instructions, but everything around this area has been refactored since, so it shouldn't be necessary anymore.

With tiering disabled, this was crashing b69225 il test.

As part of a conditional branch we were adding an implicit conversion opcode (if needed) after `td->last_ins`. If the branch is the first opcode in the basic block then this actually adds an instruction in another basic block, which is clearly incorrect. This seems to have been done like this early in the implementation, in order to achieve certain il offset mapping of instructions, but everything around this area has been refactored since, so it shouldn't be necessary anymore.

With tiering disabled, this was crashing b69225 il test.
@Copilot Copilot AI review requested due to automatic review settings May 30, 2025 09:19
Copy link
Contributor

Tagging subscribers to this area: @BrzVlad, @kotlarmilos
See info in area-owners.md if you want to be subscribed.

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR removes the special-case insertion of conversion opcodes after a “previous” instruction and instead always appends conversions to the current instruction stream.

  • Removed the prev_ins parameter from interp_add_conv and simplified it to always call interp_add_ins.
  • Updated every call site to match the new interp_add_conv(td, sp, type, conv_op) signature.
  • Ensures conversion ops are no longer accidentally added to a different basic block when a branch is the first instruction.
Comments suppressed due to low confidence (2)

src/mono/mono/mini/interp/transform.c:881

  • [nitpick] This comment reflects the old insertion logic using prev_ins and may now be misleading. Consider updating or removing it to match the refactored behavior where conversions are always appended via interp_add_ins.
// The il instruction starts with the actual branch, and not with the conversion opcodes

src/mono/mono/mini/interp/transform.c:882

  • Add a targeted test case for a conditional branch when it is the first instruction in a basic block to verify that conversion opcodes are now appended correctly and not placed in a previous block.
interp_add_conv (td, td->sp - 1, STACK_TYPE_I8, MINT_CONV_I8_I4);

@BrzVlad BrzVlad merged commit a745f28 into dotnet:main Jun 2, 2025
71 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Jul 2, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants