Skip to content

Avoid generating overlapping assignments in DSE - #162998

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
saethlin:dse-ret-is-arg
Sep 22, 2026
Merged

rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
saethlin:dse-ret-is-arg

Conversation

@saethlin

Copy link
Copy Markdown
Member

This is a fix for #162997.

Considering we also had #155680, I really wonder if this pass should be using LivenessTransferFunction at all.

@rustbot

rustbot commented Sep 19, 2026

Copy link
Copy Markdown
Collaborator

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 Sep 19, 2026
@rustbot

rustbot commented Sep 19, 2026

Copy link
Copy Markdown
Collaborator

r? @adwinwhite

rustbot has assigned @adwinwhite.
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

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler
  • compiler expanded to 77 candidates
  • Random selection from 20 candidates

@saethlin

Copy link
Copy Markdown
Member Author

r? mir-opt

@rustbot rustbot assigned oli-obk and unassigned adwinwhite Sep 19, 2026
@rust-log-analyzer

This comment has been minimized.

// it eligible to be moved-from in the argument list. That's backwards.
if !destination.is_indirect() {
state.insert(destination.local);
}

@tmiasko tmiasko Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can you describe in positive terms what it is trying to accomplish and why is it necessary?

Isn't the newly inserted condition below, i.e., place.local != destination.local, sufficient to avoid overlap?

View changes since the review

@saethlin saethlin Sep 19, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The objective is to rule out turning _1 = f(copy _1) into _1 = f(move _1).

I was musing for a while about fixing this by updating state or by adding another condition, and I decided that fixing it by adding another condition would be too clumsy. The simple check if the locals are equal rules out turning the copy into move for _1[0] = f(copy _1[1]). I simply forgot to remove that line from the diff before pushing.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can you rewrite this as a separate condition?

There are two orthogonal concerns, so a separate checks make more sense to me:

  1. Existing liveness condition: moving a local clobbers its value, so the local must be dead after.
  2. Missing no-overlap condition: destination cannot overlap with moved argument.

The simple check if the locals are equal rules out turning the copy into move for _1[0] = f(copy _1[1]).

The behavior is the same here, isn't it?

@oli-obk

oli-obk commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

@bors r+

@rust-bors

rust-bors Bot commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

📌 Commit c973b50 has been approved by oli-obk

It is now in the queue for this repository.

@rust-bors rust-bors Bot 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 Sep 22, 2026
jhpratt added a commit to jhpratt/rust that referenced this pull request Sep 22, 2026
Avoid generating overlapping assignments in DSE

This is a fix for rust-lang#162997.

Considering we also had rust-lang#155680, I really wonder if this pass should be using LivenessTransferFunction at all.
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Sep 22, 2026
Avoid generating overlapping assignments in DSE

This is a fix for rust-lang#162997.

Considering we also had rust-lang#155680, I really wonder if this pass should be using LivenessTransferFunction at all.
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Sep 22, 2026
Avoid generating overlapping assignments in DSE

This is a fix for rust-lang#162997.

Considering we also had rust-lang#155680, I really wonder if this pass should be using LivenessTransferFunction at all.
rust-bors Bot pushed a commit that referenced this pull request Sep 22, 2026
…uwer

Rollup of 7 pull requests

Successful merges:

 - #147876 (Check tainted_by_error in LateLint)
 - #162998 (Avoid generating overlapping assignments in DSE)
 - #163136 (library: prune allowed lints)
 - #163102 (remove unnecessary restriction with next-solver)
 - #163106 (emit the constant pattern note for raw identifier bindings)
 - #163118 (add `feature(field_projections)` fixme)
 - #163148 (Clean up diagnostic hashing)
@rust-bors
rust-bors Bot merged commit 1c6030f into rust-lang:main Sep 22, 2026
13 checks passed
@rustbot rustbot added this to the 1.100.0 milestone Sep 22, 2026
rust-bors Bot pushed a commit that referenced this pull request Sep 22, 2026
Rollup merge of #162998 - saethlin:dse-ret-is-arg, r=oli-obk

Avoid generating overlapping assignments in DSE

This is a fix for #162997.

Considering we also had #155680, I really wonder if this pass should be using LivenessTransferFunction at all.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

6 participants