Abstract
Static data-flow analysis is essential for software quality but faces a trade-off between slow on-demand queries and memory-intensive full preprocessing. This paper introduces a novel approach for on-demand analysis within the Interprocedural Finite Distributive Subset (IFDS) framework by exploiting the low treewidth property of program flow graphs. By combining tree decomposition with bitwise optimizations ("word tricks"), the proposed algorithms achieve theoretical optimality and near-perfect parallel scalability. Experimental results on the DaCapo benchmark suite demonstrate significant speedups, with parallel execution achieving an 11.3x speedup on 12 threads and successfully processing benchmarks where traditional complete preprocessing methods fail.
Introduction
Static data-flow analysis powers critical tools such as bug-finders and compiler optimizers. However, exhaustive analysis—calculating all data facts for every program point—is often computationally prohibitive. On-demand analysis offers a more targeted alternative, focusing on specific queries (e.g., "Is variable x null at line 10?"). Current on-demand techniques typically struggle with a trade-off: either they lack preprocessing, leading to slow repeated scans, or they require full preprocessing, which suffers from excessive memory consumption and long initial wait times.
This research targets same-context queries within the popular IFDS framework. The goal is a "Goldilocks" solution: a lightweight preprocessing phase that enables lightning-fast, parallelizable queries without the memory explosion associated with traditional exhaustive methods.
Methodology
The core innovation lies in leveraging the treewidth of program flow graphs. Treewidth is a graph-theoretic measure of how closely a graph resembles a tree. Most computer programs, particularly those avoiding complex "goto" structures, exhibit very low treewidth.
Two-Phase Pipeline
The proposed method consists of two main phases:
- Preprocessing (Offline): The program's flow graph is decomposed into a "tree decomposition"—a tree of "bags," where each bag contains a small subset of program locations. Local reachability analysis is performed within these bags. To further optimize, the authors employ "Word Tricks," leveraging bit-level parallelism in modern CPUs to pack multiple data-flow facts into machine words. This allows simultaneous processing of facts using bitwise operations, reducing complexity by a factor of the word size ($W$).
- Querying (Online): Answering a query between two points only requires examining the path between their respective bags in the tree decomposition. This tree structure allows the work to be distributed across multiple CPU cores with virtually zero coordination overhead, achieving "embarrassing parallelizability."
Experimental Evaluation
The algorithms were implemented in C++ and evaluated against 110 instances derived from five classical data-flow problems (Reachability, Liveness, Reaching Definitions, and Uninitialized Variables) using real-world Java programs from the DaCapo benchmark suite. The infrastructure utilized Soot for CFG generation and JTDec for tree decompositions.
Key Results
- Scalability and Efficiency: The preprocessing phase proved significantly more scalable than classical complete preprocessing (CPP). While CPP timed out on 25% of the benchmarks, the treewidth-based approach handled all instances. Memory usage remained proportional to input size, avoiding quadratic space explosion.
- Query Performance: Individual pair queries were resolved in less than a millisecond.
- Parallel Speedup: The parallel implementation (PAR) achieved an 11.3x speedup over the sequential version using 12 threads. This near-linear scaling confirms the algorithm's high degree of parallelizability.
- Optimality: The authors formally proved that for common analyses with a small number of data facts, the algorithm's time and space complexity is theoretically optimal.
Conclusion
By exploiting the low treewidth of program flow graphs, this work provides a highly efficient and parallelizable framework for on-demand data-flow analysis. While currently limited to same-context queries, the approach sets a new standard for performance and scalability in static analysis. Future work will focus on extending these treewidth-based optimizations to interprocedural, non-same-context queries, such as those required for complex taint analysis.
Summary updated