pub struct PtsGraph {
points_to: Vec<FxHashSet<AbstractLoc>>,
value_flow: Vec<FxHashSet<usize>>,
slots: Vec<Slot>,
slot_index: FxHashMap<Slot, usize>,
may_drop: Vec<bool>,
need_drop: Vec<bool>,
slot_kind: Vec<ValueKind>,
alias_parent: Vec<usize>,
}Expand description
Unified points-to and value-flow graph.
Maintains two directed relationship types between slots:
- points_to: the slot holds a pointer/reference into another slot.
Created by
&_x,&raw _x, etc. - value_flow: the slot’s value is a copy of another slot’s value.
Created by
_a = _b(Copy/Move),_a = _b as *const T(Cast), etc.
Alias queries (may_alias) combine:
- Alias partition: value-equivalence through assignments (union-find)
- Points-to intersection: pointer-level aliasing through references
Fields§
§points_to: Vec<FxHashSet<AbstractLoc>>§value_flow: Vec<FxHashSet<usize>>§slots: Vec<Slot>§slot_index: FxHashMap<Slot, usize>§may_drop: Vec<bool>§need_drop: Vec<bool>§slot_kind: Vec<ValueKind>Type classification per slot (RawPtr, Ref, Adt, etc.).
alias_parent: Vec<usize>Alias partition: which slots are value-equivalent (union-find).
alias_parent[i] is the representative of i’s partition,
or i itself if i is the root. None means uninitialized (singleton).
Implementations§
Source§impl PtsGraph
impl PtsGraph
pub fn new() -> Self
pub fn slot_count(&self) -> usize
pub fn get_slot(&self, idx: usize) -> Option<&Slot>
pub fn get_slot_idx(&self, slot: &Slot) -> Option<usize>
pub fn may_drop(&self, idx: usize) -> bool
pub fn need_drop(&self, idx: usize) -> bool
pub fn ensure_slot( &mut self, slot: Slot, may_drop: bool, need_drop: bool, ) -> usize
pub fn set_slot_kind(&mut self, idx: usize, kind: ValueKind)
pub fn slot_kind(&self, idx: usize) -> ValueKind
pub fn slot_is_ptr(&self, idx: usize) -> bool
pub fn slot_is_ref_count(&self, idx: usize) -> bool
Sourcepub fn direct_pointees(&self, idx: usize) -> impl Iterator<Item = &AbstractLoc>
pub fn direct_pointees(&self, idx: usize) -> impl Iterator<Item = &AbstractLoc>
Return the direct pointee targets for a slot (non-transitive).
Sourcepub fn assign_pointee(&mut self, dest_idx: usize, target: AbstractLoc)
pub fn assign_pointee(&mut self, dest_idx: usize, target: AbstractLoc)
Record that dest points to target.
Strong update: clears old points-to info for dest.
Sourcepub fn assign_value(&mut self, dest_idx: usize, src_idx: usize)
pub fn assign_value(&mut self, dest_idx: usize, src_idx: usize)
Record that dest has the same VALUE as src (Copy/Move/Cast).
This is a strong update:
- Remove
destfrom its old alias partition (other members stay) - Put
destintosrc’s alias partition - Also propagate to field slots.
Sourcepub fn merge_equivalence(&mut self, a_idx: usize, b_idx: usize)
pub fn merge_equivalence(&mut self, a_idx: usize, b_idx: usize)
Merge equivalence: the two slots may hold the same pointer.
Both inherit the union of each other’s points-to set.
This is used for inter-procedural aliasing and branch join points.
Also propagates to father slots so SafeDrop can detect aliasing
through the base local (e.g. _v.0 alias ptr → _v alias s).
fn propagate_to_father(&mut self, a_idx: usize, b_idx: usize)
fn father_of(&self, idx: usize) -> Option<usize>
Sourcepub fn conservative_call_merge(&mut self, arg_slots: &[usize])
pub fn conservative_call_merge(&mut self, arg_slots: &[usize])
Conservative merge for unknown-function calls: all pointer-typed args may alias each other and the return value.
Sourcepub fn pts(&self, start_idx: usize) -> FxHashSet<AbstractLoc>
pub fn pts(&self, start_idx: usize) -> FxHashSet<AbstractLoc>
Transitive points-to set: follow value_flow + points_to until
fixpoint. Returns all AbstractLoc reachable from start_idx.
Sourcepub fn may_alias(&self, a_idx: usize, b_idx: usize) -> bool
pub fn may_alias(&self, a_idx: usize, b_idx: usize) -> bool
May-alias check: do the pointed-to memories of a and b overlap?
Combines:
- Alias partition check (value-equivalence via assignments)
- Points-to intersection (pointer-level aliasing)
Sourcepub fn apply_callee_summary(
&mut self,
callee_pairs: &FnAliasPairs,
callee_arg_slots: &[usize],
)
pub fn apply_callee_summary( &mut self, callee_pairs: &FnAliasPairs, callee_arg_slots: &[usize], )
Apply callee’s FnAliasPairs to the graph at a call site.
callee_arg_slots: [ret_dest_idx, arg₀_idx, arg₁_idx, …]
Sourcepub fn fn_alias_pairs(&self, arg_count: usize) -> FnAliasPairs
pub fn fn_alias_pairs(&self, arg_count: usize) -> FnAliasPairs
Compute field-sensitive alias pairs among args (1..=arg_count) + return
value (0). For each pair, checks may_alias() and if true, emits an
AliasPair with the truncated single-level field paths.
Sourcefn alias_find(&self, idx: usize) -> usize
fn alias_find(&self, idx: usize) -> usize
Find the representative of idx’s alias partition.
Sourcefn alias_union(&mut self, a: usize, b: usize)
fn alias_union(&mut self, a: usize, b: usize)
Union two alias partitions.
Sourcefn alias_move_to_partition(&mut self, slot_idx: usize, target_idx: usize)
fn alias_move_to_partition(&mut self, slot_idx: usize, target_idx: usize)
Move slot_idx from its current partition to target_idx’s partition.
This implements the strong-update semantics of MoP’s assign_alias:
the moved slot leaves its old partition behind.
Sourcepub fn reset_partition(&mut self, slot_idx: usize)
pub fn reset_partition(&mut self, slot_idx: usize)
Strong-update: put all slots in slot_idx’s partition into their
own singleton partitions, breaking all alias-equivalence for the
entire partition. Used when a call produces a fresh value that
must not retain any old alias relationships.
Sourcepub fn insert_place_edge(&mut self, pointer: &PlaceKey, source: &PlaceKey)
pub fn insert_place_edge(&mut self, pointer: &PlaceKey, source: &PlaceKey)
Record that pointer place was derived from source place.
Strong-update semantics: clears old points-to info for the pointer.
Sourcepub fn get_place_source(&self, place: &PlaceKey) -> Option<PlaceKey>
pub fn get_place_source(&self, place: &PlaceKey) -> Option<PlaceKey>
Single-step points-to lookup (non-transitive) with overlap semantics. When the exact place has no edge, falls back through field-stripping.
Sourcepub fn resolve_place(&self, place: &PlaceKey) -> PlaceKey
pub fn resolve_place(&self, place: &PlaceKey) -> PlaceKey
Transitive points-to resolution with overlap semantics and loop detection.
Sourcepub fn place_edges(&self) -> Vec<(PlaceKey, PlaceKey)>
pub fn place_edges(&self) -> Vec<(PlaceKey, PlaceKey)>
Return all PlaceKey-based points-to edges.
fn place_key_to_slot(pk: &PlaceKey) -> Slot
fn slot_to_place_key(slot: &Slot) -> PlaceKey
Trait Implementations§
Auto Trait Implementations§
impl DynSend for PtsGraph
impl DynSync for PtsGraph
impl Freeze for PtsGraph
impl RefUnwindSafe for PtsGraph
impl Send for PtsGraph
impl Sync for PtsGraph
impl Unpin for PtsGraph
impl UnsafeUnpin for PtsGraph
impl UnwindSafe for PtsGraph
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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