paperbot · PL 论文追踪

全部论文 待读 收藏

P2 Boosting Compiler Testing by Injecting Real-World Code

通过注入真实世界代码增强编译器测试
PLDI 8(PLDI)2024匹配度 2/10 · 该论文属于编译器测试与程序生成,虽与 PL 相关,但未涉及静态分析、LLM/Agent 改进分析、浮点程序分析或贝叶斯程序分析等用户核心方向。其核心理念是注入真实代码增强随机测试,与用户研究画像交集很小。引用 40 inbox
Shaohua Li, Theodoros Theodoridis, Zhendong Su
dblp: 2026-09-10crossref: 2026-09-10

AI 速览

一句话:提出 Creal,以保语义方式将真实项目函数注入种子程序,借真实代码提升随机生成器的表达能力来测试优化编译器。

优化编译器的错误(miscompilation)隐蔽且难以发现,而现有随机程序生成器等工程化手段难以覆盖真实语言中丰富的语法与语义特性。本文提出一种新思路:从真实世界应用中按函数粒度抽取代码片段,将其函数调用注入种子程序,并利用动态执行信息维护语义、在注入函数与种子程序之间建立复杂数据依赖,从而以保持语义的方式融合真实代码,增强现有生成器的表达能力。作者实现工具 Creal 用于测试 C 编译器。在为期九个月的测试中,向 GCC 和 LLVM 报告了 132 个 bug,其中 121 个被确认为未知 bug,101 个已被修复;这些 bug 多为误编译,不少被认定为长期潜伏且关键的问题,证明真实世界代码对压测编译器具有显著优势。

问题
优化编译器的误编译难以通过现有随机程序生成器充分暴露,因为这类工具很难完整支持真实语言中丰富的语法与语义特性。
方法
以函数为粒度提取真实项目代码,将函数调用注入种子程序,并借助动态执行信息保持语义、构建注入函数与种子程序间的复杂数据依赖,实现保语义的真实代码融合。
评估
实现 Creal 工具测试 C 编译器,在九个月内向 GCC 和 LLVM 提交 bug;结果报告 132 个 bug,121 个确认为未知、101 个已修复,多为长期潜伏的误编译。
原文摘要(Abstract)

We introduce a novel approach for testing optimizing compilers with code from real-world applications The main idea is to construct well-formed programs by fusing multiple code snippets from various realworld projects. The key insight is backed by the fact that the large volume of real-world code exercises rich syntactical and semantic language features, which current engineering-intensive approaches like random program generators are hard to fully support. To construct well-formed programs from real-world code our approach works by (1) extracting real-world code at the granularity of function, (2) injecting function calls into seed programs, and (3) leveraging dynamic execution information to maintain the semantics and build complex data dependencies between injected functions and the seed program. With this idea, our approach complements the existing generators by boosting their expressiveness via fusing real-world code in a semantics-preserving way. We implement our idea in a tool, Creal, to test C compilers. In a nine-month testing period, we have reported 132 bugs to GCC and LLVM, two of the most popular and well-tested C compilers. At the time of writing, 121 of them have been confirmed as unknown bugs, and 101 of them have been fixed. Most of these bugs were miscompilations, and many were recognized as long-latent and critical. Our evaluation results evidently demonstrate the significant advantage of using real-world code to stress-test compilers. We believe this idea will benefit the general compiler testing direction and will be directly applicable to other compilers.

链接与引用

DOI 原文 · PDF(开放获取) · DBLP

BibTeX
@article{LiTS24,
  title = {Boosting Compiler Testing by Injecting Real-World Code},
  author = {Shaohua Li and Theodoros Theodoridis and Zhendong Su},
  journal = {Proceedings of the ACM on Programming Languages},
  volume = {8},
  number = {PLDI},
  year = {2024},
  doi = {10.1145/3656386}
}