Skip to content

Conversation

@tmiasko
Copy link
Contributor

@tmiasko tmiasko commented Oct 17, 2025

Previously copy propagation presumed that there is further unspecified distinction between move operands and copy operands in assignments and propagated moves from assignments into terminators. This is inconsistent with current operational semantics.

Turn moves into copies after copy propagation to preserve existing behavior.

Fixes #137936.
Fixes #146423.

r? @cjgillot

@rustbot
Copy link
Collaborator

rustbot commented Oct 17, 2025

Some changes occurred to MIR optimizations

cc @rust-lang/wg-mir-opt

@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 Oct 17, 2025
@tmiasko tmiasko changed the title Turns moves into copies after copy propagation Turn moves into copies after copy propagation Oct 17, 2025
@rust-log-analyzer

This comment has been minimized.

@tmiasko
Copy link
Contributor Author

tmiasko commented Oct 17, 2025

@bors2 try @rust-timer queue

@rust-timer

This comment has been minimized.

rust-bors bot added a commit that referenced this pull request Oct 17, 2025
Turn moves into copies after copy propagation
@rust-bors

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Oct 17, 2025
@rust-bors
Copy link

rust-bors bot commented Oct 17, 2025

💥 Test timed out after 21600s

@tmiasko
Copy link
Contributor Author

tmiasko commented Oct 17, 2025

@bors try

rust-bors bot added a commit that referenced this pull request Oct 17, 2025
Turn moves into copies after copy propagation
@rust-bors

This comment has been minimized.

@rust-bors
Copy link

rust-bors bot commented Oct 17, 2025

☀️ Try build successful (CI)
Build commit: 09003ac (09003acc28104d3fbe9b443536d97a793f68ffde, parent: f46475914de626785090a05ae037578aaa119fc8)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (09003ac): comparison URL.

Overall result: ❌ regressions - please read the text below

Benchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf.

Next Steps: If you can justify the regressions found in this try perf run, please do so in sufficient writing along with @rustbot label: +perf-regression-triaged. If not, please fix the regressions and do another perf run. If its results are neutral or positive, the label will be automatically removed.

@bors rollup=never
@rustbot label: -S-waiting-on-perf +perf-regression

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
1.2% [0.2%, 3.6%] 39
Regressions ❌
(secondary)
1.8% [0.3%, 10.1%] 21
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-0.1% [-0.1%, -0.1%] 1
All ❌✅ (primary) 1.2% [0.2%, 3.6%] 39

Max RSS (memory usage)

Results (primary 1.5%, secondary 4.1%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
1.5% [1.5%, 1.5%] 1
Regressions ❌
(secondary)
4.1% [4.1%, 4.1%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 1.5% [1.5%, 1.5%] 1

Cycles

Results (primary -0.5%, secondary 5.5%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
1.6% [1.6%, 1.6%] 1
Regressions ❌
(secondary)
5.5% [3.5%, 8.9%] 4
Improvements ✅
(primary)
-2.6% [-2.6%, -2.6%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -0.5% [-2.6%, 1.6%] 2

Binary size

Results (primary 0.7%, secondary 0.2%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
0.7% [0.0%, 3.3%] 63
Regressions ❌
(secondary)
0.2% [0.0%, 0.8%] 30
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.7% [0.0%, 3.3%] 63

Bootstrap: 475.372s -> 475.243s (-0.03%)
Artifact size: 390.39 MiB -> 390.39 MiB (0.00%)

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Oct 17, 2025
@tmiasko tmiasko marked this pull request as draft October 18, 2025 12:24
@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 Oct 18, 2025
@tmiasko tmiasko force-pushed the move-copy branch 2 times, most recently from 4ae2c39 to 391b45e Compare October 18, 2025 13:15
@tmiasko
Copy link
Contributor Author

tmiasko commented Oct 18, 2025

@bors try @rust-timer queue

@bors
Copy link
Collaborator

bors commented Oct 30, 2025

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Oct 30, 2025
@oli-obk oli-obk 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 Oct 31, 2025
@bors
Copy link
Collaborator

bors commented Nov 3, 2025

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

@Zalathar
Copy link
Member

Bors, this PR has merge conflicts.

@bors r- retry

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Nov 12, 2025
Previously copy propagation presumed that there is further unspecified
distinction between move operands and copy operands in assignments and
propagated moves from assignments into terminators. This is inconsistent
with current operational semantics.

Turn moves into copies after copy propagation to preserve existing behavior.

Fixes rust-lang#137936.
Fixes rust-lang#146423.
@rustbot
Copy link
Collaborator

rustbot commented Nov 20, 2025

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

//@ add-minicore
//@ revisions:m68k x86_64-linux x86_64-windows i686-linux i686-windows

//@ compile-flags: -Copt-level=1 -Cno-prepopulate-passes
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This test now relies on CopyProp + DeadStoreElimination, while it previously relied only on CopyProp.

Custom MIR would be a better alternative, if not for the fact that it is not available in minicore tests :-(.

Copy link
Member

Choose a reason for hiding this comment

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

Why is this opt-level=1 instead of enabling the specific MIR transforms?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What would be a benefit of doing that? Test assumes that code generation is performed on fully optimized MIR. It doesn't matter which transforms are involved.

Copy link
Member

Choose a reason for hiding this comment

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

Ah I see. I'm just wary of the assumption that opt-level 1 is fully optimized MIR. Currently it does map to -Zmir-opt-level=2 but I have a nagging feeling that enabling the same (with the exception of Inline) MIR opts at -Copt-level=3 and -Copt-level=1 can't be optimal.

But this isn't a serious reason to hold up this PR even more, it's an important fix so I'm delta-approving it.

@tmiasko tmiasko added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Nov 20, 2025
@saethlin
Copy link
Member

@bors r=cjgillot,saethlin

@bors
Copy link
Collaborator

bors commented Nov 23, 2025

📌 Commit 6bd1a03 has been approved by cjgillot,saethlin

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 23, 2025
@bors
Copy link
Collaborator

bors commented Nov 23, 2025

⌛ Testing commit 6bd1a03 with merge 122cbd0...

@bors
Copy link
Collaborator

bors commented Nov 23, 2025

☀️ Test successful - checks-actions
Approved by: cjgillot,saethlin
Pushing 122cbd0 to main...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Nov 23, 2025
@bors bors merged commit 122cbd0 into rust-lang:main Nov 23, 2025
12 checks passed
@rustbot rustbot added this to the 1.93.0 milestone Nov 23, 2025
@github-actions
Copy link
Contributor

What is this? This is an experimental post-merge analysis report that shows differences in test outcomes between the merged PR and its parent PR.

Comparing 23f7081 (parent) -> 122cbd0 (this PR)

Test differences

Show 2 test diffs

2 doctest diffs were found. These are ignored, as they are noisy.

Test dashboard

Run

cargo run --manifest-path src/ci/citool/Cargo.toml -- \
    test-dashboard 122cbd043833a1d7540cc5f99c458bfca2d3c525 --output-dir test-dashboard

And then open test-dashboard/index.html in your browser to see an overview of all executed tests.

Job duration changes

  1. dist-x86_64-apple: 6692.5s -> 8070.0s (+20.6%)
  2. dist-aarch64-apple: 6485.2s -> 7581.8s (+16.9%)
  3. dist-x86_64-mingw: 9669.6s -> 8448.8s (-12.6%)
  4. i686-msvc-2: 9278.3s -> 8119.0s (-12.5%)
  5. x86_64-gnu-llvm-20: 2213.9s -> 2438.3s (+10.1%)
  6. x86_64-gnu-aux: 5958.4s -> 6474.7s (+8.7%)
  7. aarch64-apple: 6985.4s -> 7570.0s (+8.4%)
  8. x86_64-gnu-stable: 6378.6s -> 6893.0s (+8.1%)
  9. x86_64-gnu-llvm-21-3: 6057.4s -> 6477.9s (+6.9%)
  10. dist-x86_64-musl: 7392.3s -> 7877.5s (+6.6%)
How to interpret the job duration changes?

Job durations can vary a lot, based on the actual runner instance
that executed the job, system noise, invalidated caches, etc. The table above is provided
mostly for t-infra members, for simpler debugging of potential CI slow-downs.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (122cbd0): comparison URL.

Overall result: ❌ regressions - please read the text below

Our benchmarks found a performance regression caused by this PR.
This might be an actual regression, but it can also be just noise.

Next Steps:

  • If the regression was expected or you think it can be justified,
    please write a comment with sufficient written justification, and add
    @rustbot label: +perf-regression-triaged to it, to mark the regression as triaged.
  • If you think that you know of a way to resolve the regression, try to create
    a new PR with a fix for the regression.
  • If you do not understand the regression or you think that it is just noise,
    you can ask the @rust-lang/wg-compiler-performance working group for help (members of this group
    were already notified of this PR).

@rustbot label: +perf-regression
cc @rust-lang/wg-compiler-performance

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
0.6% [0.1%, 0.9%] 6
Regressions ❌
(secondary)
0.8% [0.8%, 0.8%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.6% [0.1%, 0.9%] 6

Max RSS (memory usage)

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

Cycles

Results (secondary 3.0%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
3.0% [3.0%, 3.0%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Binary size

Results (primary 0.3%, secondary 0.1%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
0.3% [0.0%, 1.0%] 28
Regressions ❌
(secondary)
0.1% [0.1%, 0.2%] 9
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.3% [0.0%, 1.0%] 28

Bootstrap: 469.836s -> 471.242s (0.30%)
Artifact size: 386.24 MiB -> 386.25 MiB (0.00%)

@tmiasko tmiasko deleted the move-copy branch November 24, 2025 10:09
@Kobzol
Copy link
Member

Kobzol commented Nov 25, 2025

The perf. regression was deemed acceptable, as this fixes miscompilations.

@rustbot label: +perf-regression-triaged

@rustbot rustbot added the perf-regression-triaged The performance regression has been triaged. label Nov 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merged-by-bors This PR was explicitly merged by bors. perf-regression Performance regression. perf-regression-triaged The performance regression has been triaged. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 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.

Aliasing-related miscompile in CopyProp (use after Move of place) CopyProp miscompilation when src is moved more than once