rustc_mir_dataflow::value_analysis

Enum 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§

§

Unreachable

§

Reachable(StateData<V>)

Implementations§

source§

impl<V: Clone + HasBottom> State<V>

source

pub fn new_reachable() -> State<V>

source

pub fn all_bottom(&self) -> bool

source

fn is_reachable(&self) -> bool

source

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.

source

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.

source

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.

source

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.

source

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.

source

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.

source

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.

source

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.

source

pub fn assign( &mut self, target: PlaceRef<'_>, result: ValueOrPlace<V>, map: &Map<'_>, )
where V: HasTop,

Helper method to interpret target = result.

source

pub fn assign_discr( &mut self, target: PlaceRef<'_>, result: ValueOrPlace<V>, map: &Map<'_>, )
where V: HasTop,

Helper method for assignments to a discriminant.

source

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.

source

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.

source

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.

source

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.

source

pub fn get(&self, place: PlaceRef<'_>, map: &Map<'_>) -> V
where V: HasBottom + HasTop,

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.

source

pub fn get_discr(&self, place: PlaceRef<'_>, map: &Map<'_>) -> V
where V: HasBottom + HasTop,

Retrieve the value stored for a place, or ⊤ if it is not tracked.

This method returns ⊥ the current state is unreachable.

source

pub fn get_len(&self, place: PlaceRef<'_>, map: &Map<'_>) -> V
where V: HasBottom + HasTop,

Retrieve the value stored for a place, or ⊤ if it is not tracked.

This method returns ⊥ the current state is unreachable.

source

pub fn get_idx(&self, place: PlaceIndex, map: &Map<'_>) -> V
where V: HasBottom + HasTop,

Retrieve the value stored for a place index, or ⊤ if it is not tracked.

This method returns ⊥ the current state is unreachable.

Trait Implementations§

source§

impl<V: Clone> Clone for State<V>

source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<V: Debug> Debug for State<V>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'tcx, T> DebugWithContext<ValueAnalysisWrapper<T>> for State<T::Value>
where T: ValueAnalysis<'tcx>, T::Value: Debug,

This is used to visualize the dataflow analysis.

source§

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

Print the difference between self and old. Read more
source§

impl<V: JoinSemiLattice + Clone + HasBottom> JoinSemiLattice for State<V>

source§

fn join(&mut self, other: &Self) -> bool

Computes the least upper bound of two elements, storing the result in self and returning true if self has changed. Read more
source§

impl<V: PartialEq> PartialEq for State<V>

source§

fn eq(&self, other: &State<V>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<V: Eq> Eq for State<V>

source§

impl<V> StructuralPartialEq for State<V>

Auto Trait Implementations§

§

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> Aligned for T

source§

const ALIGN: Alignment = _

Alignment of Self.
source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> AnyEq for T
where T: Any + PartialEq,

source§

fn equals(&self, other: &(dyn Any + 'static)) -> bool

source§

fn as_any(&self) -> &(dyn Any + 'static)

source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T, R> CollectAndApply<T, R> for T

source§

fn collect_and_apply<I, F>(iter: I, f: F) -> R
where I: Iterator<Item = T>, F: FnOnce(&[T]) -> R,

Equivalent to f(&iter.collect::<Vec<_>>()).

source§

type Output = R

source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
source§

impl<T> Filterable for T

source§

fn filterable( self, filter_name: &'static str, ) -> RequestFilterDataProvider<T, fn(_: DataRequest<'_>) -> bool>

Creates a filterable data provider with the given name for debugging. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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 more
source§

impl<P> IntoQueryParam<P> for P

source§

impl<T> MaybeResult<T> for T

source§

type Error = !

source§

fn from(_: Result<T, <T as MaybeResult<T>>::Error>) -> T

source§

fn to_result(self) -> Result<T, <T as MaybeResult<T>>::Error>

source§

impl<T> Same for T

source§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

source§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<I, T, U> Upcast<I, U> for T
where U: UpcastFrom<I, T>,

source§

fn upcast(self, interner: I) -> U

source§

impl<I, T> UpcastFrom<I, T> for T

source§

fn upcast_from(from: T, _tcx: I) -> T

source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<Tcx, T> Value<Tcx> for T
where Tcx: DepContext,

source§

default fn from_cycle_error( tcx: Tcx, cycle_error: &CycleError, _guar: ErrorGuaranteed, ) -> T

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

impl<'a, T> Captures<'a> for T
where T: ?Sized,

source§

impl<T> ErasedDestructor for T
where T: 'static,

source§

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.