Struct rustc_mir_dataflow::value_analysis::State
source · pub struct State<V>(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.
Tuple Fields§
§0: StateData<V>
Implementations§
source§impl<V: Clone> State<V>
impl<V: Clone> State<V>
pub fn new(init: V, map: &Map) -> State<V>
pub fn all(&self, f: impl Fn(&V) -> bool) -> 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> JoinSemiLattice for State<V>
impl<V: JoinSemiLattice + Clone> JoinSemiLattice for State<V>
source§impl<V: PartialEq> PartialEq for State<V>
impl<V: PartialEq> PartialEq 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>
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§
§impl<T> AnyEq for T
impl<T> AnyEq for T
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, 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
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.§impl<T> Filterable for T
impl<T> Filterable for T
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<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
§impl<T> Pointable for T
impl<T> Pointable for T
source§impl<'tcx, T> ToPredicate<'tcx, T> for T
impl<'tcx, T> ToPredicate<'tcx, T> for T
fn to_predicate(self, _tcx: TyCtxt<'tcx>) -> 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: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...)
attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 24 bytes