一句话:提出 Treefix,用 LLM 迭代构造前缀树,使代码片段尽可能被执行。
执行代码是许多动态程序分析的前提。已有学习引导执行方法(如 LExecutor)通过神经网络预测缺失变量的可能值来执行代码片段,但可预测的值有限,且不利用先前执行反馈,覆盖率受限。本文提出 Treefix:一种基于 LLM 的学习引导执行方法,以多步迭代方式生成并改进代码前缀。每一步将代码片段及其执行反馈作为提示,指示 LLM 改进已有前缀,从而逐步构建前缀树;最终返回使代码片段执行行数最大化的前缀子集。在两个 Python 代码片段数据集上,Treefix 相比当前最优方法分别提升 25% 和 7% 的覆盖率,覆盖全部代码行的 84% 与 82%。
The ability to execute code is a prerequisite for various dynamic program analyses. Learning-guided execution has been proposed as an approach to enable the execution of arbitrary code snippets by letting a neural model predict likely values for any missing variables. Although state-of-the-art learning-guided execution approaches, such as LExecutor, can enable the execution of a relative high amount of code, they are limited to predicting a restricted set of possible values and do not use any feedback from previous executions to execute even more code. This paper presents Treefix, a novel learning-guided execution approach that leverages LLMs to iteratively create code prefixes that enable the execution of a given code snippet. The approach addresses the problem in a multi-step fashion, where each step uses feedback about the code snippet and its execution to instruct an LLM to improve a previously generated prefix. This process iteratively creates a tree of prefixes, a subset of which is returned to the user as prefixes that maximize the number of executed lines in the code snippet. In our experiments with two datasets of Python code snippets, Treefix achieves 25% and 7% more coverage relative to the current state of the art in learning-guided execution, covering a total of 84% and 82% of all lines in the code snippets.
DOI 原文 ·
@inproceedings{paperbot8928,
title = {Treefix: Enabling Execution with a Tree of Prefixes},
author = {Beatriz Souza and Michael Pradel},
booktitle = {ICSE},
year = {2025},
doi = {10.1109/icse55347.2025.00215}
}