arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2504.04321cs.SE
收藏

基于优化引导的等价变换的编译器优化测试

Compiler Optimization Testing Based on Optimization-Guided Equivalence Transformations

Jingwen Wu, Jiajing Zheng, Zhenyu Yang, Zhongxing Yu

AI总结:

针对差分测试在编译器优化测试中的局限性,提出一种受编译器优化启发的蜕变测试方法,通过定制代码构造和优化变换生成语义等价程序并比较输出,成功在 GCC 和 LLVM 中检测出五个错误优化缺陷。

摘要:

编译器优化技术本质上是复杂的,对编译器优化实现进行严格测试至关重要。近年来出现了用于发现错误优化缺陷的测试方法,但这些方法严重依赖差分测试机制,需要比较多个编译器的输出。这种依赖性带来了重要的局限性,包括(1)被测功能必须在所有编译器中一致实现,以及(2)共享缺陷仍未被检测到。因此,会产生误报,并且需要大量的人工工作。为了克服这些局限性,我们提出了一种受编译器优化启发的蜕变测试方法。该方法由如何最大化编译器优化机会同时有效判断优化正确性来驱动。具体而言,我们的方法首先采用定制的代码构造策略来生成满足优化条件的输入程序,然后应用各种编译器优化变换来创建语义等价的测试程序。通过比较变换前后程序的输出,该方法有效地识别了错误优化缺陷。我们在 GCC 和 LLVM 上对该方法进行了初步评估,在撰写本文时已成功检测到五个错误优化缺陷。该结果证明了我们方法的有效性和潜力。

英文摘要:

Compiler optimization techniques are inherently complex, and rigorous testing of compiler optimization implementation is critical. Recent years have witnessed the emergence of testing approaches for uncovering incorrect optimization bugs, but these approaches rely heavily on the differential testing mechanism, which requires comparing outputs across multiple compilers. This dependency gives rise to important limitations, including that (1) the tested functionality must be consistently implemented across all compilers and (2) shared bugs remain undetected. Thus, false alarms can be produced and significant manual efforts will be required. To overcome the limitations, we propose a metamorphic testing approach inspired by compiler optimizations. The approach is driven by how to maximize compiler optimization opportunities while effectively judging optimization correctness. Specifically, our approach first employs tailored code construction strategies to generate input programs that satisfy optimization conditions, and then applies various compiler optimization transformations to create semantically equivalent test programs. By comparing the outputs of pre- and post-transformation programs, this approach effectively identifies incorrect optimization bugs. We conducted a preliminary evaluation of this approach on GCC and LLVM, and we have successfully detected five incorrect optimization bugs at the time of writing. This result demonstrates the effectiveness and potential of our approach.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑