Conversation
PR SummaryMedium Risk Overview Implements Fuel backend lowering for Adds IR compilation + test coverage by exposing Written by Cursor Bugbot for commit 62f3856. This will update automatically on new commits. Configure here. |
e43b077 to
9988e37
Compare
| sorted_cases | ||
| .iter_mut() | ||
| .for_each(|(val, _)| *val -= min_case_value); | ||
| } |
There was a problem hiding this comment.
In-place SUBI corrupts discriminant register for successor blocks
High Severity
The SUBI writes the adjusted discriminant back into discrim_reg, the same virtual register returned by value_to_register(discriminant). This register is shared by all uses of that IR value. If any successor block references the discriminant directly (not via phi/block arguments), value_to_register returns the same register, and the successor sees the subtracted value instead of the original. A fresh temporary register from self.reg_seqr.next() is needed for the adjusted value.
There was a problem hiding this comment.
Great catch! This is indeed a bug!
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
|
Putting to draft until https://github.com/FuelLabs/sway/pull/7536/changes#r2821795856 is fixed and tested. |


Description
This PR adds a new IR instruction
switch, that supports both exhaustive (for exhaustivematchs, verified by the front-end) and non-exhaustive switches.Since
matchs in the frontend still translate to anif-elseladder, aswitchis never generated yet. So for testing, the PR adds support in the test harness to compile and execute (in the VM)sway-irfiles directly.To be able to snapshot-test the generated ASM output, we will add
compile-irtoforcas well. This will be done in a follow up PR in which we will also add snapshot tests forshould_pass/language/ir_switchtests added in this PRThis is the first step on the backend in implementing #7503.