-
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
mir-opt: Merge all branch BBs into a single copy statement #129931
base: master
Are you sure you want to change the base?
Conversation
r? @nnethercote rustbot has assigned @nnethercote. Use |
r? ghost |
Failed to set assignee to
|
r? cjgillot |
This comment has been minimized.
This comment has been minimized.
efce2e8
to
adb6166
Compare
☔ The latest upstream changes (presumably #128299) made this pull request unmergeable. Please resolve the merge conflicts. |
adb6166
to
622247a
Compare
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
Merge these copy statements that simplified the canonical enum clone method by GVN This is blocked by rust-lang#128299.
☀️ Try build successful - checks-actions |
This comment has been minimized.
This comment has been minimized.
Finished benchmarking commit (c324112): comparison URL. Overall result: no relevant changes - no 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. @bors rollup=never Instruction countThis benchmark run did not return any relevant results for this metric. Max RSS (memory usage)Results (primary 0.9%)This 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 sizeResults (primary 0.0%, secondary -0.0%)This 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.
Bootstrap: 760.71s -> 756.595s (-0.54%) |
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.
My high-level reaction to this PR is that it's both too specific in what it's trying to match (a clone impl) and too general in its implementation (handles storage statements...).
I suggest having two heuristics:
- for clone impls, use some kind of
StructuralClone
trait so that we fully replace the derived implsClone
with simpler MIR; - for general MIR, lift the restrictions on this pass (bb0 and assignment to _0 namely).
What do you think?
@@ -604,6 +602,7 @@ fn run_optimization_passes<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) { | |||
&dead_store_elimination::DeadStoreElimination::Initial, | |||
&gvn::GVN, | |||
&simplify::SimplifyLocals::AfterGVN, | |||
&match_branches::MatchBranchSimplification, |
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.
Should this run on clone shims too? Or do we want a trait-based solution to detect trivial clone impls?
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.
Should this run on clone shims too?
Could you explain more?
Or do we want a trait-based solution to detect trivial clone impls?
It makes sense to me for clone impls.
It looks like makes sense. @rustbot author |
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.
I didn't submit all the comments through "Submit review"; there are still some pending comments. o
I am currently modifying the code to move it into a separate pass.
@@ -604,6 +602,7 @@ fn run_optimization_passes<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) { | |||
&dead_store_elimination::DeadStoreElimination::Initial, | |||
&gvn::GVN, | |||
&simplify::SimplifyLocals::AfterGVN, | |||
&match_branches::MatchBranchSimplification, |
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.
Should this run on clone shims too?
Could you explain more?
Or do we want a trait-based solution to detect trivial clone impls?
It makes sense to me for clone impls.
☀️ Try build successful - checks-actions |
This comment has been minimized.
This comment has been minimized.
Finished benchmarking commit (9637884): comparison URL. Overall result: ❌✅ regressions and improvements - no 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. @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)Results (primary 3.2%, secondary 2.5%)This 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.
CyclesResults (primary 1.9%)This 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.
Binary sizeResults (primary -0.0%, secondary -0.0%)This 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.
Bootstrap: 775.25s -> 775.189s (-0.01%) |
@rustbot review |
Some(dest_place) | ||
} | ||
|
||
fn find_copy_assign<'tcx>( |
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.
Could you doc-comment this? I'm still not sure what pattern you are looking for.
// There is only one statement that cannot be ignored | ||
// that can be used as an expected copy statement. | ||
expected_assign_stmt = Some(statement_index); | ||
lived_stmts.remove(statement_index); |
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.
I know we already discussed this, but I'd rather have DSE
run multiple times in the pipeline, than having re-coded here. This complicates the code a lot, where we could get rid of the statements once.
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.
Since debuginfo handles it differently, I'll try to modify the DSE then get rid of these.
@@ -609,6 +610,7 @@ fn run_optimization_passes<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) { | |||
&dead_store_elimination::DeadStoreElimination::Initial, | |||
&gvn::GVN, | |||
&simplify::SimplifyLocals::AfterGVN, | |||
&merge_branches::MergeBranchSimplification, |
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.
Why here in the pipeline?
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.
This needs to run after GVN. I expect SimplifyLocals::AfterGVN
can simplify the analysis in MergeBranchSimplification
. Additionally, after MergeBranchSimplification
simplifies the CFG, it will benefit subsequent passes that are related to the CFG.
I will probably update in two days. @rustbot author |
Just a few trivial modifications and rebase. |
I have tried to update the document and DSE. @rustbot review |
☔ The latest upstream changes (presumably #132349) made this pull request unmergeable. Please resolve the merge conflicts. |
#128299 simplified
to
The switch branch can be simplified into a single copy statement. This PR implements a relatively general simplification.