arXiv:2502.06854cs.LGcs.AI2025-02ICML被引 2

大模型看懂编译器中间表示能力有限,尤其在控制流推理上表现差。

Can Large Language Models Understand Intermediate Representations in Compilers?

  • 用6个主流大模型测试四类编译器任务,评估其对中间表示的理解力。
  • 在控制流重构和动态执行推理中准确率低于40%,常误读分支与循环。
  • 适合编译器研究者、LLM安全评估人员参考,提示需针对性优化模型架构。

中间表示(IR)在编译器设计与程序分析中起关键作用,但大型语言模型(LLMs)对其理解能力尚未充分探索。本文开展一项实证研究,评估六种先进大模型——GPT-4、GPT-3、DeepSeek、Gemma 2、Llama 3 和 Code Llama——在理解IR方面的表现。具体考察四项核心任务:控制流图重建、反编译、代码摘要生成和执行推理。结果显示,尽管模型能较好解析IR语法并识别高层结构,但在指令级推理方面表现持续不足,尤其在控制流推理、循环处理和动态执行方面。常见错误包括误读分支指令、遗漏关键操作,以及依赖启发式而非精确的指令逻辑推理。研究指出需在大模型设计中引入针对IR的改进策略,建议在结构化IR数据集上进行微调,并集成对控制流敏感的架构。所有实验数据与源码已公开。

原文摘要 · Abstract (English)

Intermediate Representations (IRs) play a critical role in compiler design and program analysis, yet their comprehension by Large Language Models (LLMs) remains underexplored. In this paper, we present an explorative empirical study evaluating the capabilities of six state-of-the-art LLMs: GPT-4, GPT-3, DeepSeek, Gemma 2, Llama 3, and Code Llama, in understanding IRs. Specifically, we assess model performance across four core tasks: control flow graph reconstruction, decompilation, code summarization, and execution reasoning. While LLMs exhibit competence in parsing IR syntax and identifying high-level structures, they consistently struggle with instruction-level reasoning, especially in control flow reasoning, loop handling, and dynamic execution. Common failure modes include misinterpreting branching instructions, omitting critical operations, and relying on heuristic reasoning rather than precise instruction-level logic. Our findings highlight the need for IR-specific enhancements in LLM design. We recommend fine-tuning on structured IR datasets and integrating control-flow-sensitive architectures to improve model effectiveness. All experimental data and source code are publicly available at

编译器大模型控制流

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。