Skip to content

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

Merged
rust-bors[bot] merged 3 commits into
rust-lang:mainfrom
Amanieu:move-elimination/precise-liveness
Oct 9, 2026
Merged

rust-bors[bot] merged 3 commits into
rust-lang:mainfrom
Amanieu:move-elimination/precise-liveness

Conversation

@Amanieu

@Amanieu Amanieu commented Sep 25, 2026 •

Copy link
Copy Markdown
Member

View all comments

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

This comment has been minimized.

@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

This comment has been minimized.

@Amanieu
Amanieu force-pushed the move-elimination/precise-liveness branch from b1a44c7 to 3f7db5c Compare October 5, 2026 20:00
@rustbot

rustbot commented Oct 5, 2026

Copy link
Copy Markdown
Collaborator

Some changes occurred in compiler/rustc_attr_parsing

cc @jdonszelmann, @JonathanBrouwer

Some changes occurred in compiler/rustc_attr_ir

cc @jdonszelmann, @JonathanBrouwer

@rustbot rustbot added the A-attributes Area: Attributes (`#[…]`, `#![…]`) label Oct 5, 2026
Comment thread compiler/rustc_mir_dataflow/src/impls/precise_liveness.rs
Comment thread compiler/rustc_mir_dataflow/src/impls/precise_liveness.rs
Comment thread compiler/rustc_mir_dataflow/src/impls/precise_liveness.rs Outdated
Comment thread compiler/rustc_mir_dataflow/src/impls/precise_liveness.rs Outdated
Comment thread tests/mir-opt/precise_liveness.rs
Comment thread compiler/rustc_mir_dataflow/src/impls/precise_liveness.rs
@tmiasko

tmiasko commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

Thanks. r=me with "Add additional comments & clarify existing ones" and "Address review feedback" incorporated into earlier commits.

@Amanieu
Amanieu force-pushed the move-elimination/precise-liveness branch from 02741ef to c645363 Compare October 8, 2026 23:13
@Amanieu

Amanieu commented Oct 8, 2026

Copy link
Copy Markdown
Member Author

@bors r=tmiasko

@rust-bors

rust-bors Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

📌 Commit c645363 has been tentatively approved by tmiasko

It will be put into the queue for this repository once PR CI succeeds.

@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 Oct 8, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Oct 9, 2026
…iveness, r=tmiasko

MIR move elimination [3/6]: PreciseLiveness

Depends on rust-lang#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
rust-bors Bot pushed a commit that referenced this pull request Oct 9, 2026
…uwer

Rollup of 7 pull requests

Successful merges:

 - #162652 (Syntactically reject leading parenthesized precise capturing lists in bare trait object types (`(use<…>)+`))
 - #163337 (MIR move elimination [3/6]: PreciseLiveness)
 - #163954 (fix(bootstrap/darwin): fix rpath for distributed LLD)
 - #163956 (Pass the unremapped path to the `rustc` invocation for doctests)
 - #163634 (move overflow lint computation into decorator)
 - #163727 (rigid aliases to non-rigid for fully normalized check)
 - #163745 (replace `fully_monomorphized` with `cx.typing_env()`)
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Oct 9, 2026
…iveness, r=tmiasko

MIR move elimination [3/6]: PreciseLiveness

Depends on rust-lang#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
rust-bors Bot pushed a commit that referenced this pull request Oct 9, 2026
…uwer

Rollup of 11 pull requests

Successful merges:

 - #162652 (Syntactically reject leading parenthesized precise capturing lists in bare trait object types (`(use<…>)+`))
 - #163337 (MIR move elimination [3/6]: PreciseLiveness)
 - #163954 (fix(bootstrap/darwin): fix rpath for distributed LLD)
 - #163956 (Pass the unremapped path to the `rustc` invocation for doctests)
 - #163634 (move overflow lint computation into decorator)
 - #163666 (Updates the expect message library/core/src/time.rs)
 - #163727 (rigid aliases to non-rigid for fully normalized check)
 - #163745 (replace `fully_monomorphized` with `cx.typing_env()`)
 - #164000 (When mentioning that closure doesn't implement trait, point at closure)
 - #164007 ([rustdoc] Prefer local paths over remote ones when foreign item is locally reexported)
 - #164017 (cg_llvm: Avoid some explicit casts to `*const c_char`)
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Oct 9, 2026
…iveness, r=tmiasko

MIR move elimination [3/6]: PreciseLiveness

Depends on rust-lang#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
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Oct 9, 2026
…iveness, r=tmiasko

MIR move elimination [3/6]: PreciseLiveness

Depends on rust-lang#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
rust-bors Bot pushed a commit that referenced this pull request Oct 9, 2026
…uwer

Rollup of 14 pull requests

Successful merges:

 - #162652 (Syntactically reject leading parenthesized precise capturing lists in bare trait object types (`(use<…>)+`))
 - #163337 (MIR move elimination [3/6]: PreciseLiveness)
 - #163954 (fix(bootstrap/darwin): fix rpath for distributed LLD)
 - #163193 (cfi: mangle `f128` as `e` rather than `g` on platforms without `_Float128`)
 - #163634 (move overflow lint computation into decorator)
 - #163666 (Updates the expect message library/core/src/time.rs)
 - #163727 (rigid aliases to non-rigid for fully normalized check)
 - #163745 (replace `fully_monomorphized` with `cx.typing_env()`)
 - #163912 (Fix debug assert failure in `note_obligation_cause_code_inner`)
 - #163972 (const-eval: ICE when we hit a non-const fn)
 - #164000 (When mentioning that closure doesn't implement trait, point at closure)
 - #164007 ([rustdoc] Prefer local paths over remote ones when foreign item is locally reexported)
 - #164017 (cg_llvm: Avoid some explicit casts to `*const c_char`)
 - #164025 (Less `CanonicalVarValues`)
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Oct 9, 2026
…iveness, r=tmiasko

MIR move elimination [3/6]: PreciseLiveness

Depends on rust-lang#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
rust-bors Bot pushed a commit that referenced this pull request Oct 9, 2026
…uwer

Rollup of 14 pull requests

Successful merges:

 - #162652 (Syntactically reject leading parenthesized precise capturing lists in bare trait object types (`(use<…>)+`))
 - #163337 (MIR move elimination [3/6]: PreciseLiveness)
 - #163954 (fix(bootstrap/darwin): fix rpath for distributed LLD)
 - #163193 (cfi: mangle `f128` as `e` rather than `g` on platforms without `_Float128`)
 - #163634 (move overflow lint computation into decorator)
 - #163666 (Updates the expect message library/core/src/time.rs)
 - #163727 (rigid aliases to non-rigid for fully normalized check)
 - #163745 (replace `fully_monomorphized` with `cx.typing_env()`)
 - #163912 (Fix debug assert failure in `note_obligation_cause_code_inner`)
 - #163950 (don't treat inherited opaques as defining)
 - #164000 (When mentioning that closure doesn't implement trait, point at closure)
 - #164007 ([rustdoc] Prefer local paths over remote ones when foreign item is locally reexported)
 - #164017 (cg_llvm: Avoid some explicit casts to `*const c_char`)
 - #164025 (Less `CanonicalVarValues`)
rust-bors Bot pushed a commit that referenced this pull request Oct 9, 2026
…uwer

Rollup of 24 pull requests

Successful merges:

 - #161998 ( Support type-relative assoc item paths in generic param defaults & const param types)
 - #162106 (Helpful suggestions for incorrect address-of mutability (2))
 - #162652 (Syntactically reject leading parenthesized precise capturing lists in bare trait object types (`(use<…>)+`))
 - #163337 (MIR move elimination [3/6]: PreciseLiveness)
 - #163938 (-Zassumptions-on-binders: rewrite alias outlives constraints more goodly)
 - #163939 (Better debug impls for some assumptions on binders types)
 - #163954 (fix(bootstrap/darwin): fix rpath for distributed LLD)
 - #163956 (Pass the unremapped path to the `rustc` invocation for doctests)
 - #164042 (Allow testing cg-gcc on any target)
 - #162443 (Do not retain `Normalization` goal errors in nested goals for `BestObligationVisitor:: non_trivial_candidates `)
 - #162908 (Fix - const parameters rejected when identical)
 - #163193 (cfi: mangle `f128` as `e` rather than `g` on platforms without `_Float128`)
 - #163634 (move overflow lint computation into decorator)
 - #163666 (Updates the expect message library/core/src/time.rs)
 - #163727 (rigid aliases to non-rigid for fully normalized check)
 - #163745 (replace `fully_monomorphized` with `cx.typing_env()`)
 - #163912 (Fix debug assert failure in `note_obligation_cause_code_inner`)
 - #163950 (don't treat inherited opaques as defining)
 - #163972 (const-eval: ICE when we hit a non-const fn)
 - #164000 (When mentioning that closure doesn't implement trait, point at closure)
 - #164007 ([rustdoc] Prefer local paths over remote ones when foreign item is locally reexported)
 - #164008 (properly ignore the current goal's usages)
 - #164017 (cg_llvm: Avoid some explicit casts to `*const c_char`)
 - #164025 (Less `CanonicalVarValues`)
@rust-bors
rust-bors Bot merged commit 98476db into rust-lang:main Oct 9, 2026
14 checks passed
@rustbot rustbot added this to the 1.101.0 milestone Oct 9, 2026
rust-bors Bot pushed a commit that referenced this pull request Oct 9, 2026
Rollup merge of #163337 - Amanieu:move-elimination/precise-liveness, r=tmiasko

MIR move elimination [3/6]: PreciseLiveness

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-attributes Area: Attributes (`#[…]`, `#![…]`) llm-assisted An LLM-assisted PR as defined by the LLM policy. Requires ahead-of-time consent by assignee. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 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.

4 participants