Skip to content

Add Miri support for move elimination semantics - #162048

Draft
Amanieu wants to merge 14 commits into
rust-lang:mainfrom
Amanieu:miri-move-elimination
Draft

Add Miri support for move elimination semantics#162048
Amanieu wants to merge 14 commits into
rust-lang:mainfrom
Amanieu:miri-move-elimination

Conversation

@Amanieu

@Amanieu Amanieu commented Aug 31, 2026

Copy link
Copy Markdown
Member

Adds support to Miri for the new MIR semantics from RFC 3943 when -Zmir-move-elimination is enabled. This builds on top of #157943, look at the last commit only.

Notable changes:

  • Added a LocalValue::LiveUnallocated state to represent a local that is StorageLive but hasn't been eliminated yet.
    • Except for ZSTs: those are always fully allocated at StorageLive. This is necessary for the RemoveZsts pass and because several MIR constructors leave ZST places uninitialized.
  • Added eval_place_for_write which allocates a local if it is currently LiveUnallocated.
  • Move operands with a bare local are evaluated by move_out_local: it copies the value to a temporary allocation freed at the end of the statement, and then frees the original allocation, switching the local to LiveUnallocated.
  • FnArg::InPlace arguments that are bare locals are recorded as part of the ReturnContinuation. They are freed upon returning or unwinding back to the caller.
  • Rvalue evaluation needs to evaluate the destination after all operands. This is done by evaluating the rvalue into a temporary allocation, and then moving that to the evaluated destination.

r? @ghost

@rustbot

rustbot commented Aug 31, 2026

Copy link
Copy Markdown
Collaborator

miri is developed in its own repository. If the Miri part of this change can be broken out, consider making this change to rust-lang/miri instead. However, if Miri needs adjusting for rustc changes, just ignore this message.

cc @rust-lang/miri

This PR changes rustc_public

cc @oli-obk, @celinval, @ouz-a, @makai410

Some changes occurred to the CTFE / Miri interpreter

cc @rust-lang/miri

Some changes occurred to MIR optimizations

cc @rust-lang/wg-mir-opt

Some changes occurred to the CTFE machinery

cc @RalfJung, @oli-obk, @lcnr

This PR changes MIR

cc @oli-obk, @RalfJung, @JakobDegen, @vakaras

Some changes occurred to the CTFE / Miri interpreter

cc @rust-lang/miri, @RalfJung, @oli-obk, @lcnr

@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 Aug 31, 2026
@Amanieu
Amanieu marked this pull request as draft August 31, 2026 06:54
@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 Aug 31, 2026
@Amanieu

Amanieu commented Aug 31, 2026

Copy link
Copy Markdown
Member Author

Oops, that should've been a draft.

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.

2 participants