paperbot · PL 论文追踪

全部论文 待读 收藏

P2 Towards Removing Undef Values from LLVM IR

迈向移除 LLVM IR 中的 undef 值
PLDI 10(PLDI)2026匹配度 2/10 · 该论文属于编译器 IR 形式语义与优化正确性,核心是移除 LLVM 的 undef 值,与用户关注的 PL 与 AI/LLM 交叉、Agentic 程序静态分析、浮点程序分析及贝叶斯程序分析均无直接关联。仅在“形式语义+工程实现”偏好上有微弱共性,不匹配核心研究方向。引用 0 inbox
Pedro Lobo, John McIver, George Mitenkov, Juneyoung Lee, Kirshanthan Sundararajah, Nuno P. Lopes
crossref: 2026-09-10

AI 速览

一句话:提出 raw memory 类型与 freezing load 扩展 LLVM IR,替代 undef 的最后用途,为彻底移除 undef 铺路。

LLVM IR 中的 undef 与 poison 两个延迟未定义行为值长期是错误来源;undef 尤其难以推理,其“每次观察可取不同任意值”的语义会让 2×y 改写为 y+y 等看似简单的优化变得不健全。它的最后用途是表示未初始化内存,并影响位域 lowering、原始数据拷贝与比较。本文提出对 LLVM IR 的扩展:引入 raw memory 值类型和 freezing load,并论证二者足以替代 undef 的剩余用途。作者在 LLVM 中实现这些构造,评估显示对运行时和编译时性能影响很小。该工作扫除了彻底移除 undef 的最后障碍,为更简单的语义模型和更易论证 IR 分析与优化的健全性铺平道路。

问题
LLVM IR 的 undef 值语义难以推理,使许多分析与优化不健全;其最后剩余用途是表示未初始化内存,并涉及位域 lowering、原始数据拷贝和比较。
方法
提出 LLVM IR 扩展,加入 raw memory 值类型与 freezing load,用它们替代 undef 在所有剩余场景中的用途。
评估
在 LLVM 中实现该扩展并测量运行时与编译时开销,结果表明性能影响很小;同时论证可移除 undef。
原文摘要(Abstract)

LLVM’s intermediate representation (IR) has two deferred undefined behavior (UB) values: undef and poison. The existence of these two values has been a persistent source of bugs. Reasoning about the correctness of analyses and optimizations for the regular cases is already tricky; ensuring that these are sound for all UB cases is highly non-trivial. Undef values, in particular, are one of the most misunderstood concepts of LLVM IR. On paper, the definition is simple: they represent an arbitrary value of the underlying type, and can yield a different value each time they are observed. However, this property makes even simple algebraic rewrites, such as replacing 2 × y with y + y , unsound in LLVM. Because reasoning about undef is hard, and the benefits of having it are limited, we have set a roadmap to eliminate it altogether from LLVM IR. The last remaining use of undef is the value of uninitialized memory, which has implications on the lowering of bitfields, as well as raw data copies and comparisons. In this paper, we propose an extension to LLVM IR that includes a raw memory value type and a freezing load. We show that these two constructs are sufficient to replace the remaining uses of undef in LLVM. Our implementation shows that these changes have minimal impact on both run-time and compile-time performance. By removing the final hurdle to eliminating undef from LLVM IR, this work paves the way for a simpler semantic model and easier reasoning about the soundness of IR analyses and optimizations.

链接与引用

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

BibTeX
@article{LoboMMLSL26,
  title = {Towards Removing Undef Values from LLVM IR},
  author = {Pedro Lobo and John McIver and George Mitenkov and Juneyoung Lee and Kirshanthan Sundararajah and Nuno P. Lopes},
  journal = {Proceedings of the ACM on Programming Languages},
  volume = {10},
  number = {PLDI},
  year = {2026},
  doi = {10.1145/3808250}
}