Struct rustc_mir_dataflow::value_analysis::Map
source · pub struct Map {
locals: IndexVec<Local, Option<PlaceIndex>>,
projections: FxHashMap<(PlaceIndex, TrackElem), PlaceIndex>,
places: IndexVec<PlaceIndex, PlaceInfo>,
value_count: usize,
}
Expand description
Partial mapping from Place
to PlaceIndex
, where some places also have a ValueIndex
.
This data structure essentially maintains a tree of places and their projections. Some additional bookkeeping is done, to speed up traversal over this tree:
- For iteration, every
PlaceInfo
contains an intrusive linked list of its children. - To directly get the child for a specific projection, there is a
projections
map.
Fields§
§locals: IndexVec<Local, Option<PlaceIndex>>
§projections: FxHashMap<(PlaceIndex, TrackElem), PlaceIndex>
§places: IndexVec<PlaceIndex, PlaceInfo>
§value_count: usize
Implementations§
source§impl Map
impl Map
fn new() -> Self
sourcepub fn from_filter<'tcx>(
tcx: TyCtxt<'tcx>,
body: &Body<'tcx>,
filter: impl FnMut(Ty<'tcx>) -> bool
) -> Self
pub fn from_filter<'tcx>(
tcx: TyCtxt<'tcx>,
body: &Body<'tcx>,
filter: impl FnMut(Ty<'tcx>) -> bool
) -> Self
Returns a map that only tracks places whose type passes the filter.
This is currently the only way to create a Map
. The way in which the tracked places are
chosen is an implementation detail and may not be relied upon (other than that their type
passes the filter).
sourcefn register_with_filter<'tcx>(
&mut self,
tcx: TyCtxt<'tcx>,
body: &Body<'tcx>,
filter: impl FnMut(Ty<'tcx>) -> bool,
exclude: &IndexVec<Local, bool>
)
fn register_with_filter<'tcx>(
&mut self,
tcx: TyCtxt<'tcx>,
body: &Body<'tcx>,
filter: impl FnMut(Ty<'tcx>) -> bool,
exclude: &IndexVec<Local, bool>
)
Register all non-excluded places that pass the filter.
sourcefn register_with_filter_rec<'tcx>(
&mut self,
tcx: TyCtxt<'tcx>,
local: Local,
projection: &mut Vec<PlaceElem<'tcx>>,
ty: Ty<'tcx>,
filter: &mut impl FnMut(Ty<'tcx>) -> bool
)
fn register_with_filter_rec<'tcx>(
&mut self,
tcx: TyCtxt<'tcx>,
local: Local,
projection: &mut Vec<PlaceElem<'tcx>>,
ty: Ty<'tcx>,
filter: &mut impl FnMut(Ty<'tcx>) -> bool
)
Potentially register the (local, projection) place and its fields, recursively.
Invariant: The projection must only contain fields.
sourcefn make_place<'tcx>(
&mut self,
local: Local,
projection: &[PlaceElem<'tcx>]
) -> Result<PlaceIndex, ()>
fn make_place<'tcx>(
&mut self,
local: Local,
projection: &[PlaceElem<'tcx>]
) -> Result<PlaceIndex, ()>
Tries to add the place to the map, without allocating a value slot.
Can fail if the projection contains non-trackable elements.
sourcepub fn tracked_places(&self) -> usize
pub fn tracked_places(&self) -> usize
Returns the number of tracked places, i.e., those for which a value can be stored.
sourcepub fn apply(&self, place: PlaceIndex, elem: TrackElem) -> Option<PlaceIndex>
pub fn apply(&self, place: PlaceIndex, elem: TrackElem) -> Option<PlaceIndex>
Applies a single projection element, yielding the corresponding child.
sourcepub fn find(&self, place: PlaceRef<'_>) -> Option<PlaceIndex>
pub fn find(&self, place: PlaceRef<'_>) -> Option<PlaceIndex>
Locates the given place, if it exists in the tree.
sourcepub fn children(
&self,
parent: PlaceIndex
) -> impl Iterator<Item = PlaceIndex> + '_
pub fn children(
&self,
parent: PlaceIndex
) -> impl Iterator<Item = PlaceIndex> + '_
Iterate over all direct children.
sourcepub fn preorder_invoke(&self, root: PlaceIndex, f: &mut impl FnMut(PlaceIndex))
pub fn preorder_invoke(&self, root: PlaceIndex, f: &mut impl FnMut(PlaceIndex))
Invoke a function on the given place and all descendants.
Trait Implementations§
Auto Trait Implementations§
impl RefUnwindSafe for Map
impl Send for Map
impl Sync for Map
impl Unpin for Map
impl UnwindSafe for Map
Blanket Implementations§
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: 88 bytes