Program reduction is a prevalent technique to facilitate compilers' debugging by automatically minimizing bug-triggering programs. Existing program reduction techniques are either generic across languages (e.g., Perses and Vulcan) or specifically customized for one certain language by employing language-specific features, like C-Reduce. However, striking the balance between generality across multiple programming languages and specificity to individual languages in program reduction is yet to be explored. This paper proposes LPR, the first technique utilizing LLMs to perform language-specific program reduction for multiple languages. The core insight is to utilize both the language-generic syntax level program reduction (e.g., Perses) and the language-specific semantic level program transformations learned by LLMs. Alternately, language-generic program reducers efficiently reduce programs into 1-tree-minimality, which is small enough to be manageable for LLMs; LLMs effectively transform programs via the learned semantics to expose new reduction opportunities for the language-generic program reducers to further reduce the programs. Our extensive evaluation on 50 benchmarks across three languages (C, Rust, and JavaScript) has highlighted LPR's practicality and superiority over Vulcan, the state-of-the-art language-generic program reducer. For effectiveness, LPR surpasses Vulcan by producing 24.93%, 4.47%, and 11.71% smaller programs on benchmarks in C, Rust and JavaScript. Moreover, LPR and Vulcan have demonstrated their potential to complement each other. By using Vulcan on LPR's output for C programs, we achieve program sizes comparable to those reduced by C-Reduce. For efficiency, LPR takes 10.77%, 34.88%, 36.96% less time than Vulcan to finish all benchmarks in C, Rust and JavaScript, separately.
翻译:程序缩减是一种通过自动最小化触发缺陷的程序来辅助编译器调试的通用技术。现有程序缩减技术要么跨语言通用(如Perses和Vulcan),要么通过利用语言特定特性为某一特定语言定制(如C-Reduce)。然而,在程序缩减中如何平衡跨多种编程语言的通用性与单一语言的特异性仍待探索。本文提出LPR,这是首个利用LLMs对多种语言执行语言特定程序缩减的技术。其核心思想在于同时利用语言通用的语法级程序缩减(如Perses)和LLMs习得的语言特定语义级程序变换。通过交替执行:语言通用程序缩减器高效地将程序缩减至1-树最小状态(该规模足够小,便于LLMs处理);LLMs则通过习得的语义有效变换程序,为语言通用程序缩减器暴露新的缩减机会,使其能进一步缩减程序。我们在涵盖C、Rust和JavaScript三种语言的50个基准测试上进行了广泛评估,结果凸显了LPR相较于最先进的通用语言程序缩减器Vulcan的实用性和优越性。在效果方面,LPR在C、Rust和JavaScript基准测试上产生的程序分别比Vulcan小24.93%、4.47%和11.71%。此外,LPR与Vulcan展现出互补潜力——对C语言程序使用Vulcan处理LPR输出后,可获得与C-Reduce缩减结果相当的程序体积。在效率方面,LPR完成C、Rust和JavaScript全部基准测试所需时间分别比Vulcan少10.77%、34.88%和36.96%。