一句话:提出分阶段求解 CFL 可达性,将文法分解为括号匹配 CFG 与控制/数据流正则文法,大幅加速程序分析。
上下文无关语言可达性(CFL-reachability)是程序分析的基础形式化方法,但求解代价高昂,复杂度接近输入图节点数的次立方。论文提出分阶段求解:将基于 CFL 的分析所用上下文无关文法分解为用于匹配括号(如过程调用/返回、字段存储/加载)的较小 CFG L,以及刻画控制/数据流的正则文法 R。不同于标准算法整体求解两者,该方法分两阶段求解 L 可达性与 R 可达性;L 仍为上下文无关但只涉及少量边,R 可近二次时间高效计算。作者实现求解器 STG,在上下文敏感值流分析与字段敏感别名分析上评估,平均较标准次立方算法分别加速 861.59 倍和 4.1 倍,并使 POCR、PEARL 显著提速。
Context-free language reachability (CFL-reachability) is a fundamental formulation for program analysis with many applications. CFL-reachability analysis is computationally expensive, with a slightly subcubic time complexity concerning the number of nodes in the input graph. This paper proposes staged solving: a new perspective on solving CFL-reachability. Our key observation is that the context-free grammar (CFG) of a CFL-based program analysis can be decomposed into (1) a smaller CFG, L, for matching parentheses, such as procedure calls/returns, field stores/loads, and (2) a regular grammar, R, capturing control/data flows. Instead of solving these two parts monolithically (as in standard algorithms), staged solving solves L-reachability and R-reachability in two distinct stages. In practice, L-reachability, though still context-free, involves only a small subset of edges, while R-reachability can be computed efficiently with close to quadratic complexity relative to the node size of the input graph. We implement our staged CFL-reachability solver, STG, and evaluate it using two clients: context-sensitive value-flow analysis and field-sensitive alias analysis. The empirical results demonstrate that STG achieves speedups of 861.59x and 4.1x for value-flow analysis and alias analysis on average, respectively, over the standard subcubic algorithm. Moreover, we also showcase that staged solving can help to significantly improve the performance of two state-of-the-art solvers, POCR and PEARL, by 74.82x (1.78x) and 37.66x (1.7x) for value-flow (alias) analysis, respectively.