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: usizeTraversal 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: SpanImplementations§
Source§impl<'tcx> AliasGraph<'tcx>
impl<'tcx> AliasGraph<'tcx>
pub fn alias_bb(&mut self, bb_index: usize)
pub fn alias_bbcall( &mut self, bb_index: usize, fn_map: &mut MopFnAliasMap, recursion_set: &mut HashSet<DefId>, )
pub fn projection(&mut self, place: Place<'tcx>) -> usize
Sourcepub fn assign_alias(&mut self, lv_idx: usize, rv_idx: usize)
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.
pub fn sync_field_alias( &mut self, lv: usize, rv: usize, depth: usize, clear_left: bool, )
pub fn sync_father_alias( &mut self, lv: usize, rv: usize, lv_alias_set_idx: usize, )
pub fn handle_fn_alias(&mut self, fn_alias: &MopAliasPair, arg_vec: &[usize])
pub fn get_field_seq(&self, value: &Value) -> Vec<usize>
Sourcefn is_valid_field(&self, local: usize, field_seq: &[usize]) -> bool
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.
pub fn merge_results(&mut self)
Sourcepub fn compress_aliases(&mut self)
pub fn compress_aliases(&mut self)
Compresses the alias analysis results with a two-step procedure:
-
Field Truncation: For each alias fact, any
lhs_fieldsorrhs_fieldsprojection longer than one element is truncated to just its first element (e.g.,1.0.1becomes1.0,1.2.2.0.0becomes1.2). This aggressively flattens all field projections to a single field level. -
Containment Merging: For all pairs of alias facts with the same locals, if both the truncated
lhs_fieldsandrhs_fieldsof 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.
pub fn find_alias_set(&self, e: usize) -> Option<usize>
pub fn is_aliasing(&self, e1: usize, e2: usize) -> bool
fn build_set_index(&self) -> FxHashMap<usize, usize>
fn is_aliasing_indexed( &self, e1: usize, e2: usize, index: &FxHashMap<usize, usize>, ) -> bool
pub fn merge_alias(&mut self, e1: usize, e2: usize)
pub fn get_alias_set(&mut self, e: usize) -> Option<FxHashSet<usize>>
Source§impl<'tcx> AliasGraph<'tcx>
impl<'tcx> AliasGraph<'tcx>
pub fn new(tcx: TyCtxt<'tcx>, def_id: DefId) -> AliasGraph<'tcx>
pub fn from_path_graph( tcx: TyCtxt<'tcx>, def_id: DefId, path_graph: PathGraph<'tcx>, ) -> AliasGraph<'tcx>
pub fn def_id(&self) -> DefId
pub fn tcx(&self) -> TyCtxt<'tcx>
pub fn arg_size(&self) -> usize
pub fn span(&self) -> Span
pub fn cfg_block(&self, index: usize) -> &CfgBlock
Sourcepub fn terminator(&self, index: usize) -> Option<&Terminator<'tcx>>
pub fn terminator(&self, index: usize) -> Option<&Terminator<'tcx>>
Retrieve the MIR terminator for the block at index on demand.
pub fn find_scc(&mut self)
pub fn enumerate_paths(&self) -> PathTree
pub fn visit_times(&self) -> usize
pub fn increment_visit_times(&mut self) -> usize
Source§impl<'tcx> AliasGraph<'tcx>
impl<'tcx> AliasGraph<'tcx>
fn snapshot_state(&self) -> MopStateSnapshot
fn restore_state(&mut self, snapshot: &MopStateSnapshot)
Sourcepub fn process_function_paths(
&mut self,
fn_map: &mut MopFnAliasMap,
recursion_set: &mut HashSet<DefId>,
)
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.
Sourcepub fn process_function_paths_opt(
&mut self,
precomputed_paths: Option<PathTree>,
fn_map: &mut MopFnAliasMap,
recursion_set: &mut HashSet<DefId>,
)
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.
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>
impl<'tcx> Clone for AliasGraph<'tcx>
Source§fn clone(&self) -> AliasGraph<'tcx>
fn clone(&self) -> AliasGraph<'tcx>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto 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> 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§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 more