[论文解读] Idempotent Slices with Applications to Code-Size Reduction
该论文将幂等向后切片在GSA形式下形式化,提供一个正确的一线性时间切片识别算法,并展示一种基于切片的代码大小缩减方法(SBCR),该方法可以合并非连续指令,在LLVM二进制中实现显著的缩减。
Given a value computed within a program, an idempotent backward slice with respect to this value is a maximal subprogram that computes it. An informal notion of an idempotent slice has previously been used by Guimaraes et al. to transform eager into strict evaluation in the LLVM intermediate representation. However, that algorithm is insufficient to be correctly applied to general control-flow graphs. This paper addresses these omissions by formalizing the notion of idempotent backward slices and presenting a sound and efficient algorithm for extracting them from programs in Gated Static Single Assignment (GSA) form. As an example of their practical use, the paper describes how identifying and extracting idempotent backward slices enables a sparse code-size reduction optimization; that is, one capable of merging non-contiguous sequences of instructions within the control-flow graph of a single function or across functions. Experiments with the LLVM test suite show that, in specific benchmarks, this new algorithm achieves code-size reductions up to -7.24% on programs highly optimized by the -Os sequence of passes from clang 17.
研究动机与目标
- 形式化一般控制流图中幂等向后切片的概念,并识别现有方法的不足之处。
- 开发一个健全、有效的从GSA形式的程序中提取幂等向后切片的算法。
- 展示幂等切片如何通过 outlining 和合并切片来实现代码大小缩减优化。
- 在LLVM中实现切片算法并在LLVM测试套件上评估其有效性。
提出的方法
- 使用 Tu 和 Padua 的门控路径算法将 SSA 转换为 GSA,以获得显式的数据-控制依赖。
- 遍历 GSA,以带有循环和函数感知的停止条件识别幂等向后切片。
- 将已识别的切片 Outline 成独立函数,具有受保护的接口,并证明语义正确性(定理 4.2)。
- 使用两阶段重复消除(结构哈希和规范比较)合并同一性/语义等价的切片函数。
- 基于成本模型的决策将切片 Outline 与保留在原位进行权衡(参数 I、P、C)。
- 在 LLVM 测试集上将 SBCR 与基线(FMSA 和 LLVM IROutliner)进行对比评估,关注代码大小的变化。

实验结果
研究问题
- RQ1SBCR 的理想成本模型参数是什么?
- RQ2幂等切片 Outline 能实现多少代码大小缩减,与以往工作相比有何差异?
- RQ3相对于此前技术,切片 Outline 的运行时和编译开销是多少?
- RQ4切片 Outline 算法的渐近行为如何?
- RQ5将 SBCR 与其他代码大小缩减技术结合时,是否存在累积收益?
主要发现
- 可以从 GSA 形式正确识别幂等向后切片,并不需要 hammock 结构或 CSSA 属性。
- 向后切片的时间复杂度随程序 CFG 边数量线性增长。
- 在结合 -Os 优化时,SBCR 在 LLVM 二进制文本段的大小缩减可达到几何平均值 7.24%,基于2007个基准。
- SBCR 能发现前述方法如按序列对齐或 LLVM IROutliner 未捕捉到的非连续性与跨函数的切片机会。
- 所提出的方法与现有技术互为补充,在特定基准(如 AMGmk)上带来显著缩减。
- 给出健全性保证:Outline 的切片保留原始准则值和切片内循环的程序语义。
![Figure 2 : (a) Program with a slice criterion: the instruction $s=s+1$ . (b) Dense slice, adapted from Blazy et al. [ 3 , Fig. 1] . (c) Program in Static Single-Assignment form. (d) Program in Gated Static Single-Assignment form. (e) Idempotent backward slice with respect to SSA variable $s_{3}$ . (](https://ar5iv.labs.arxiv.org/html/2603.09726/assets/x2.png)
更好的研究,从现在开始
从论文设计到论文写作,大幅缩短您的研究时间。
无需绑定信用卡
本解读由 AI 生成,并经人工编辑审核。