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.