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.
- Callgraph
Build Scratch - 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_tointo 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.