-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Change SwitchTarget
representation in StableMIR
#118461
Conversation
r? @ouz-a (rustbot has picked a reviewer for you, use r? to override) |
This PR changes Stable MIR cc @oli-obk, @celinval, @spastorino, @ouz-a |
Thanks! This looks good, have you tested if we are correctly printing |
It looks correct. The following function: pub fn demux(input: u8) -> u8 {
match input {
0 => 10,
1 => 6,
2 => 8,
_ => 0,
}
} prints the following: fn demux(_0: u8) -> u8 {
}
bb0: {
switchInt(_1) -> [0: bb1, 1: bb2, 2: bb3, otherwise: bb4]
}
bb1: {
_0 = const 0_u8
goto -> 5
}
bb2: {
_0 = const 10_u8
goto -> 5
}
bb3: {
_0 = const 6_u8
goto -> 5
}
bb4: {
_0 = const 8_u8
goto -> 5
}
bb5: {
return
} I believe the issues with this output are unrelated to this change, and you are addressing them in #118364, right? |
@bors r+ rollup |
After inspecting the output, I realized the basic blocks order is incorrect. @bors r- |
The new structure encodes its invariant, which reduces the likelihood of having an inconsistent representation. It is also more intuitive and user friendly. I encapsulated the structure for now in case we decide to change it back.
We currently rely on the order of successors to be conditional branches first, followed by the otherwise target.
34cdeae
to
9d2c923
Compare
The same function:
now prints:
|
@bors r+ rollup |
☀️ Test successful - checks-actions |
Finished benchmarking commit (c263ccf): comparison URL. Overall result: no relevant changes - no action needed@rustbot label: -perf-regression Instruction countThis benchmark run did not return any relevant results for this metric. Max RSS (memory usage)ResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesThis benchmark run did not return any relevant results for this metric. Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 673.779s -> 673.487s (-0.04%) |
The new structure encodes its invariant, which reduces the likelihood of having an inconsistent representation. It is also more intuitive and user friendly.
I encapsulated the structure for now in case we decide to change it back.
Notes:
Successors
type, since there's a conflict on the iterator type. We could potentially implement an iterator here, but I would prefer keeping it simple for now, and add asuccessors_iter()
method if needed.CoroutineDrop
for now since it we never create it. We can add it when we add support to other MIR stages.