-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Pull Derefer before ElaborateDrops #98145
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
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 |
---|---|---|
|
@@ -52,6 +52,8 @@ pub enum MirPhase { | |
/// of the `mir_promoted` query), these promoted elements are available in the `promoted_mir` | ||
/// query. | ||
ConstsPromoted = 2, | ||
/// After this projections may only contain deref projections as the first element. | ||
Derefered = 3, | ||
/// Beginning with this phase, the following variants are disallowed: | ||
/// * [`TerminatorKind::DropAndReplace`] | ||
/// * [`TerminatorKind::FalseUnwind`] | ||
|
@@ -66,9 +68,7 @@ pub enum MirPhase { | |
/// Furthermore, `Drop` now uses explicit drop flags visible in the MIR and reaching a `Drop` | ||
/// terminator means that the auto-generated drop glue will be invoked. Also, `Copy` operands | ||
/// are allowed for non-`Copy` types. | ||
DropsLowered = 3, | ||
/// After this projections may only contain deref projections as the first element. | ||
Derefered = 4, | ||
DropsLowered = 4, | ||
/// Beginning with this phase, the following variant is disallowed: | ||
/// * [`Rvalue::Aggregate`] for any `AggregateKind` except `Array` | ||
/// | ||
|
@@ -1051,6 +1051,16 @@ pub enum Rvalue<'tcx> { | |
/// initialized but its content as uninitialized. Like other pointer casts, this in general | ||
/// affects alias analysis. | ||
ShallowInitBox(Operand<'tcx>, Ty<'tcx>), | ||
|
||
/// A CopyForDeref is equivalent to a read from a place at the | ||
/// codegen level, but is treated specially by drop elaboration. When such a read happens, it | ||
/// is guaranteed (via nature of the mir_opt `Derefer` in rustc_mir_transform/src/deref_separator) | ||
/// that the only use of the returned value is a deref operation, immediately | ||
/// followed by one or more projections. Drop elaboration treats this rvalue as if the | ||
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. Why are the projections relevant? What is the problem if the only use of this value is in 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. Without projection, we wouldn't even run 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. Sure but there's nothing wrong with that situation, right? If it somehow happened, all passes could handle it fine? 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. I never considered the if part so I made some local changes that makes sure it will work no matter what , I will push it alongside CI fix (Once I solve it 😭 ). |
||
/// read never happened and just projects further. This allows simplifying various MIR | ||
/// optimizations and codegen backends that previously had to handle deref operations anywhere | ||
/// in a place. | ||
CopyForDeref(Place<'tcx>), | ||
} | ||
|
||
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))] | ||
|
Uh oh!
There was an error while loading. Please reload this page.