Skip to main content

Module points_to

Module points_to 

Source
Expand description

This module implements a points-to analysis for mutable references.

We use the result of the analysis to insert ghost statements at the points where pointers (ptr(l)) have to be converted to borrows (&mut T). For example, consider the function

โ“˜
fn foo(mut x: i32, mut y: i32, b: bool) {
    let r;
    if b {
        r = &mut x
    } else {
        r = &mut y
    }
}

In the then branch (resp. else) we know r must point to x (resp. y). Thus, during refinement type checking, we give r types ptr(x) and ptr(y) in each branch respectively. However, at the join point, r could point to either x or y so we must find a type that joins the two pointers. We use the result of the analysis to insert a ghost statement at the end of each branch to convert the pointer to a borrow &mut i32{v: ...} and use it as the join.

Re-exportsยง

use std::collections::VecDeque; ๐Ÿ”’
use std::fmt; ๐Ÿ”’
use std::iter; ๐Ÿ”’
use std::ops::Range; ๐Ÿ”’
use flux_common::tracked_span_bug; ๐Ÿ”’
use flux_middle::global_env::GlobalEnv; ๐Ÿ”’
use flux_middle::queries::QueryResult; ๐Ÿ”’
use flux_middle::rty; ๐Ÿ”’
use flux_middle::rty::Loc; ๐Ÿ”’
use flux_middle::rty::Path; ๐Ÿ”’
use rustc_abi::FieldIdx; ๐Ÿ”’
use rustc_hash::FxHashMap; ๐Ÿ”’
use rustc_index::IndexSlice; ๐Ÿ”’
use rustc_index::IndexVec; ๐Ÿ”’
use rustc_index::bit_set::DenseBitSet; ๐Ÿ”’
use rustc_middle::mir; ๐Ÿ”’
use rustc_middle::mir::BasicBlock; ๐Ÿ”’
use rustc_middle::mir::traversal; ๐Ÿ”’
use rustc_middle::mir::visit::Visitor; ๐Ÿ”’
use rustc_middle::ty; ๐Ÿ”’
use rustc_mir_dataflow::Analysis; ๐Ÿ”’
use rustc_mir_dataflow::JoinSemiLattice; ๐Ÿ”’
use rustc_mir_dataflow::ResultsVisitor; ๐Ÿ”’
use rustc_mir_dataflow::fmt::DebugWithContext; ๐Ÿ”’
use rustc_mir_dataflow::lattice::FlatSet; ๐Ÿ”’
use rustc_mir_dataflow::lattice::HasBottom; ๐Ÿ”’
use rustc_mir_dataflow::lattice::HasTop; ๐Ÿ”’
use rustc_mir_dataflow::visit_results; ๐Ÿ”’
use super::GhostStatements; ๐Ÿ”’
use crate::ghost_statements::GhostStatement; ๐Ÿ”’
use crate::ghost_statements::Point; ๐Ÿ”’

Structsยง

Children ๐Ÿ”’
CollectPointerToBorrows ๐Ÿ”’
Map
Partial mapping from Place to PlaceIndex, where some places also have a ValueIndex.
PlaceIndex ๐Ÿ”’
This index uniquely identifies a place.
PlaceInfo ๐Ÿ”’
This is the information tracked for every PlaceIndex and is stored by Map.
PointsToAnalysis ๐Ÿ”’
This implement a points to analysis for mutable references over a [FlatSet]. The analysis is a may analysis. If you want to know if a reference definitively points to a location you have to combine it with the result of a definitely initialized analysis. See module level documentation for more details.
State ๐Ÿ”’
The dataflow state for the PointsToAnalysis.
ValueIndex ๐Ÿ”’
This index uniquely identifies a tracked place and therefore a slot in State.

Enumsยง

PlaceOrValue ๐Ÿ”’
Used as the result for r-value.

Functionsยง

add_ghost_statements ๐Ÿ”’
debug_with_context ๐Ÿ”’
debug_with_context_rec ๐Ÿ”’
excluded_locals ๐Ÿ”’
Returns all locals with projections that have their reference or address taken.