Mark more locals as moved to avoid building drops for them. - #158281
Mark more locals as moved to avoid building drops for them.#158281cjgillot wants to merge 5 commits into
Conversation
|
Some changes occurred to MIR optimizations cc @rust-lang/wg-mir-opt |
|
r? @JohnTitor rustbot has assigned @JohnTitor. Use Why was this reviewer chosen?The reviewer was selected based on:
|
|
Does this have user-visible behavior changes? e.g., see #156713 |
|
Yes. With this change, both cases in #156713 pass. We also have a few user-visible consequences with the drop order lint. |
|
@rustbot reroll |
51861b3 to
d128dba
Compare
This comment has been minimized.
This comment has been minimized.
a5dd21c to
4ff8c26
Compare
This comment has been minimized.
This comment has been minimized.
4ff8c26 to
90e4893
Compare
This comment has been minimized.
This comment has been minimized.
90e4893 to
a851b9e
Compare
This comment has been minimized.
This comment has been minimized.
|
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
734e208 to
4ad2c3f
Compare
This comment has been minimized.
This comment has been minimized.
|
I'm not personally very familiar with when we are allowed to avoid building drops (specifically, which are these truly count as moves from an opsem perspective). cc both @rust-lang/opsem and @rust-lang/types I would be far more comfortable if there was a small and specific test demonstrating the difference from marking each individual site that we record as moved. |
|
I'm afraid MIR building is mostly outside my wheelhouse. |
|
Is there somewhere a high-level description of the algorithm implemented here and how it defines "move"? |
At high level, the doc-comment on
This is on the "built" MIR phase. In short, a "move" is an occurrence of |
4ad2c3f to
c18975a
Compare
This comment has been minimized.
This comment has been minimized.
Latest push adds a |
"de-initialize" here refers to the initialization state tracked for drop flags, right? |
This comment has been minimized.
This comment has been minimized.
Yes |
c18975a to
1811466
Compare
This comment has been minimized.
This comment has been minimized.
This should probably be mentioned in the |
1811466 to
6e4bdc1
Compare
|
This PR changes MIR cc @oli-obk, @RalfJung, @JakobDegen, @vakaras |
This comment has been minimized.
This comment has been minimized.
And some more cases along the way. We have a specific optimization to avoid generating useless drops, use it. In particular, aggregate construction are very similar to function calls for which this is designed.
6e4bdc1 to
a9aef0f
Compare
|
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. |
View all comments
MIR building skips generating drops for moved-from locals in the topmost scope. This was only used for call terminators, but can be generalized to many other moves. This PR generalizes this to aggregate construction and many other assignments.
This avoids generating drops that would then be removed by drop elaboration.
This PR changes borrowck behaviour: some programs that were rejected are now accepted, see the last commit. That particular case was wrongly rejected.
Fixes #156713
Based on #158279 to remove a lint false-positive