1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
//! DF-6 - backward slicer.
//!
//! Given a sink node `s`, emit the minimal sub-graph that may
//! affect it. Reduces to **reverse** reachability on the merged
//! dependence graph: walk backward from the sink, union-in
//! every predecessor along data dependences (DF-2 reaching, DF-3
//! points-to, DF-5 callgraph) and control dependences
//! (`security::dominator_tree`).
//!
//! # Implementation
//!
//! Reverse-BFS is
//! [`csr_backward_traverse`] applied to the caller-supplied
//! `ProgramGraph`. The caller merges `reach`, `callgraph`, and
//! `dom` into a single CSR before dispatch (dense-OR of three CSRs
//! - a one-kernel fusion via `fuse_programs`). The
//! `edge_kind_mask` channel already supports up to 32 independent
//! edge kinds, so we admit **every** kind with `u32::MAX` - the
//! slicer is intentionally maximal, and false-positives are
//! filtered by the downstream rule.
//!
//! # Soundness
//!
//! [`MayOver`](super::Soundness::MayOver). Rules requiring zero-FP
//! pair this slicer with a sanitizer filter on each edge in the
//! returned slice.
#[cfg(any(test, feature = "cpu-parity"))]
mod oracle;
mod plan;
mod program;
#[cfg(test)]
mod tests;
pub(crate) const OP_ID: &str = "weir::slice";
crate::define_analysis_family! {
family: SliceFamily,
kind: crate::fixed_point_graph::FixedPointAnalysisKind::Slice,
name: "slice_closure",
program_builder: backward_slice,
graph_prep: plan::prepare_slice_graph,
graph_prep_scratch: plan::prepare_slice_graph_with_scratch,
input_buffer: "fin",
output_buffer: "fout",
closure_prefix: slice_closure,
resident_prefix: slice_closure_resident,
word_capacity: "slice_closure",
frontier_output: "slice frontier",
resident_capacity: "slice_closure resident",
resident_output: "slice frontier",
visibility: pub,
}
#[cfg(any(test, feature = "cpu-parity"))]
#[allow(deprecated)]
pub(crate) use oracle::slice_closure_cpu;
pub use plan::{
prepare_slice_graph, prepare_slice_graph_into, prepare_slice_graph_with_scratch,
prepare_slice_plan, prepare_slice_plan_into,
};
#[allow(deprecated)]
pub use program::{backward_slice, backward_slice_with_shape, BackwardSlice};
#[cfg(test)]
use vyre::ir::Program;
#[cfg(test)]
use vyre_primitives::graph::program_graph::ProgramGraphShape;