-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Do not deaggregate MIR #107267
Do not deaggregate MIR #107267
Conversation
Some changes occurred to the CTFE / Miri engine cc @rust-lang/miri Some changes occurred to MIR optimizations cc @rust-lang/wg-mir-opt This PR changes MIR cc @oli-obk, @RalfJung, @JakobDegen, @davidtwco, @celinval, @vakaras |
6278cd7
to
bf1045f
Compare
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
⌛ Trying commit bf1045f6445947bde254afb44e4f51e59d5ee3cd with merge 1c5362be2bfa0958bd3e3d628499105ba64bcef2... |
☀️ Try build successful - checks-actions |
This comment has been minimized.
This comment has been minimized.
Finished benchmarking commit (1c5362be2bfa0958bd3e3d628499105ba64bcef2): comparison URL. Overall result: ❌✅ regressions and improvements - ACTION NEEDEDBenchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR may lead to changes in compiler perf. Next Steps: If you can justify the regressions found in this try perf run, please indicate this with @bors rollup=never Instruction countThis is a highly reliable metric that was used to determine the overall result at the top of this comment.
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.
CyclesResultsThis 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.
|
This comment has been minimized.
This comment has been minimized.
I reopened #35259 because there are conflicting desires
The discussion that caused this PR: https://rust-lang.zulipchat.com/#narrow/stream/136281-t-lang.2Fwg-unsafe-code-guidelines/topic/Changing.20enum.20variant.20by.20writing.20to.20field |
One thing we can do is keep deaggregating structs, but not enums. Then there won't be two ways of doing the same thing, as long as we don't allow |
Replace ZST operands and debuginfo by constants. This is work that ConstProp will not have to do. Split from rust-lang#107267
Replace ZST operands and debuginfo by constants. This is work that ConstProp will not have to do. Split from rust-lang#107267
bf1045f
to
6994ef2
Compare
So... basically the reason deaggregation was enabled for everything but arrays was to work towards named return value optimization. Instead of building all the components and then doing a single aggregate assignment at the end, you can assign to sub-places immediately and even end up with multiple layers of function calls that assign to a place in the outermost call. I guess we can still do that as part of nrvo when it decides a return value should get that opt run on it. |
This comment has been minimized.
This comment has been minimized.
Honestly, this is a problem we should fix via SSA (or something similar, not via deaggregation) |
Makes sense. So I guess the only thing left is to give codegen backends the ability to deaggregate so they don't have to implement both aggregate rvalues, field assignments and setdiscriminant unless they want to |
6994ef2
to
17fc912
Compare
This comment has been minimized.
This comment has been minimized.
Finished benchmarking commit (9dee4e4): comparison URL. Overall result: ❌✅ regressions and improvements - ACTION NEEDEDNext Steps: If you can justify the regressions found in this perf run, please indicate this with @rustbot label: +perf-regression Instruction countThis is a highly reliable metric that was used to determine the overall result at the top of this comment.
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.
CyclesResultsThis 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.
|
The wins here outweigh the losses, even if you ignore the handful of very good results among secondary benchmarks that skew the overall results. @rustbot label: +perf-regression-triaged |
Adapt SROA MIR opt for aggregated MIR The pass was broken by rust-lang#107267. This PR extends it to replace: ``` x = Struct { 0: a, 1: b } y = move? x ``` by assignment between locals ``` x_0 = a x_1 = b y_0 = move? x_0 y_1 = move? x_1 ``` The improved pass runs to fixpoint, so we can flatten nested field accesses.
} else { | ||
(dest, active_field_index) | ||
} | ||
let (variant_index, variant_dest, active_field_index) = match **kind { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cg_clif needs to be updated too. Will do this over at the cg_clif repo.
Edit: done in bjorn3/rustc_codegen_cranelift@8494882
This caused a regression: #107678 Should this be reverted? (Or perhaps you can help find the bug) |
Replace ZST operands and debuginfo by constants. This is work that ConstProp will not have to do. Split from rust-lang#107267
Replace ZST operands and debuginfo by constants. This is work that ConstProp will not have to do. Split from rust-lang/rust#107267
Replace ZST operands and debuginfo by constants. This is work that ConstProp will not have to do. Split from rust-lang/rust#107267
This turns out to simplify a lot of things.
I haven't checked the consequences for miri yet.
cc @JakobDegen
r? @oli-obk