Faster Algorithms for Algebraic Path Properties in RSMs with Constant Treewidth

Krishnendu Chatterjee, Rasmus Ibsen-Jensen, Andreas Pavlogiannis, Prateesh GoyalarXiv 2014

Abstract

Interprocedural program analysis is essential for modern software verification and optimization, yet it remains computationally demanding for large-scale applications. This paper presents a novel framework that achieves significant speedups by exploiting the "constant treewidth" property inherent in most human-written code. By combining tree decomposition with generalized algebraic semirings, the authors provide algorithms that reduce complex path-related queries—such as reachability and shortest paths—to near-constant time after a one-time preprocessing step.

Introduction

Modern static analysis tools rely on interprocedural analysis to detect memory leaks, perform alias analysis, and optimize code across function boundaries. These problems are typically modeled using Recursive State Machines (RSMs), which represent the control flow of programs containing recursion and nested function calls.

Two primary challenges hinder current approaches:

  1. Query Efficiency: While single-source queries are common, real-world tools often require multiple "pair queries" (e.g., determining if two pointers can ever alias). Standard methods are often too slow for repeated use.
  2. Structural Neglect: Most algorithms treat program control-flow graphs (CFGs) as arbitrary networks, ignoring the fact that structured programming constructs (loops, conditionals) result in graphs that are fundamentally tree-like, characterized by a low treewidth.

Methodology: Leveraging Structural Sparsity

The core of the proposed approach is the use of tree decomposition to break down complex program graphs into a tree of "bags" (small sets of nodes). This structural insight allows the authors to apply a dynamic programming approach to solve algebraic path properties using various semirings:

  • Boolean Semiring: For reachability analysis.
  • Tropical Semiring: For shortest path calculations.
  • Viterbi Semiring: For determining the most probable execution paths.
Figure 1: A directed graph (left) and its corresponding tree decomposition (right), where nodes are grouped into small "bags" to simplify path calculations.

The Preprocessing and Query Cycle

The algorithm operates in two phases:

  1. Preprocessing: The tree decomposition is processed bottom-up to summarize "U-shaped paths" (paths contained within a specific subtree). For interprocedural analysis, the RSMDistance algorithm propagates these summaries across function boundaries using a Bellman-Ford-like iteration over the call graph.
  2. Querying: Once preprocessed, the system can answer queries by identifying the lowest common ancestor of two nodes in the tree decomposition and combining their precomputed summaries. This reduces query time to $O(\log n)$ or $O(1)$.

Empirical Evaluation

The researchers validated their framework using the DaCapo benchmark suite, analyzing real-world Java applications like antlr and eclipse. Using the Soot framework, they extracted CFGs and confirmed that even massive programs maintain a remarkably low treewidth (typically between 1 and 4).

Key Results

The theoretical and empirical results demonstrate that structural optimization provides a significant advantage over general-purpose graph algorithms.

Figure 6: Complexity comparison showing the theoretical bounds for preprocessing time, space, and query efficiency achieved by the proposed algorithms.
  • Efficiency Gains: Preprocessing was found to be 1.5x to 4x faster than traditional all-pairs reachability methods.
  • Query Speed: Shortest path queries, which traditionally take $O(n^4)$ time without preprocessing, were answered in linear or constant time.
  • Scalability: By maintaining a space complexity of $O(n \log n)$, the approach remains practical for large codebases where quadratic space requirements would fail.

Conclusion and Future Work

By recognizing that program structure is inherently tree-like, this work provides a unified abstraction for a wide variety of static analysis problems. While current results focus on "same-context" queries (paths starting and ending with an empty call stack), future research aims to extend this to multi-entry/exit components and dynamic graph updates, where the analysis can be incrementally refreshed as code changes.

Summary updated

BibTeX
@misc{chatterjee2014faster,
  author = {Krishnendu Chatterjee and Rasmus Ibsen-Jensen and Andreas Pavlogiannis and Prateesh Goyal},
  title = {{Faster Algorithms for Algebraic Path Properties in RSMs with Constant Treewidth}},
  year = {2014},
  eprint = {1410.7724},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1410.7724},
}
Figure