MopGraph

Struct MopGraph 

Source
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>

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

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> MopGraph<'tcx>

Source

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

Source

pub fn dfs_on_spanning_tree( &self, _index: usize, _stack: &mut Vec<usize>, _paths: &mut Vec<Vec<usize>>, )

Source

pub fn get_paths(&self) -> Vec<Vec<usize>>

Source

pub fn get_all_branch_sub_blocks_paths(&self) -> Vec<Vec<usize>>

Source

pub fn get_branch_sub_blocks_for_path(&self, path: &[usize]) -> Vec<usize>

Source§

impl<'tcx> MopGraph<'tcx>

Source

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

Source

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>, )

Source

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

Source

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

Source

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

Source

pub fn handle_nexts( &mut self, bb_idx: usize, fn_map: &mut MopFnAliasMap, path_constraints: Option<&FxHashMap<usize, usize>>, recursion_set: &mut HashSet<DefId>, )

Source

pub fn sort_scc_tree(&mut self, scc: &SccInfo) -> SccTree

Source

pub fn find_scc_paths( &mut self, start: usize, scc_tree: &SccTree, path_constraints: &mut FxHashMap<usize, usize>, ) -> Vec<(Vec<usize>, FxHashMap<usize, usize>)>

Source

fn find_scc_paths_inner( &mut self, start: usize, cur: usize, scc_tree: &SccTree, path: &mut Vec<usize>, path_constraints: &mut FxHashMap<usize, usize>, paths_in_scc: &mut Vec<(Vec<usize>, FxHashMap<usize, usize>)>, scc_path_set: &mut HashSet<Vec<usize>>, )

Source

fn handle_switch_int_case( &mut self, start: usize, _cur: usize, path: &mut Vec<usize>, scc_tree: &SccTree, path_constraints: &mut FxHashMap<usize, usize>, paths_in_scc: &mut Vec<(Vec<usize>, FxHashMap<usize, usize>)>, discr: &Operand<'tcx>, targets: &SwitchTargets, scc_path_set: &mut HashSet<Vec<usize>>, )

Trait Implementations§

Source§

impl<'tcx> Clone for MopGraph<'tcx>

Source§

fn clone(&self) -> MopGraph<'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 MopGraph<'tcx>

Source§

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

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

impl<'tcx> Scc for MopGraph<'tcx>

Source§

fn on_scc_found(&mut self, root: usize, scc_components: &[usize])

Source§

fn get_next(&mut self, root: usize) -> FxHashSet<usize>

Source§

fn get_size(&mut self) -> usize

Source§

fn find_scc(&mut self)

Source§

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, )

Source§

impl<'tcx> SccHelper<'tcx> for MopGraph<'tcx>

Source§

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

Source§

fn defid(&self) -> DefId

Source§

fn blocks(&self) -> &Vec<Block<'tcx>>

Source§

fn blocks_mut(&mut self) -> &mut Vec<Block<'tcx>>

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