paperbot · PL 论文追踪

全部论文 待读 收藏

P2 Unleashing the power of compiler intermediate representation to enhance neural program embeddings

释放编译器中间表示的力量以增强神经程序嵌入
ICSE Proceedings of the 44th International Conference on Software Engineering2022匹配度 4/10 · 该论文研究用 LLVM IR 与遗传算法优化神经程序嵌入以提升代码克隆检测,属于经典的 ML4Code / 程序表示学习方向,与用户画像中 PL→AI 的静态分析应用、AI→PL 的 LLM 改进静态分析、浮点程序分析、贝叶斯程序分析等核心方向均无直接交集;但其编译器 IR 与程序分析交叉的定位存在一定边缘关联。引用 40 inbox
Zongjie Li, Pingchuan Ma, Huaijin Wang, Shuai Wang, Qiyi Tang, Sen Nie, Shi Wu
crossref: 2026-09-12dblp: 2026-09-12arxiv: 2026-09-12

AI 速览

一句话:利用 LLVM IR 与遗传算法搜索优化选项,增强神经程序嵌入质量并提升代码克隆检测性能。

现有神经程序嵌入多直接从源代码的 token、AST 或控制流图学习,未充分利用编译器中间表示。本文提出结合源代码与 LLVM IR 训练嵌入模型,并设计 IRGEN:基于遗传算法搜索近似最优的 LLVM 优化选项序列,以最大化嵌入质量。作者扩展 CodeCMR,加入 triplet loss 实现源代码与 IR 联合学习,在代码克隆检测上评估。实验表明,经 IRGEN 优化 IR 训练的 CodeCMR 显著优于仅用源代码的 CodeBERT,也优于使用默认优化级别 IR 的版本;IRGEN 还能泛化到其他嵌入模型,并适用于训练数据极少场景。

问题
现有神经程序嵌入主要从源代码特征学习,未有效利用编译器 IR 及优化选项对嵌入质量的影响。
方法
提出在源代码与 LLVM IR 上联合训练嵌入模型,并用基于遗传算法的 IRGEN 搜索最优 LLVM 优化选项序列;扩展 CodeCMR 加入 triplet loss。
评估
以代码克隆检测为下游任务,比较 CodeBERT、默认优化 IR 训练的 CodeCMR;并考察 IRGEN 的泛化性与少样本设置。
原文摘要(Abstract)

Neural program embeddings have demonstrated considerable promise in a range of program analysis tasks, including clone identification, program repair, code completion, and program synthesis. However, most existing methods generate neural program embeddings di-rectly from the program source codes, by learning from features such as tokens, abstract syntax trees, and control flow graphs. This paper takes a fresh look at how to improve program embed-dings by leveraging compiler intermediate representation (IR). We first demonstrate simple yet highly effective methods for enhancing embedding quality by training embedding models alongside source code and LLVM IR generated by default optimization levels (e.g., -02). We then introduce IRGEN, a framework based on genetic algorithms (GA), to identify (near-)optimal sequences of optimization flags that can significantly improve embedding quality. We use IRGEN to find optimal sequences of LLVM optimization flags by performing GA on source code datasets. We then extend a popular code embedding model, CodeCMR, by adding a new objective based on triplet loss to enable a joint learning over source code and LLVM IR. We benchmark the quality of embedding using a rep-resentative downstream application, code clone detection. When CodeCMR was trained with source code and LLVM IRs optimized by findings of IRGEN, the embedding quality was significantly im-proved, outperforming the state-of-the-art model, CodeBERT, which was trained only with source code. Our augmented CodeCMR also outperformed CodeCMR trained over source code and IR optimized with default optimization levels. We investigate the properties of optimization flags that increase embedding quality, demonstrate IRGEN's generalization in boosting other embedding models, and establish IRGEN's use in settings with extremely limited training data. Our research and findings demonstrate that a straightforward addition to modern neural code embedding models can provide a highly effective enhancement.

链接与引用

DOI 原文 · arXiv · PDF(开放获取) · DBLP

BibTeX
@inproceedings{Li0WW0NW22,
  title = {Unleashing the power of compiler intermediate representation to enhance neural program embeddings},
  author = {Zongjie Li and Pingchuan Ma and Huaijin Wang and Shuai Wang and Qiyi Tang and Sen Nie and Shi Wu},
  booktitle = {ICSE},
  year = {2022},
  doi = {10.1145/3510003.3510217}
}