diff options
| author | Camille GILLOT <gillot.camille@gmail.com> | 2023-10-17 18:35:13 +0000 |
|---|---|---|
| committer | Camille GILLOT <gillot.camille@gmail.com> | 2023-10-21 07:02:06 +0000 |
| commit | b5aa1ef9b42c744db10e20fa946c6a4bb66b2cbb (patch) | |
| tree | 9fc5ceecbc588a5197c953520876c926672aea14 /compiler/rustc_mir_transform/src/jump_threading.rs | |
| parent | 4abea8366339b66932bf80203dd0884366fdb872 (diff) | |
| download | rust-b5aa1ef9b42c744db10e20fa946c6a4bb66b2cbb.tar.gz rust-b5aa1ef9b42c744db10e20fa946c6a4bb66b2cbb.zip | |
Document mutated_statement.
Diffstat (limited to 'compiler/rustc_mir_transform/src/jump_threading.rs')
| -rw-r--r-- | compiler/rustc_mir_transform/src/jump_threading.rs | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/compiler/rustc_mir_transform/src/jump_threading.rs b/compiler/rustc_mir_transform/src/jump_threading.rs index a5ee843e23a..16da3c934e7 100644 --- a/compiler/rustc_mir_transform/src/jump_threading.rs +++ b/compiler/rustc_mir_transform/src/jump_threading.rs @@ -273,6 +273,18 @@ impl<'tcx, 'a> TOFinder<'tcx, 'a> { } /// Extract the mutated place from a statement. + /// + /// This method returns the `Place` so we can flood the state in case of a partial assignment. + /// (_1 as Ok).0 = _5; + /// (_1 as Err).0 = _6; + /// We want to ensure that a `SwitchInt((_1 as Ok).0)` does not see the first assignment, as + /// the value may have been mangled by the second assignment. + /// + /// In case we assign to a discriminant, we return `Some(TrackElem::Discriminant)`, so we can + /// stop at flooding the discriminant, and preserve the variant fields. + /// (_1 as Some).0 = _6; + /// SetDiscriminant(_1, 1); + /// switchInt((_1 as Some).0) #[instrument(level = "trace", skip(self), ret)] fn mutated_statement( &self, @@ -280,9 +292,6 @@ impl<'tcx, 'a> TOFinder<'tcx, 'a> { ) -> Option<(Place<'tcx>, Option<TrackElem>)> { match stmt.kind { StatementKind::Assign(box (place, _)) - | StatementKind::Intrinsic(box NonDivergingIntrinsic::Assume( - Operand::Copy(place) | Operand::Move(place), - )) | StatementKind::Deinit(box place) => Some((place, None)), StatementKind::SetDiscriminant { box place, variant_index: _ } => { Some((place, Some(TrackElem::Discriminant))) @@ -291,7 +300,9 @@ impl<'tcx, 'a> TOFinder<'tcx, 'a> { Some((Place::from(local), None)) } StatementKind::Retag(..) - | StatementKind::Intrinsic(..) + | StatementKind::Intrinsic(box NonDivergingIntrinsic::Assume(..)) + // copy_nonoverlapping takes pointers and mutated the pointed-to value. + | StatementKind::Intrinsic(box NonDivergingIntrinsic::CopyNonOverlapping(..)) | StatementKind::AscribeUserType(..) | StatementKind::Coverage(..) | StatementKind::FakeRead(..) |
