Skip to main content

Module callgraph

Module callgraph 

Source
Expand description

Call-graph construction with indirect resolution (DF-5).

Build a callgraph propagation Program:

use weir::callgraph::callgraph_build;

let program = callgraph_build("direct", "indirect", "pts", "cg_out");

DF-5 - call graph with indirect dispatch resolution.

Direct calls are trivial - the graph is built during AP-2 lowering. Indirect calls (fnptr tables, vtables, kernel ops-struct dispatch - file_operations, net_proto_ops, proto_ops, etc.) require points-to (DF-3) to resolve the callee set.

The kernel ops-struct pattern is the largest source of false negatives in competing tools. We track every struct literal whose fields are function pointers, index by the struct’s type, and when x->f(...) appears with x : struct T * the callee set is { s.f | s is a struct T literal in the program }.

§Implementation

The final call-graph bitset per call-site is direct ∪ (indirect_sites × points_to_closure). Both operands are bitsets in the CSR-frontier shape we already own, so the kernel is a per-invocation bitwise OR of two loads plus a bounds check.

Soundness: MayOver - may-analysis.

Gate for C19.

Structs§

Callgraph
Marker type for the callgraph dataflow primitive.
CallgraphBuildScratch
Caller-owned staging for repeated callgraph projection dispatches.

Functions§

callgraph_build
Build a single-dispatch Program that OR-merges a direct call-edge bitset with the transitive-closure bitset produced by crate::points_to::andersen_points_to into the final callgraph edge bitset.
callgraph_build_borrowed_into_result_with_scratch_via
GPU callgraph projection using caller-owned staging/output scratch and caller-owned decoded result storage.
callgraph_build_borrowed_into_via
GPU callgraph projection using borrowed dispatch inputs and caller-owned output storage.
callgraph_build_borrowed_via
GPU callgraph projection using borrowed dispatch inputs.
callgraph_build_borrowed_with_scratch_via
GPU callgraph projection using borrowed dispatch inputs and caller-owned staging/output scratch.
callgraph_build_via
callgraph_build_with_count
Version that takes the number of call-site lanes explicitly.