Skip to content

Conversation

beepster4096
Copy link
Contributor

@beepster4096 beepster4096 commented Aug 16, 2025

(split from my WIP #145344)

This PR:

  • Removes Rvalue::CopyForDeref and LocalInfo::DerefTemp from runtime MIR
    • Using a new mir pass EraseDerefTemps
    • CopyForDeref(x) is turned into Use(Copy(x))
    • DerefTemp is turned into Boring
      • Not sure if this part is actually necessary, it made more sense in [WIP] Underefer refactoring #145344 with DerefTemp storing actual data that I wanted to keep from having to be kept in sync with the rest of the body in runtime MIR
  • Checks in validation that CopyForDeref and DerefTemp are only used together
  • Removes special handling for CopyForDeref from many places
  • Removes CopyForDeref from custom_mir reverting Custom MIR: Support Rvalue::CopyForDeref #111587
    • In runtime MIR simple copies can be used instead
    • In post cleanup analysis MIR it was already wrong to use due to the lack of support for creating DerefTemp locals
    • Possibly this should be its own PR?
  • Adds an argument to deref_finder to avoid creating new DerefTemps and CopyForDeref in runtime MIR.
    • Ideally we would just avoid making intermediate derefs instead of fixing it at the end of a pass / during shim building
  • Removes some usages of deref_finder that I found out don't actually do anything

r? oli-obk

@rustbot
Copy link
Collaborator

rustbot commented Aug 16, 2025

oli-obk is not on the review rotation at the moment.
They may take a while to respond.

@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. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Aug 16, 2025
@rustbot
Copy link
Collaborator

rustbot commented Aug 16, 2025

This PR changes MIR

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

Some changes occurred in compiler/rustc_codegen_cranelift

cc @bjorn3

Some changes occurred in compiler/rustc_codegen_ssa

cc @WaffleLapkin

Some changes occurred to MIR optimizations

cc @rust-lang/wg-mir-opt

Some changes occurred to the CTFE / Miri interpreter

cc @rust-lang/miri

Some changes occurred to constck

cc @fee1-dead

Some changes occurred to the intrinsics. Make sure the CTFE / Miri interpreter
gets adapted for the changes, if necessary.

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

Some changes occurred to the CTFE machinery

cc @RalfJung, @oli-obk, @lcnr

@rust-log-analyzer

This comment has been minimized.

@WaffleLapkin
Copy link
Member

(note that oli is on vacation and will be for quite a while)

@rust-log-analyzer

This comment has been minimized.

@beepster4096
Copy link
Contributor Author

@rustbot author
r? ghost

@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 17, 2025
@rustbot
Copy link
Collaborator

rustbot commented Aug 17, 2025

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@rustbot rustbot added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Aug 17, 2025
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

some optimization is behaving slightly differently on box derefs after this change, but the difference is irrelevant
it did not create DerefTemp locals when used, so it was never actually correct.
elaborate drops and inline don't seem to actually need it
@beepster4096
Copy link
Contributor Author

r? mir
@rustbot ready

@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 Aug 18, 2025
@davidtwco
Copy link
Member

It's been long enough since I've looked at a involved MIR change that I'm probably not best suited to this

r? mir

@rustbot rustbot assigned saethlin and unassigned davidtwco Aug 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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. 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.

7 participants