Skip to main content

PtsGraph

Struct PtsGraph 

Source
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

Source

pub fn new() -> Self

Source

pub fn slot_count(&self) -> usize

Source

pub fn get_slot(&self, idx: usize) -> Option<&Slot>

Source

pub fn get_slot_idx(&self, slot: &Slot) -> Option<usize>

Source

pub fn may_drop(&self, idx: usize) -> bool

Source

pub fn need_drop(&self, idx: usize) -> bool

Source

pub fn ensure_slot( &mut self, slot: Slot, may_drop: bool, need_drop: bool, ) -> usize

Source

pub fn set_slot_kind(&mut self, idx: usize, kind: ValueKind)

Source

pub fn slot_kind(&self, idx: usize) -> ValueKind

Source

pub fn slot_is_ptr(&self, idx: usize) -> bool

Source

pub fn slot_is_ref_count(&self, idx: usize) -> bool

Source

pub fn direct_pointees(&self, idx: usize) -> impl Iterator<Item = &AbstractLoc>

Return the direct pointee targets for a slot (non-transitive).

Source

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.

Source

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 dest from its old alias partition (other members stay)
  • Put dest into src’s alias partition
  • Also propagate to field slots.
Source

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

Source

fn propagate_to_father(&mut self, a_idx: usize, b_idx: usize)

Source

fn father_of(&self, idx: usize) -> Option<usize>

Source

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.

Source

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.

Source

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:

  1. Alias partition check (value-equivalence via assignments)
  2. Points-to intersection (pointer-level aliasing)
Source

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, …]

Source

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.

Source

fn alias_find(&self, idx: usize) -> usize

Find the representative of idx’s alias partition.

Source

fn alias_union(&mut self, a: usize, b: usize)

Union two alias partitions.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn resolve_place(&self, place: &PlaceKey) -> PlaceKey

Transitive points-to resolution with overlap semantics and loop detection.

Source

pub fn place_edges(&self) -> Vec<(PlaceKey, PlaceKey)>

Return all PlaceKey-based points-to edges.

Source

fn place_key_to_slot(pk: &PlaceKey) -> Slot

Source

fn slot_to_place_key(slot: &Slot) -> PlaceKey

Trait Implementations§

Source§

impl Clone for PtsGraph

Source§

fn clone(&self) -> PtsGraph

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for PtsGraph

Source§

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

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

impl Default for PtsGraph

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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