Data-flow analysis is a general technique used to compute information of interest at different points of a program and is considered to be a cornerstone of static analysis. In this thesis, we consider interprocedural data-flow analysis as formalized by the standard IFDS framework, which can express many widely-used static analyses such as reaching definitions, live variables, and null-pointer. We focus on the well-studied on-demand setting in which queries arrive one-by-one in a stream and each query should be answered as fast as possible. While the classical IFDS algorithm provides a polynomial-time solution to this problem, it is not scalable in practice. Specifically, it either requires a quadratic-time preprocessing phase or takes linear time per query, both of which are untenable for modern huge codebases with hundreds of thousands of lines. Previous works have already shown that parameterizing the problem by the treewidth of the program's control-flow graph is promising and can lead to significant gains in efficiency. Unfortunately, these results were only applicable to the limited special case of same-context queries. In this work, we obtain significant speedups for the general case of on-demand IFDS with queries that are not necessarily same-context. This is achieved by exploiting a new graph sparsity parameter, namely the treedepth of the program's call graph. Our approach is the first to exploit the sparsity of control-flow graphs and call graphs at the same time and parameterize by both treewidth and treedepth. We obtain an algorithm with a linear preprocessing phase that can answer each query in constant time with respect to the input size. Finally, we show experimental results demonstrating that our approach significantly outperforms the classical IFDS and its on-demand variant.
翻译:数据流分析是一种通用技术,用于计算程序不同位置处的感兴趣信息,被视作静态分析的基石。本论文研究由标准IFDS框架形式化的过程间数据流分析,该框架可表述多种广泛使用的静态分析,如到达定义、活跃变量和空指针分析。我们聚焦于已充分研究的按需场景,其中查询以流形式逐个到达,每个查询需尽快响应。经典IFDS算法虽为该问题提供了多项式时间解法,但在实际中缺乏可扩展性。具体而言,它要么需要二次时间的预处理阶段,要么每个查询需线性时间,这对于现代数十万行代码的庞大代码库而言均不可接受。先前工作已表明,以程序控制流图的树宽为参数化该问题具有前景,并能显著提升效率。然而,这些结果仅适用于同上下文查询的有限特例。在本工作中,我们对一般性按需IFDS场景(查询未必同上下文)实现了显著加速。这通过利用新的图稀疏性参数——即程序调用图的树深度——得以实现。我们的方法首次同时利用控制流图和调用图的稀疏性,并以树宽和树深度进行双参数化。我们设计的算法具有线性预处理阶段,可对每个查询在常数时间(相对于输入规模)内完成响应。最后,实验结果表明,我们的方法显著优于经典IFDS算法及其按需变体。