pub struct MopGraph<'tcx> {
pub def_id: DefId,
pub tcx: TyCtxt<'tcx>,
pub arg_size: usize,
pub span: Span,
pub values: Vec<Value>,
pub blocks: Vec<Block<'tcx>>,
pub constants: FxHashMap<usize, usize>,
pub discriminants: FxHashMap<usize, usize>,
pub visit_times: usize,
pub alias_sets: Vec<FxHashSet<usize>>,
pub ret_alias: MopFnAliasPairs,
pub terminators: Vec<TerminatorKind<'tcx>>,
}Fields§
§def_id: DefId§tcx: TyCtxt<'tcx>§arg_size: usize§span: Span§values: Vec<Value>§blocks: Vec<Block<'tcx>>§constants: FxHashMap<usize, usize>§discriminants: FxHashMap<usize, usize>§visit_times: usize§alias_sets: Vec<FxHashSet<usize>>§ret_alias: MopFnAliasPairs§terminators: Vec<TerminatorKind<'tcx>>Implementations§
Source§impl<'tcx> MopGraph<'tcx>
impl<'tcx> MopGraph<'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
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> MopGraph<'tcx>
impl<'tcx> MopGraph<'tcx>
pub fn new(tcx: TyCtxt<'tcx>, def_id: DefId) -> MopGraph<'tcx>
pub fn dfs_on_spanning_tree( &self, _index: usize, _stack: &mut Vec<usize>, _paths: &mut Vec<Vec<usize>>, )
pub fn get_paths(&self) -> Vec<Vec<usize>>
pub fn get_all_branch_sub_blocks_paths(&self) -> Vec<Vec<usize>>
pub fn get_branch_sub_blocks_for_path(&self, path: &[usize]) -> Vec<usize>
Source§impl<'tcx> MopGraph<'tcx>
impl<'tcx> MopGraph<'tcx>
fn switch_target_for_value( &self, targets: &SwitchTargets, value: usize, ) -> usize
fn unique_otherwise_switch_value( &self, discr: &Operand<'tcx>, targets: &SwitchTargets, ) -> Option<usize>
fn record_scc_exit_path( &self, scc: &SccInfo, node: usize, constraints: &FxHashMap<usize, usize>, cur_path: &Vec<usize>, out: &mut Vec<(Vec<usize>, FxHashMap<usize, usize>)>, seen_paths: &mut FxHashSet<PathKey>, )
fn possible_switch_values_for_constraint_id( &self, discr_local: usize, ) -> Option<Vec<usize>>
pub fn split_check( &mut self, bb_idx: usize, fn_map: &mut MopFnAliasMap, recursion_set: &mut HashSet<DefId>, )
pub fn split_check_with_cond( &mut self, bb_idx: usize, path_discr_id: usize, path_discr_val: usize, fn_map: &mut MopFnAliasMap, recursion_set: &mut HashSet<DefId>, )
pub fn check( &mut self, bb_idx: usize, fn_map: &mut MopFnAliasMap, recursion_set: &mut HashSet<DefId>, )
pub fn check_scc( &mut self, bb_idx: usize, fn_map: &mut MopFnAliasMap, recursion_set: &mut HashSet<DefId>, )
pub fn check_single_node( &mut self, bb_idx: usize, fn_map: &mut MopFnAliasMap, recursion_set: &mut HashSet<DefId>, )
pub fn handle_nexts( &mut self, bb_idx: usize, fn_map: &mut MopFnAliasMap, path_constraints: Option<&FxHashMap<usize, usize>>, recursion_set: &mut HashSet<DefId>, )
pub fn sort_scc_tree(&mut self, scc: &SccInfo) -> SccTree
pub fn find_scc_paths( &mut self, start: usize, scc_tree: &SccTree, initial_constraints: &FxHashMap<usize, usize>, ) -> Vec<(Vec<usize>, FxHashMap<usize, usize>)>
fn find_scc_paths_inner( &mut self, start: usize, cur: usize, scc_tree: &SccTree, path: &mut Vec<usize>, path_constraints: FxHashMap<usize, usize>, segment_stack: FxHashSet<usize>, visited_since_enter: FxHashSet<usize>, baseline_at_dominator: FxHashSet<usize>, skip_child_enter: Option<usize>, paths_in_scc: &mut Vec<(Vec<usize>, FxHashMap<usize, usize>)>, seen_paths: &mut FxHashSet<PathKey>, )
Trait Implementations§
Source§impl<'tcx> Scc for MopGraph<'tcx>
impl<'tcx> Scc for MopGraph<'tcx>
fn on_scc_found(&mut self, root: usize, scc_components: &[usize])
fn get_next(&mut self, root: usize) -> FxHashSet<usize>
fn get_size(&mut self) -> usize
fn find_scc(&mut self)
fn tarjan( &mut self, index: usize, stack: &mut Vec<usize>, instack: &mut FxHashSet<usize>, dfn: &mut Vec<usize>, low: &mut Vec<usize>, time: &mut usize, )
Auto Trait Implementations§
impl<'tcx> Freeze for MopGraph<'tcx>
impl<'tcx> !RefUnwindSafe for MopGraph<'tcx>
impl<'tcx> !Send for MopGraph<'tcx>
impl<'tcx> !Sync for MopGraph<'tcx>
impl<'tcx> Unpin for MopGraph<'tcx>
impl<'tcx> !UnwindSafe for MopGraph<'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