Abstract
Static analysis of array-manipulating programs is traditionally hampered by the "array problem": the computational cost of tracking mutable elements accessed via computed indices. This paper introduces Array Content Graphs, a novel abstract domain that tracks properties of array segments using a partial-order approach. By avoiding the exponential "partitioning explosion" of previous methods, this approach achieves significant speedups while maintaining high precision for complex code.
The Challenge of Array Analysis
In static analysis, proving properties of code without execution requires a balance between precision and performance. Simple "Array Smashing" treats an entire array as one variable, losing detail. More precise "Array Partitioning" splits arrays into symbolic segments (e.g., from index $0$ to $i$). However, these methods typically require a total ordering of all index variables.
As shown in Figure 1, even a simple loop involves multiple index relationships. If a program has $m$ index variables, there are $m!$ possible total orderings. This leads to a "partitioning explosion" where the number of states to track grows factorially, making the analysis of complex loops prohibitively slow.
Methods: Array Content Graphs
The authors propose a Graph-Based Array Content Domain. Instead of pre-calculating every possible total ordering, the system represents the array as a graph where nodes are index expressions (e.g., $0, N, i, i+1$) and edges represent properties holding for the segment between them.
As illustrated in Figure 5, the domain uses a matrix $\Psi$ to track relationships between indices. Key features include:
- Partial Order: The system only maintains observed relationships, staying "undecided" about the relative order of indices until necessary. This avoids the combinatorial explosion of total orderings.
- Strong Updates: By identifying "singleton" segments (ranges of exactly one element, like $[i, i+1)$), the analyzer can definitively overwrite values, preserving precision compared to weak updates.
- Normalization: A shortest-path-style algorithm propagates information across segments. If properties hold for $[i, j)$ and $[j, k)$, the system automatically infers what holds for the combined range $[i, k)$.
Evaluation and Results
The prototype tool, sparcolyzer, was evaluated on a suite of array-manipulation benchmarks, including standard algorithms like init, copy, and arraymax, as well as complex Quicksort variants.
- Scalability: On the synthetic
init_rand_mbenchmark, traditional methods saw states jump from 6 to over 27,000 as the number of index variables ($m$) increased from 1 to 5. The graph-based approach handled this with near-linear growth. - Performance: For the
init_rand_5benchmark, the "sparse" graph approach finished in 4.96 seconds, whereas naive implementations took over 80 seconds. - Precision: Despite the speedups, the tool successfully proved complex invariants for Quicksort partitioning, matching the precision of much slower state-of-the-art tools.
Conclusion and Future Work
By leveraging a partial-order graph representation, this research provides a scalable solution to the array partitioning problem. While the current approach struggles with some disjunctive reasoning (either-or scenarios), future optimizations such as integrating liveness analysis to prune unused variables and applying transitive reduction to the graph structure promise even greater efficiency.
Summary updated