Skip to content
FormalLanguageConstrainedPathQueryingPublic
forked from SVF-tools/SVF

About

Static Value-Flow Analysis Framework for Source Code

Resources

Stars

0 stars

Watchers

0 watching

Forks

 
 

Repository files navigation

Note

This is a fork of SVF-tools/SVF implementing a linear-algebra-based CFL reachability solver.

  • Status: Pending merge into the main repository (see PR #XXX).
  • Branch goal: Demonstrate the performance gains and benchmarks of the new method.
  • The original project documentation is below.

Linear-Algebra-Based CFL Reachability Solver

TL;DR

Replaces the standard worklist-based CFL reachability algorithm with a Boolean-matrix (linear algebra) formulation solved by LAGraph. On potential-aliasing analysis over 19 open-source projects (SPEC CPU 2017 + Phoronix Test Suite), the advanced matrix solver (AdvMTXSolver) is the fastest on every program and grammar: up to ~17× per-program speedup (up to ~194× per module) over the classic worklist baseline, up to ~12× per program (~5× on average) over the state-of-the-art POCR algorithm, and 1.1–3.1× lower peak memory (up to ~12× per module). The advanced solver realizes the algorithm of Muravev & Grigorev, STTT 2026 on top of the matrix CFL reachability of Azimov & Grigorev (GRADES/NDA 2018); both matrix CFL reachability algorithms are implemented by Ilkhom Kombaev in the LAGraph fork (tag homka122/CFL_optimizations). POCR and POCRHybrid implement Lei et al., OOPSLA 2022.

Quickstart

source ./build.sh
./build/bin/cfl --adv-mtx-alias program.bc

All new flags default to off — existing behavior is unchanged. New CLI options:

Flag Description Default
--mtx-alias Use the matrix-based CFL solver off
--adv-mtx-alias Use the advanced matrix-based CFL solver off
--adv-mtx-optimizations=<mask> LAGraph optimization bitmask: 1=empty, 2=format, 4=lazy, 8=block 7
--mtx-only-starting Copy back only start-nonterminal edges from the matrix result on

How it works

Both solvers express CFL reachability as a closure over Boolean matrices: the grammar is converted to (extended) weak Chomsky normal form, each terminal becomes an adjacency matrix, and the fixed point is computed with sparse matrix multiplication (SuiteSparse:GraphBLAS). MTXSolver implements the base algorithm of Azimov & Grigorev; AdvMTXSolver adds the optimizations of Muravev & Grigorev — incremental computation, storage-format management, lazy matrix addition, and block multiplication for indexed rule families — via the LAGraph fork.

Two solvers are provided, selectable via CLI flags:

Solver Class Backend call Notes
Matrix MTXSolver LAGraph_CFL_reachability Direct port of the standard matrix algorithm
Advanced matrix AdvMTXSolver LAGraph_CFL_reachability_adv Adds LAGraph optimization bitmask; requires a uniformly indexed grammar

Implementation: svf/include/CFL/CFLSolver.h · svf/lib/CFL/CFLAlias.cpp · svf-llvm/tools/CFL/cfl.cpp

Limitations. AdvMTXSolver requires uniformly indexed grammar rules: consecutive instance numbering, identical index sets for all indexed symbols within a rule, and complete rule families (it aborts otherwise). Non-conforming grammars can be expanded explicitly (semantics preserved) but lose the block optimization. Incremental updates re-run the full matrix solve.

Correctness. Verified in isolation: for identical input graphs and grammars, the matrix solvers return the same reachable pairs as the built-in solvers.

Benchmarks

Test environment

Component Specification
OS Ubuntu 24.04
CPU Intel Core i9-13905H (14 cores / 20 threads)
RAM 32 GB
LLVM <STUB: version>

Dataset

19 open-source projects (20 benchmark configurations) from SPEC CPU 2017 and the Phoronix Test Suite: a compiler, an archiver, 3D renderers, video codecs, and telecom protocol stacks. Each project is compiled to LLVM IR (clang -save-temps), mem2reg is applied via opt, and each IR file is analyzed as a separate unit. CFL graph sizes per project:

Project Source Files Median vertices Max vertices Median edges Max edges
povray POV-Ray/povray 69 1739 7696 3174 37756
blender blender/blender 732 1469.5 23821 2639 79074
srsRAN srsran/srsRAN 12 3432.5 10552 6614 19840
srsRAN_4G srsran/srsRAN_4G (formerly srsLTE) 52 2922 7855 5656 14986
gcc_r gcc-mirror/gcc 174 2079 7922 4954 353704
x264 mirror/x264 50 1751.5 22652 3485 79572
nab SPEC CPU 2017 544.nab_r (source not public) 7 3428 4815 7856 88436
xz tukaani-project/xz 6 1467 3051 3455 7554
SVT-AV1 AOMediaCodec/SVT-AV1 72 3236.5 25620 6892 174638
SVT-HEVC OpenVisualCloud/SVT-HEVC 22 3478 9354 5042 32880
SVT-VP9 OpenVisualCloud/SVT-VP9 10 5420 10514 9402 22488
aom aomedia/aom 97 2752 16996 6256 36090
kvazaar ultravideo/kvazaar 4 5090 5179 10806 12656
dav1d videolan/dav1d 4 3424 4891 7060 9576
ffmpeg FFmpeg/FFmpeg 1264 727.5 36228 1298 84284
libgav chromium/libgav1 30 2693 7394 5036 16268
openapv AcademySoftwareFoundation/openapv 3 2626 4268 5428 8360
uvg266 ultravideo/uvg266 16 3521.5 15780 7570 36834
vvenc fraunhoferhhi/vvenc 46 2753.5 7469 7014 17430
x265 Multicorewareinc/x265 15 4850 14552 9310 22784

Methodology

Two SVF grammars for the potential-aliasing problem: copy-grammar (direct dataflow only) and mem-grammar (+ memory-mediated flow). Metrics: CFL algorithm runtime and peak RSS (/usr/bin/time -v, 32 GB cap). All modules are included (no time filter); per-file values in evaluation_raw_data/RESULTS.md. The graph solvers (baseline, POCR, POCRHybrid) are single-threaded and pinned to one core (taskset -c 0); the matrix solvers run multithreaded via SuiteSparse:GraphBLAS on all 20 cores. Values are geometric means over modules per program.

Results

Analysis. AdvMTX is the fastest solver on every program and grammar, beating both POCR variants on all of them (up to ~12× per program, ~5× on average vs POCRHybrid). The base MTX solver is faster than the worklist baseline on the copy-grammar but not consistently on the mem-grammar, and does not consistently beat POCR/POCRHybrid. The effect of the optimizations is input-dependent: the AdvMTX/MTX gap varies widely across programs and grammars. Both matrix solvers use less peak memory than the graph solvers; AdvMTX uses slightly less than MTX. Overall: up to ~17× per-program speedup and 1.1–3.1× lower peak memory.

Detailed per-file results (all modules, both grammars): evaluation_raw_data/RESULTS.md

Reproducing

./scripts/benchmark.sh   # <STUB: script to be added; runs all three solvers over the suite, prints the table above>

Manual run on a single program:

source ./build.sh
./build/bin/cfl --cfl-alias-measure-algo-runtime program.bc                        # baseline
./build/bin/cfl --mtx-alias --cfl-alias-measure-algo-runtime program.bc            # matrix
./build/bin/cfl --adv-mtx-alias --cfl-alias-measure-algo-runtime program.bc        # advanced matrix

Visualization

Per-benchmark results from the evaluation run (all five solvers; per-file data in evaluation_raw_data/RESULTS.md).

Per-file runtime distribution (violin, log scale)

copy-grammar (PEG) mem-grammar (PAG)

Speedup vs baseline (geometric mean over modules)

copy-grammar (PEG) mem-grammar (PAG)

Total runtime (sum over modules)

copy-grammar (PEG) mem-grammar (PAG)

Speedup vs baseline (total time)

copy-grammar (PEG) mem-grammar (PAG)

Per-file peak memory distribution (violin)

copy-grammar (PEG) mem-grammar (PAG)

Memory improvement vs baseline (> 1 = less memory)

copy-grammar (PEG) mem-grammar (PAG)

Geometric-mean peak memory

copy-grammar (PEG) mem-grammar (PAG)


SVF provides reusable abstractions, graphs, and solvers for analyzing LLVM IR.

News

  • MSli, an on-demand program slicing tool for multithreaded programs, is now available in SVF/MTA.
  • SVF now supports LLVM-22 (Contributed by Giorgio).
  • SVF now supports LLVM-21 (Contributed by cjsrxzdyzds).
  • SVF now supports new build system (Thank Johannes for his help!).
  • SVF-Python is now available, enabling developers to write static analyzers in Python by leveraging the SVF library (Contributed by Jiawei Wang).
  • New course Software Security Analysis for learning code analysis and verification with SVF for fun and expertise!
  • SVF now supports LLVM-16.0.0 with opaque pointers (Contributed by Xiao Cheng).
  • Modernize SVF's CMake (Contributed by Johannes).
Older news

Documentation

About SVF Setup Guide User Guide Developer Guide
About Setup User Developer
Introducing SVF -- what it does and how we design it A step by step setup guide to build SVF Command-line options to run SVF, get analysis outputs, and test SVF with an example or PTABen Detailed technical documentation and how to write your own analyses in SVF or use SVF as a lib for your tool, and the course on SVF

SVF's doxygen document is available here.

Features and Publications

SVF (CC'16) is able to perform

  • AE (abstract execution): cross-domain execution (ICSE'24), selective widening (OOPSLA'25), recursion analysis (ECOOP'25), typestate analysis (FSE'24);
  • WPA (whole program analysis): field-sensitive (SAS'19), flow-sensitive (CGO'21, OOPSLA'21) analysis;
  • DDA (demand-driven analysis): flow-sensitive, context-sensitive points-to analysis (FSE'16, TSE'18);
  • MSSA (memory SSA form construction): memory regions, side-effects, SSA form (JSS'18);
  • SABER (memory error checking): memory leaks and double-frees (ISSTA'12, TSE'14, ICSE'18);
  • MTA (analysis of multithreaded programs): value-flows for multithreaded programs (CGO'16), on-demand program slicing (ISSTA'26);
  • CFL (context-free-reachability analysis): standard CFL solver, graph and grammar (OOPSLA'22, PLDI'23);
  • SVFIR and MemoryModel (SVFIR): SVFIR, memory abstraction and points-to data structure (SAS'21);
  • Graphs: generating a variety of graphs, including call graph, ICFG, class hierarchy graph, constraint graph, value-flow graph for static analyses and code embedding (OOPSLA'20, TOSEM'21)

We release the SVF source code with the hope of benefiting the open-source community. If you find SVF helpful, please kindly acknowledge the use of the tool or the relevant publications above.

About

Static Value-Flow Analysis Framework for Source Code

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages