AliasGraph

Struct AliasGraph 

Source
pub struct AliasGraph<'tcx> {
    pub path_graph: PathGraph<'tcx>,
    pub constants: FxHashMap<usize, usize>,
    pub visit_times: usize,
    pub values: Vec<Value>,
    pub block_facts: Vec<AliasBlockFacts<'tcx>>,
    pub alias_sets: Vec<FxHashSet<usize>>,
    pub ret_alias: MopFnAliasPairs,
    pub arg_size: usize,
    pub span: Span,
}

Fields§

§path_graph: PathGraph<'tcx>§constants: FxHashMap<usize, usize>

Path-sensitive state used by alias/safedrop traversal.

§visit_times: usize

Traversal visit counter for recursion limiting.

§values: Vec<Value>§block_facts: Vec<AliasBlockFacts<'tcx>>§alias_sets: Vec<FxHashSet<usize>>§ret_alias: MopFnAliasPairs§arg_size: usize§span: Span

Implementations§

Source§

impl<'tcx> AliasGraph<'tcx>

Source

pub fn alias_bb(&mut self, bb_index: usize)

Source

pub fn alias_bbcall( &mut self, bb_index: usize, fn_map: &mut MopFnAliasMap, recursion_set: &mut HashSet<DefId>, )

Source

pub fn projection(&mut self, place: Place<'tcx>) -> usize

Source

pub fn assign_alias(&mut self, lv_idx: usize, rv_idx: usize)

Used to assign alias for a statement. Operation: dealiasing the left; aliasing the left with right. Synchronize the fields and father nodes iteratively.

Source

pub fn sync_field_alias( &mut self, lv: usize, rv: usize, depth: usize, clear_left: bool, )

Source

pub fn sync_father_alias( &mut self, lv: usize, rv: usize, lv_alias_set_idx: usize, )

Source

pub fn handle_fn_alias(&mut self, fn_alias: &MopAliasPair, arg_vec: &[usize])

Source

pub fn get_field_seq(&self, value: &Value) -> Vec<usize>

Source

fn is_valid_field(&self, local: usize, field_seq: &[usize]) -> bool

Checks whether a sequence of field projections on a local MIR variable is valid. For example, if the type of a local (e.g., 0) has two fields, 0.2 or 0.3 are both invalid.

Source

pub fn merge_results(&mut self)

Source

pub fn compress_aliases(&mut self)

Compresses the alias analysis results with a two-step procedure:

  1. Field Truncation: For each alias fact, any lhs_fields or rhs_fields projection longer than one element is truncated to just its first element (e.g., 1.0.1 becomes 1.0, 1.2.2.0.0 becomes 1.2). This aggressively flattens all field projections to a single field level.

  2. Containment Merging: For all pairs of alias facts with the same locals, if both the truncated lhs_fields and rhs_fields of one are a (strict) prefix of another, only the more general (shorter) alias is kept. For example:

    • Keep (0, 1), remove (0.0, 1.1)
    • But do not merge (0, 1.0) and (0, 1.1), since these have different non-prefix fields.

Call this after constructing the alias set to minimize and canonicalize the result.

Source

pub fn find_alias_set(&self, e: usize) -> Option<usize>

Source

pub fn is_aliasing(&self, e1: usize, e2: usize) -> bool

Source

fn build_set_index(&self) -> FxHashMap<usize, usize>

Source

fn is_aliasing_indexed( &self, e1: usize, e2: usize, index: &FxHashMap<usize, usize>, ) -> bool

Source

pub fn merge_alias(&mut self, e1: usize, e2: usize)

Source

pub fn get_alias_set(&mut self, e: usize) -> Option<FxHashSet<usize>>

Source§

impl<'tcx> AliasGraph<'tcx>

Source

pub fn new(tcx: TyCtxt<'tcx>, def_id: DefId) -> AliasGraph<'tcx>

Source

pub fn from_path_graph( tcx: TyCtxt<'tcx>, def_id: DefId, path_graph: PathGraph<'tcx>, ) -> AliasGraph<'tcx>

Source

pub fn def_id(&self) -> DefId

Source

pub fn tcx(&self) -> TyCtxt<'tcx>

Source

pub fn arg_size(&self) -> usize

Source

pub fn span(&self) -> Span

Source

pub fn cfg_block(&self, index: usize) -> &CfgBlock

Source

pub fn terminator(&self, index: usize) -> Option<&Terminator<'tcx>>

Retrieve the MIR terminator for the block at index on demand.

Source

pub fn find_scc(&mut self)

Source

pub fn enumerate_paths(&self) -> PathTree

Source

pub fn visit_times(&self) -> usize

Source

pub fn increment_visit_times(&mut self) -> usize

Source§

impl<'tcx> AliasGraph<'tcx>

Source

fn snapshot_state(&self) -> MopStateSnapshot

Source

fn restore_state(&mut self, snapshot: &MopStateSnapshot)

Source

pub fn process_function_paths( &mut self, fn_map: &mut MopFnAliasMap, recursion_set: &mut HashSet<DefId>, )

Process pre-enumerated whole-function paths via DFS on the path tree.

Shared prefixes are processed once. State is saved at branch points and restored before processing sibling subtrees, avoiding redundant re-analysis of common path prefixes.

If precomputed_paths is Some, it is used directly instead of re-enumerating from the internal PathGraph. This allows callers that have already cached a PathTree (e.g., via PathAnalyzer) to avoid redundant work.

Source

pub fn process_function_paths_opt( &mut self, precomputed_paths: Option<PathTree>, fn_map: &mut MopFnAliasMap, recursion_set: &mut HashSet<DefId>, )

Like process_function_paths but accepts an optional precomputed PathTree.

Source

fn dfs_mop( &mut self, node: &PathNode, path: &mut Vec<usize>, fn_map: &mut MopFnAliasMap, recursion_set: &mut HashSet<DefId>, ) -> Result<(), ()>

Trait Implementations§

Source§

impl<'tcx> Clone for AliasGraph<'tcx>

Source§

fn clone(&self) -> AliasGraph<'tcx>

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<'tcx> Display for AliasGraph<'tcx>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'tcx> Freeze for AliasGraph<'tcx>

§

impl<'tcx> !RefUnwindSafe for AliasGraph<'tcx>

§

impl<'tcx> !Send for AliasGraph<'tcx>

§

impl<'tcx> !Sync for AliasGraph<'tcx>

§

impl<'tcx> Unpin for AliasGraph<'tcx>

§

impl<'tcx> !UnwindSafe for AliasGraph<'tcx>

Blanket Implementations§

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> 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, dest: *mut u8)

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

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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<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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.
§

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

§

fn vzip(self) -> V

§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,