TL;DR
This paper introduces Bebop, a novel path-sensitive interprocedural dataflow analysis engine. Bebop tackles the precision-efficiency trade-off in program analysis by using Binary Decision Diagrams (BDDs) to track correlations between dataflow facts, enabling more accurate analysis of infeasible program paths.
What Problem Does This Paper Address?
Program analysis aims to understand program behavior, but there's a fundamental tension between precision and efficiency. Traditional flow-insensitive analyses are fast but imprecise, while flow-sensitive analyses are more precise by considering statement order but can still be imprecise by assuming all program paths are executable. Path-sensitive analyses aim to improve precision by ruling out infeasible paths based on correlations between dataflow facts. However, naively tracking these correlations can lead to prohibitively high memory and runtime costs. This paper addresses the challenge of building an interprocedural path-sensitive analysis that is both precise and practical.
Methods
The core of Bebop is a reformulation of an existing interprocedural dataflow algorithm (Reps, Horwitz, and Sagiv - RHS) into a more traditional dataflow framework. This reformulated algorithm, called SPrhs, maintains the precision and complexity of the original RHS algorithm but is easier to extend. The key innovation is then to "lift" this SPrhs algorithm to be path-sensitive. This is achieved by using Binary Decision Diagrams (BDDs), a data structure commonly used in model checking. BDDs allow Bebop to compactly represent and manipulate sets of sets of dataflow facts, effectively tracking the correlations needed for path-sensitivity. The analysis is further enabled by translating C programs into "boolean programs," where boolean variables represent dataflow facts, and the analysis is performed on these boolean programs.
Datasets
Not discussed in the paper. The paper focuses on the algorithm and its implementation, using a small example C program for illustration.
Key Insights and Ideas
- Reformulating RHS for Simplicity: The paper shows that the complex RHS algorithm can be expressed as a more standard dataflow analysis, making it more accessible and extensible.
- BDDs for Path-Sensitivity: BDDs are a powerful tool for compactly representing sets of sets of facts, which is crucial for managing the complexity of path-sensitive analysis. This avoids the exponential blow-up that might occur with naive representations.
- Boolean Programs as an Analysis Target: Translating C programs into boolean programs provides a clean and unified way to express dataflow problems for analysis by Bebop. This abstraction hides the complexities of the underlying dataflow engine from the analysis developer.
- Path-Sensitivity for Practical Gains: The paper highlights that path-sensitivity can significantly improve precision, especially in cases like pointer analysis where branch correlations (e.g., checking for NULL) are common and informative.
Key Results
The paper presents a general algorithm for path-sensitive interprocedural finite dataflow analysis. While specific quantitative results on large-scale benchmarks are not detailed, the paper demonstrates the algorithm's capability through an example of pointer NULLness analysis. This analysis, using Bebop, can achieve greater precision than traditional flow-sensitive analyses by correctly identifying that a pointer dereference is safe due to prior NULL checks, whereas a flow-sensitive analysis might incorrectly flag it as a potential issue. The theoretical complexity of the SPrhs algorithm is O(E × D³), and the path-sensitive extension using BDDs is discussed in terms of its potential complexity, noting that BDD size can be exponential in the number of variables.
Limitations and Future Work
The authors acknowledge that the BDDs used in their approach can, in the worst case, grow exponentially in size. They plan to investigate overapproximation techniques to help Bebop scale to larger programs, suggesting that not all analyses require the full power of path-sensitivity. Two specific ideas for overapproximation are:
- Making Bebop a flow-sensitive engine by changing the meet operator to a Cartesian abstraction of set union.
- Exploring the theory of overlapping projections to obtain good overapproximations, potentially guided by information about dependent and independent dataflow facts.
Summary updated