一句话:提出基于 LLM 的 Golang 编译器测试代码生成方法,通过过滤与种子调度提升用例质量与数量。
现代优化编译器异常复杂,模糊测试是发现其细微缺陷的关键手段,但传统测试用例生成方法在覆盖率和数量上有限。本文提出基于 LLM 的编译器测试代码生成方法,以同时提升生成用例的质量与数量。方法包含过滤策略,用于清洗源码、避免未定义行为与语法错误,并为模型训练准备高质量数据集;还提出种子调度策略改进代码生成。作者将该方法用于测试 Golang 编译器。评估显示,其流水线在质量和数量上均优于先前方法:生成用例平均覆盖率为 3.38%,而 GoFuzz 仅为 0.44%;仅 2.79% 的用例出现语法错误,且无未定义行为。
Modern optimizing compilers are among the most complex software systems humans build. One way to identify subtle compiler bugs is fuzzing. Both the quantity and the quality of testcases are crucial to the performance of fuzzing. Traditional testcase-generation methods, such as Csmith and YARPGen, have been proven successful at discovering compiler bugs. However, such generated testcases have limited coverage and quantity. In this paper, we present a code generation method for compiler testing based on LLM to maximize the quality and quantity of the generated code. In particular, to avoid undefined behavior and syntax errors in generated testcases, we design a filter strategy to clean the source code, preparing a high-quality dataset for the model training. Besides, we present a seed schedule strategy to improve code generation. We apply the method to test the Golang compiler and the result shows that our pipeline outperforms previous methods both qualitatively and quantitatively. It produces testcases with an average coverage of 3.38%, in contrast to the testcases generated by GoFuzz, which have an average coverage of 0.44%. Moreover, among all the generated testcases, only 2.79% exhibited syntax errors, and none displayed undefined behavior.