一句话:提出按需代数程序分析算法,借助控制流与调用图稀疏性,预处理后每次查询仅需 O(k)。
代数程序分析(APA)将程序摘要建模为正则代数元素,常用于数据流分析、终止性分析与不变式生成等静态分析任务。经典 APA 对单个或同起点查询需 O(n·α(n)·k),而按需场景需回答大量在线 (s,t) 查询,逐次分析代价高昂。本文提出一系列按需 APA 算法:先以 O(n·lg n·k) 轻量预处理,再利用真实程序控制流图的树状结构、有界树宽与嵌套深度,以及调用图相对程序规模较小的树深等稀疏性,将每次查询降至 O(k),即仅需常数次代数操作。实验表明该方法有效且相比经典 APA 快若干数量级。
Algebraic Program Analysis (APA) is a ubiquitous framework that has been employed as a unifying model for various problems in data-flow analysis, termination analysis, invariant generation, predicate abstraction and a wide variety of other standard static analysis tasks. APA models program summaries as elements of a regular algebra . Suppose that a summary inAis assigned to every transition of the program and that we aim to compute the effect of running the program starting at linesand ending at linet. APA first computes a regular expression capturing all program paths of interest. In case of intraprocedural analysis, models all paths fromstot, whereas in the interprocedural case it models all interprocedurally-valid paths, i.e. paths that go back to the right caller function when a callee returns. This regular expression is then interpreted over the algebra to obtain the desired result. Suppose the program hasnlines of code and each evaluation of an operation in the regular algebra takesO(k) time. It is well-known that a single APA query, or a set of queries with the same starting points, can be answered inO(n· α(n) ·k), where α is the inverse Ackermann function. In this work, we consider an on-demand setting for APA: the program is given in the input and can be preprocessed. The analysis has to then answer a large number of on-line queries, each providing a pair (s,t) of program lines which are the start and end point of the query, respectively. The goal is to avoid the significant cost of running a fresh APA instance for each query. Our main contribution is a series of algorithms that, after a lightweight preprocessing ofO(n· lgn·k), answer each query inO(k) time. In other words, our preprocessing has almost the same asymptotic complexity as a single APA query, except for a sub-logarithmic factor, and then every future query is answered instantly, i.e. by a constant number of operations in the algebra. We achieve this remarkable speedup by relying on certain structural sparsity properties of control-flow and call graphs (CFGs and CGs). Specifically, we exploit the fact that control-flow graphs of real-world programs have a tree-like structure and bounded treewidth and nesting depth and that their call graphs have small treedepth in comparison to the size of the program. Finally, we provide experimental results demonstrating the effectiveness and efficiency of our approach and showing that it beats the runtime of classical APA by several orders of magnitude.
@article{paperbot1886,
title = {Exploiting the Sparseness of Control-Flow and Call Graphs for Efficient and On-Demand Algebraic Program Analysis},
author = {Giovanna Kobus Conrado and Amir Kafshdar Goharshady and Kerim Kochekov and Yun Chen Tsai and Ahmed Khaled Zaher},
journal = {Proceedings of the ACM on Programming Languages},
volume = {7},
number = {OOPSLA2},
year = {2023},
doi = {10.1145/3622868}
}