Enum rustc_mir_dataflow::value_analysis::State
source · pub enum State<V> {
Unreachable,
Reachable(StateData<V>),
}
Expand description
The dataflow state for an instance of ValueAnalysis
.
Every instance specifies a lattice that represents the possible values of a single tracked
place. If we call this lattice V
and set of tracked places P
, then a State
is an
element of {unreachable} ∪ (P -> V)
. This again forms a lattice, where the bottom element is
unreachable
and the top element is the mapping p ↦ ⊤
. Note that the mapping p ↦ ⊥
is not
the bottom element (because joining an unreachable and any other reachable state yields a
reachable state). All operations on unreachable states are ignored.
Flooding means assigning a value (by default ⊤
) to all tracked projections of a given place.
Variants§
Implementations§
source§impl<V: Clone + HasBottom> State<V>
impl<V: Clone + HasBottom> State<V>
pub fn new_reachable() -> State<V>
pub fn all_bottom(&self) -> bool
fn is_reachable(&self) -> bool
sourcepub fn flood_with(&mut self, place: PlaceRef<'_>, map: &Map<'_>, value: V)
pub fn flood_with(&mut self, place: PlaceRef<'_>, map: &Map<'_>, value: V)
Assign value
to all places that are contained in place
or may alias one.
sourcepub fn flood(&mut self, place: PlaceRef<'_>, map: &Map<'_>)where
V: HasTop,
pub fn flood(&mut self, place: PlaceRef<'_>, map: &Map<'_>)where
V: HasTop,
Assign TOP
to all places that are contained in place
or may alias one.
sourcefn flood_discr_with(&mut self, place: PlaceRef<'_>, map: &Map<'_>, value: V)
fn flood_discr_with(&mut self, place: PlaceRef<'_>, map: &Map<'_>, value: V)
Assign value
to the discriminant of place
and all places that may alias it.
sourcepub fn flood_discr(&mut self, place: PlaceRef<'_>, map: &Map<'_>)where
V: HasTop,
pub fn flood_discr(&mut self, place: PlaceRef<'_>, map: &Map<'_>)where
V: HasTop,
Assign TOP
to the discriminant of place
and all places that may alias it.
sourcepub fn flood_with_tail_elem(
&mut self,
place: PlaceRef<'_>,
tail_elem: Option<TrackElem>,
map: &Map<'_>,
value: V,
)
pub fn flood_with_tail_elem( &mut self, place: PlaceRef<'_>, tail_elem: Option<TrackElem>, map: &Map<'_>, value: V, )
This method is the most general version of the flood_*
method.
Assign value
on the given place and all places that may alias it. In particular, when
the given place has a variant downcast, we invoke the function on all the other variants.
tail_elem
allows to support discriminants that are not a place in MIR, but that we track
as such.
sourcefn insert_idx(
&mut self,
target: PlaceIndex,
result: ValueOrPlace<V>,
map: &Map<'_>,
)
fn insert_idx( &mut self, target: PlaceIndex, result: ValueOrPlace<V>, map: &Map<'_>, )
Low-level method that assigns to a place. This does nothing if the place is not tracked.
The target place must have been flooded before calling this method.
sourcepub fn insert_value_idx(&mut self, target: PlaceIndex, value: V, map: &Map<'_>)
pub fn insert_value_idx(&mut self, target: PlaceIndex, value: V, map: &Map<'_>)
Low-level method that assigns a value to a place. This does nothing if the place is not tracked.
The target place must have been flooded before calling this method.
sourcepub fn insert_place_idx(
&mut self,
target: PlaceIndex,
source: PlaceIndex,
map: &Map<'_>,
)
pub fn insert_place_idx( &mut self, target: PlaceIndex, source: PlaceIndex, map: &Map<'_>, )
Copies source
to target
, including all tracked places beneath.
If target
contains a place that is not contained in source
, it will be overwritten with
Top. Also, because this will copy all entries one after another, it may only be used for
places that are non-overlapping or identical.
The target place must have been flooded before calling this method.
sourcepub fn assign(
&mut self,
target: PlaceRef<'_>,
result: ValueOrPlace<V>,
map: &Map<'_>,
)where
V: HasTop,
pub fn assign(
&mut self,
target: PlaceRef<'_>,
result: ValueOrPlace<V>,
map: &Map<'_>,
)where
V: HasTop,
Helper method to interpret target = result
.
sourcepub fn assign_discr(
&mut self,
target: PlaceRef<'_>,
result: ValueOrPlace<V>,
map: &Map<'_>,
)where
V: HasTop,
pub fn assign_discr(
&mut self,
target: PlaceRef<'_>,
result: ValueOrPlace<V>,
map: &Map<'_>,
)where
V: HasTop,
Helper method for assignments to a discriminant.
sourcepub fn try_get(&self, place: PlaceRef<'_>, map: &Map<'_>) -> Option<V>
pub fn try_get(&self, place: PlaceRef<'_>, map: &Map<'_>) -> Option<V>
Retrieve the value stored for a place, or None
if it is not tracked.
sourcepub fn try_get_discr(&self, place: PlaceRef<'_>, map: &Map<'_>) -> Option<V>
pub fn try_get_discr(&self, place: PlaceRef<'_>, map: &Map<'_>) -> Option<V>
Retrieve the discriminant stored for a place, or None
if it is not tracked.
sourcepub fn try_get_len(&self, place: PlaceRef<'_>, map: &Map<'_>) -> Option<V>
pub fn try_get_len(&self, place: PlaceRef<'_>, map: &Map<'_>) -> Option<V>
Retrieve the slice length stored for a place, or None
if it is not tracked.
sourcepub fn try_get_idx(&self, place: PlaceIndex, map: &Map<'_>) -> Option<V>
pub fn try_get_idx(&self, place: PlaceIndex, map: &Map<'_>) -> Option<V>
Retrieve the value stored for a place index, or None
if it is not tracked.
sourcepub fn get(&self, place: PlaceRef<'_>, map: &Map<'_>) -> V
pub fn get(&self, place: PlaceRef<'_>, map: &Map<'_>) -> V
Retrieve the value stored for a place, or ⊤ if it is not tracked.
This method returns ⊥ if the place is tracked and the state is unreachable.
sourcepub fn get_discr(&self, place: PlaceRef<'_>, map: &Map<'_>) -> V
pub fn get_discr(&self, place: PlaceRef<'_>, map: &Map<'_>) -> V
Retrieve the value stored for a place, or ⊤ if it is not tracked.
This method returns ⊥ the current state is unreachable.
Trait Implementations§
source§impl<'tcx, T> DebugWithContext<ValueAnalysisWrapper<T>> for State<T::Value>
impl<'tcx, T> DebugWithContext<ValueAnalysisWrapper<T>> for State<T::Value>
This is used to visualize the dataflow analysis.
fn fmt_with( &self, ctxt: &ValueAnalysisWrapper<T>, f: &mut Formatter<'_>, ) -> Result
source§fn fmt_diff_with(
&self,
old: &Self,
ctxt: &ValueAnalysisWrapper<T>,
f: &mut Formatter<'_>,
) -> Result
fn fmt_diff_with( &self, old: &Self, ctxt: &ValueAnalysisWrapper<T>, f: &mut Formatter<'_>, ) -> Result
source§impl<V: JoinSemiLattice + Clone + HasBottom> JoinSemiLattice for State<V>
impl<V: JoinSemiLattice + Clone + HasBottom> JoinSemiLattice for State<V>
impl<V: Eq> Eq for State<V>
impl<V> StructuralPartialEq for State<V>
Auto Trait Implementations§
impl<V> DynSend for State<V>where
V: DynSend,
impl<V> DynSync for State<V>where
V: DynSync,
impl<V> Freeze for State<V>where
V: Freeze,
impl<V> RefUnwindSafe for State<V>where
V: RefUnwindSafe,
impl<V> Send for State<V>where
V: Send,
impl<V> Sync for State<V>where
V: Sync,
impl<V> Unpin for State<V>where
V: Unpin,
impl<V> UnwindSafe for State<V>where
V: UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<T, R> CollectAndApply<T, R> for T
impl<T, R> CollectAndApply<T, R> for T
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.source§impl<T> Filterable for T
impl<T> Filterable for T
source§fn filterable(
self,
filter_name: &'static str,
) -> RequestFilterDataProvider<T, fn(_: DataRequest<'_>) -> bool>
fn filterable( self, filter_name: &'static str, ) -> RequestFilterDataProvider<T, fn(_: DataRequest<'_>) -> bool>
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§impl<P> IntoQueryParam<P> for P
impl<P> IntoQueryParam<P> for P
fn into_query_param(self) -> P
source§impl<T> MaybeResult<T> for T
impl<T> MaybeResult<T> for T
source§impl<T> Pointable for T
impl<T> Pointable for T
source§impl<I, T, U> Upcast<I, U> for Twhere
U: UpcastFrom<I, T>,
impl<I, T, U> Upcast<I, U> for Twhere
U: UpcastFrom<I, T>,
source§impl<I, T> UpcastFrom<I, T> for T
impl<I, T> UpcastFrom<I, T> for T
fn upcast_from(from: T, _tcx: I) -> T
source§impl<Tcx, T> Value<Tcx> for Twhere
Tcx: DepContext,
impl<Tcx, T> Value<Tcx> for Twhere
Tcx: DepContext,
default fn from_cycle_error( tcx: Tcx, cycle_error: &CycleError, _guar: ErrorGuaranteed, ) -> T
source§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
source§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
source§fn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
impl<'a, T> Captures<'a> for Twhere
T: ?Sized,
impl<T> ErasedDestructor for Twhere
T: 'static,
impl<T> MaybeSendSync for T
Layout§
Note: Unable to compute type layout, possibly due to this type having generic parameters. Layout can only be computed for concrete, fully-instantiated types.