Skip to content

MIR move elimination [2/6]: TailCopyToMove - #163336

Open
Amanieu wants to merge 2 commits into
rust-lang:mainfrom
Amanieu:move-elimination/tail-copy-to-move
Open

Amanieu wants to merge 2 commits into
rust-lang:mainfrom
Amanieu:move-elimination/tail-copy-to-move

Conversation

@Amanieu

@Amanieu Amanieu commented Sep 25, 2026 •

Copy link
Copy Markdown
Member

Depends on #163335

This PR implements a pre-pass for the MoveElimination pass from rust-lang/rfcs#3943.

TailCopyToMove turns Copy into Move just before a Return terminator. This is valid even for places that have been borrowed because the Return will invalidate borrows anyway. This is necessary to allow the source of the copy to be unified with the return place.

r? tmiasko

@rustbot

rustbot commented Sep 25, 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 25, 2026
@Amanieu

Amanieu commented Sep 25, 2026

Copy link
Copy Markdown
Member Author

LLM disclosure: I actually tried getting an LLM to write this entire pass for me. It was a disaster that was unsound in new and interesting ways. That draft was promptly nuked and replaced with a properly thought out implementation. LLMs were also used to generate the boilerplate for the MIR tests, but each test was manually reviewed and adjusted before committing.

@oli-obk oli-obk 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

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-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.

4 participants