一句话:提出黑盒编译器后端测试方法 BackSmith,通过生成后端导向、抗优化和稀有汇编程序,在 GCC/LLVM 后端发现 104 个新缺陷。
编译器后端负责将高层代码翻译为高效机器指令,但其测试相对不足。有效测试需要能暴露指令选择、寄存器分配等底层行为的程序,然而这类程序难以生成,并常被中端优化消除。BackSmith 是一种跨编译器和架构的黑盒测试方法,它生成同时具备后端导向特征与抗优化特征的代码片段,以压力测试后端机制并保持程序多样性;还专门生成编译后汇编在随机生成中罕见的片段,并将三类特征整合进种子程序。作者在 16 个成熟的 GCC 和 LLVM 后端上评估,经过五个月测试发现 104 个此前未知的后端缺陷,其中 88 个已确认或修复,表明该方法能系统性地暴露后端缺陷。
Compiler backends are critical for translating high-level code into efficient machine instructions, yet they remain relatively underexplored in compiler testing. Effective backend testing requires programs that expose low-level backend behaviors, but such features are difficult to generate and are frequently eliminated by earlier optimization passes. As a result, existing testing approaches often fail to adequately exercise backend behaviors and are therefore less effective at uncovering backend defects. We present BackSmith, a black-box approach for testing compiler backends across compilers and architectures. BackSmith generates code snippets with two complementary properties: backend-oriented features that directly stress backend mechanisms such as instruction selection and register allocation, and optimization-resistant features that preserve program diversity by resisting excessive middle-end canonicalization. To further increase coverage of rare but critical backend behaviors, BackSmith also generates code snippets whose compiled assembly rarely arises during random generation. It then integrates all three kinds of features into seed programs for backend testing. We evaluated BackSmith on 16 mature GCC and LLVM backends. Over five months of testing, BackSmith uncovered 104 previously unknown backend bugs, 88 of which have been confirmed or fixed, demonstrating the effectiveness of our approach in systematically exposing backend defects.
@article{paperbot12128,
title = {BackSmith: A Systematic Approach to Testing Compiler Backends},
author = {Hongyu Chen and Yu Wang and Jianhua Zhao and Ke Wang},
journal = {Proceedings of the ACM on Programming Languages},
volume = {10},
number = {OOPSLA2},
year = {2026},
doi = {10.1145/3839529}
}