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

DCE-LLM: 基于大语言模型的死代码消除

DCE-LLM: Dead Code Elimination with Large Language Models

Minyu Chen, Guoqiang Li, Ling-I Wu, Ruibang Liu

AI总结:

针对现有死代码消除工具易被复杂模式绕过、需大量人工介入的问题,提出DCE-LLM框架,结合小型CodeBERT的可疑代码定位与微调LLM的判断修复,在多语言死代码检测上F1超94%,显著优于GPT-4o。

摘要:

死代码会给软件开发带来诸多挑战,例如二进制体积增大、维护难度提升。它还可能掩盖逻辑错误,甚至被用于恶意软件的混淆操作。在基于大语言模型(LLM)的代码相关任务中,死代码会引入可误导模型的漏洞,引发安全隐患。尽管现代编译器和集成开发环境(IDE)已提供死代码消除功能,但复杂的代码模式仍可绕过这些工具。业界需要一套涵盖分类、定位、解释和修复的通用方案,而现有工具往往需要大量人工介入。我们提出DCE-LLM框架,用于自动化死代码消除:该框架采用小型CodeBERT模型搭配基于归因的行选择器,可高效定位可疑代码;随后由LLM生成判断与解释,且模型在大规模带标注死代码数据集上完成微调,可提供详细的问题说明与修复补丁。DCE-LLM在不可达代码检测能力、自动化修复效果及多编程语言支持方面均优于现有工具。实验结果显示,DCE-LLM在未使用代码和不可达代码检测任务上的F1值均超过94%,较GPT-4o高出30%。

英文摘要:

Dead code introduces several challenges in software development, such as increased binary size and maintenance difficulties. It can also obscure logical errors and be exploited for obfuscation in malware. For LLM-based code-related tasks, dead code introduces vulnerabilities that can mislead these models, raising security concerns. Although modern compilers and IDEs offer dead code elimination, sophisticated patterns can bypass these tools. A universal approach that includes classification, location, explanation, and correction is needed, yet current tools often require significant manual effort. We present DCE-LLM, a framework for automated dead code elimination using a small CodeBERT model with an attribution-based line selector to efficiently locate suspect code. LLMs then generate judgments and explanations, fine-tuned on a large-scale, annotated dead code dataset to provide detailed explanations and patches. DCE-LLM outperforms existing tools, with advanced unreachability detection, automated correction, and support for multiple programming languages. Experimental results show DCE-LLM achieves over 94% F1 scores for unused and unreachable code, significantly surpassing GPT-4o by 30%.

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

↑