Skip to content

MIR move elimination [3/6]: PreciseLiveness - #163337

Open
Amanieu wants to merge 4 commits into
rust-lang:mainfrom
Amanieu:move-elimination/precise-liveness
Open

Amanieu wants to merge 4 commits into
rust-lang:mainfrom
Amanieu:move-elimination/precise-liveness

Conversation

@Amanieu

@Amanieu Amanieu commented Sep 25, 2026 •

Copy link
Copy Markdown
Member

Depends on #163335

This PR implements the lifetime analysis used by the MoveElimination pass from rust-lang/rfcs#3943.

PreciseLiveness calculates, at a sub-statement granularity, the points in a function where a local requires storage to be allocated. This is more fine-grained than MaybeStorageLive, and takes borrows into account.

r? tmiasko

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-clippy Relevant to the Clippy team. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Sep 25, 2026
@Amanieu

Amanieu commented Sep 25, 2026

Copy link
Copy Markdown
Member Author

LLM disclosure: LLMs were used to double-check the correctness of the analysis against the RFC, Miri and existing MIR passes. It was useful since it found several issues, notably around the behavior of call destination places in the unwind path.

@Amanieu Amanieu added the llm-assisted An LLM-assisted PR as defined by the LLM policy. Requires ahead-of-time consent by assignee. label Sep 25, 2026
@Amanieu
Amanieu force-pushed the move-elimination/precise-liveness branch from e7ac990 to 191a6f0 Compare September 26, 2026 01:05
@Amanieu
Amanieu force-pushed the move-elimination/precise-liveness branch from 191a6f0 to 8f7b938 Compare September 30, 2026 12:49
@Amanieu
Amanieu marked this pull request as ready for review September 30, 2026 13:03
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Sep 30, 2026
@Amanieu
Amanieu force-pushed the move-elimination/precise-liveness branch from 8f7b938 to 1c34f63 Compare September 30, 2026 13:03
@rustbot

rustbot commented Sep 30, 2026

Copy link
Copy Markdown
Collaborator

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.

@tmiasko

tmiasko commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

Would it be possible to test this independently from move elimination?

@Amanieu

Amanieu commented Oct 1, 2026

Copy link
Copy Markdown
Member Author

We don't really have good infrastructure for testing analysis passes directly. The best I can do is generate some analysis snapshots, but it won't have any CHECK comments since those only look at the final MIR.

My preference is to instead have this tested indirectly through the tests in MoveElimination.

@tmiasko

tmiasko commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Perhaps we could annotate final MIR with dataflow results and run file check on it? For example, along the lines of https://github.com/tmiasko/rust/tree/pretty-dataflow.

@Amanieu

Amanieu commented Oct 2, 2026

Copy link
Copy Markdown
Member Author

Yes, this seems to work, see my latest commit that builds on top of yours. How do you plan to land this? Will you be making a separate PR with your pretty infrastructure?

@tmiasko

tmiasko commented Oct 3, 2026

Copy link
Copy Markdown
Contributor

Opened #163721 with dataflow pretty printing.

@Amanieu

Amanieu commented Oct 4, 2026

Copy link
Copy Markdown
Member Author

By the way, I'm not super happy about the name PreciseLiveness and I'm open to ideas about better names.

@rust-bors

rust-bors Bot commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

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

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

llm-assisted An LLM-assisted PR as defined by the LLM policy. Requires ahead-of-time consent by assignee. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-clippy Relevant to the Clippy team. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants