Skip to content
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

Merge these copy statements that simplified the canonical enum clone method by GVN #129931

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

DianQK
Copy link
Member

@DianQK DianQK commented Sep 3, 2024

This is blocked by #128299.

@rustbot
Copy link
Collaborator

rustbot commented Sep 3, 2024

r? @nnethercote

rustbot has assigned @nnethercote.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Sep 3, 2024
@DianQK
Copy link
Member Author

DianQK commented Sep 3, 2024

r? ghost

@rustbot
Copy link
Collaborator

rustbot commented Sep 3, 2024

Failed to set assignee to ghost: invalid assignee

Note: Only org members with at least the repository "read" role, users with write permissions, or people who have commented on the PR may be assigned.

@DianQK
Copy link
Member Author

DianQK commented Sep 3, 2024

r? cjgillot

@rustbot rustbot assigned cjgillot and unassigned nnethercote Sep 3, 2024
@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Contributor

bors commented Sep 14, 2024

☔ The latest upstream changes (presumably #128299) made this pull request unmergeable. Please resolve the merge conflicts.

@DianQK
Copy link
Member Author

DianQK commented Sep 14, 2024

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Sep 14, 2024
@bors
Copy link
Contributor

bors commented Sep 14, 2024

⌛ Trying commit 622247a with merge c324112...

bors added a commit to rust-lang-ci/rust that referenced this pull request Sep 14, 2024
Merge these copy statements that simplified the canonical enum clone method by GVN

This is blocked by rust-lang#128299.
@bors
Copy link
Contributor

bors commented Sep 14, 2024

☀️ Try build successful - checks-actions
Build commit: c324112 (c3241126e94d7a53a1805ad854686e0bd061b5df)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (c324112): comparison URL.

Overall result: no relevant changes - no action needed

Benchmarking 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
@rustbot label: -S-waiting-on-perf -perf-regression

Instruction count

This 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.

mean range count
Regressions ❌
(primary)
4.0% [3.0%, 5.1%] 3
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-3.8% [-5.9%, -1.7%] 2
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.9% [-5.9%, 5.1%] 5

Cycles

This benchmark run did not return any relevant results for this metric.

Binary size

Results (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.

mean range count
Regressions ❌
(primary)
0.1% [0.0%, 0.2%] 11
Regressions ❌
(secondary)
0.0% [0.0%, 0.1%] 2
Improvements ✅
(primary)
-0.1% [-0.3%, -0.0%] 6
Improvements ✅
(secondary)
-0.0% [-0.0%, -0.0%] 3
All ❌✅ (primary) 0.0% [-0.3%, 0.2%] 17

Bootstrap: 760.71s -> 756.595s (-0.54%)
Artifact size: 341.13 MiB -> 341.17 MiB (0.01%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Sep 15, 2024
Copy link
Contributor

@cjgillot cjgillot left a 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 impls Clone 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,
Copy link
Contributor

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?

if simplify_to_copy(tcx, body, bb_idx, param_env).is_some() {
should_cleanup = true;
continue;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be made a standalone MirPass? This will be easier to have some analyses computed only once.

if stmts.is_empty() {
return None;
}
if let [Statement { kind: StatementKind::Assign(box (place, rvalue)), .. }] =
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you add a comment for the high-level pattern you are trying to match?

}
}
}
let expected_copy_stmt = expected_copy_stmt?;
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we perform the same analysis on this statement that we do in the single statement branch above?

@DianQK
Copy link
Member Author

DianQK commented Sep 18, 2024

* for clone impls, use some kind of `StructuralClone` trait so that we fully replace the derived impls `Clone` with simpler MIR;

* for general MIR, lift the restrictions on this pass (bb0 and assignment to _0 namely).

What do you think?

It looks like makes sense.
IIUC, the StructuralClone is exact matching clone shims? I expect this can improve compile-time.

@rustbot author

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants