-
-
Notifications
You must be signed in to change notification settings - Fork 15.4k
Mark more locals as moved to avoid building drops for them. #158281
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -732,42 +732,40 @@ pub enum TerminatorKind<'tcx> { | |||||||
|
|
||||||||
| /// The behavior of this statement differs significantly before and after drop elaboration. | ||||||||
| /// | ||||||||
| /// After drop elaboration: `Drop` terminators are a complete nop for types that have no drop | ||||||||
| /// After drop elaboration, `Drop` terminators are a complete nop for types that have no drop | ||||||||
| /// glue. For other types, `Drop` terminators behave exactly like a call to | ||||||||
| /// `core::mem::drop_glue` with a reference to the given place. | ||||||||
| /// | ||||||||
| /// `Drop` before drop elaboration is a *conditional* execution of the drop glue. Specifically, | ||||||||
| /// the `Drop` will be executed if... | ||||||||
| /// Before drop elaboration, `Drop` behave as a *conditional* execution of the drop glue. | ||||||||
| /// Specifically, the drop glue is executed if, among all statements executed within this | ||||||||
| /// `Body`, an assignment to the place occurred more recently than a move out of it. | ||||||||
| /// If a place is partially assigned-to or partially moved-from, the drop glue is only executed | ||||||||
| /// on the assigned-to part. | ||||||||
| /// | ||||||||
| /// **Needs clarification**: End of that sentence. This in effect should document the exact | ||||||||
| /// behavior of drop elaboration. The following sounds vaguely right, but I'm not quite sure: | ||||||||
| /// This considers the contents of a `Box` to be a sub-place, but does not consider indirect | ||||||||
| /// assignments through references or pointers. | ||||||||
| /// | ||||||||
| /// > The drop glue is executed if, among all statements executed within this `Body`, an assignment to | ||||||||
| /// > the place or one of its "parents" occurred more recently than a move out of it. This does not | ||||||||
| /// > consider indirect assignments. | ||||||||
| /// **Async drop processing**: | ||||||||
| /// MIR building detects possible async drops, and constructs a complete CFG. To correctly | ||||||||
| /// handle the coroutine being dropped while itself drops, we need a 'drop' target | ||||||||
| /// similar to `Yield` terminator. | ||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
| /// | ||||||||
| /// The `replace` flag indicates whether this terminator was created as part of an assignment. | ||||||||
| /// This should only be used for diagnostic purposes, and does not have any operational | ||||||||
| /// meaning. | ||||||||
| /// Drop elaboration later refines the set of useful async drops. If there is no need for an | ||||||||
| /// async drop, it is downgraded to a sync drop by setting `drop` to `None` If this is an | ||||||||
| /// actual async drop, it is expanded to an `await` loop over the `async_drop_in_place` or | ||||||||
| /// `AsyncDrop::drop` coroutine. | ||||||||
| /// | ||||||||
| /// Async drop processing: | ||||||||
| /// MIR building detects possible async drops, and constructs a complete CFG. To correctly | ||||||||
| /// handle the coroutine being dropped while itself drops, we need a 'drop' target | ||||||||
| /// similar to `Yield` terminator (see `drops.build_mir::<CoroutineDrop>`). | ||||||||
| /// | ||||||||
| /// Drop elaboration later refines the set of useful async drops. If there is no need for an | ||||||||
| /// async drop, it is downgraded to a sync drop by setting `drop` to `None` If this is an | ||||||||
| /// actual async drop, it is expanded to an `await` loop over the `async_drop_in_place` or | ||||||||
| /// `AsyncDrop::drop` coroutine. | ||||||||
| /// | ||||||||
| /// When a coroutine has any internal async drop, the coroutine drop function will be async | ||||||||
| /// (generated by `create_coroutine_drop_shim_async`, not `create_coroutine_drop_shim`). | ||||||||
| /// When a coroutine has any internal async drop, the coroutine drop function will be async | ||||||||
| /// (generated by `create_coroutine_drop_shim_async`, not `create_coroutine_drop_shim`). | ||||||||
| Drop { | ||||||||
| place: Place<'tcx>, | ||||||||
| target: BasicBlock, | ||||||||
| unwind: UnwindAction, | ||||||||
| /// The `replace` flag indicates whether this terminator was created as part of an | ||||||||
| /// assignment. This should only be used for diagnostic purposes, and does not have any | ||||||||
| /// operational meaning. | ||||||||
| replace: bool, | ||||||||
| /// Cleanup to be done if the coroutine is dropped at this suspend point (for async drop). | ||||||||
| /// Cleanup to be done if the coroutine is dropped at this suspend point, for async drop. | ||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Is this right? The interpreter asserts it. |
||||||||
| drop: Option<BasicBlock>, | ||||||||
| }, | ||||||||
|
|
||||||||
|
|
@@ -1288,6 +1286,9 @@ pub enum Operand<'tcx> { | |||||||
|
|
||||||||
| /// Creates a value by performing loading the place, just like the `Copy` operand. | ||||||||
| /// | ||||||||
| /// During MIR analyzes, it overwrites the place with `uninit` bytes and unschedules drops on | ||||||||
| /// the given place. | ||||||||
|
Comment on lines
+1289
to
+1290
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There's no overwriting happening, or at least it's unclear -- that's the point of the next paragraph. |
||||||||
| /// | ||||||||
| /// This *may* additionally overwrite the place with `uninit` bytes, depending on how we decide | ||||||||
| /// in [UCG#188]. You should not emit MIR that may attempt a subsequent second load of this | ||||||||
| /// place without first re-initializing it. | ||||||||
|
|
||||||||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"while itself drops"? I can't quite parse this.
View changes since the review