Lune

PLDI2026顶会

Towards Removing Undef Values from LLVM IR

Pedro Lobo, John McIver, George Mitenkov, Juneyoung Lee, Kirshanthan Sundararajah, Nuno P. Lopes

摘要

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 × 𝑦 with 𝑦 + 𝑦, 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.

问 Lune

几分钟读透这篇 Paper,不用再花一下午。

Lune 能读完全文,也能读引用它的顶会 Paper,讲清它的结论、证据和局限,每一点都注明出自哪篇 Paper。不用硬啃,也不靠猜。

可以从这些问题问起

Lune 可以查阅

全文 · 相关的 Paper

获取答案

免费开始,无需绑卡

脉络

  • Alive2: bounded translation validation for LLVM 引用了 An SMT Encoding of LLVM's Memory Model for Bounded Translation Validation
  • An SMT Encoding of LLVM's Memory Model for Bounded Translation Validation 引用了 Alive2: bounded translation validation for LLVM
它引用的引用它的从左到右按年份排列,引用越多,位置越高。

它引用的 Paper10

  1. Alive2: bounded translation validation for LLVMNuno P. Lopes, Juneyoung Lee, Chung-Kil Hur, Zhengyang Liu 等PLDI 2021 · 109 次引用
  2. Refined Input, Degraded Output: The Counterintuitive World of Compiler BehaviorTheodoros Theodoridis, Zhendong SuPLDI 2024 · 14 次引用
  3. VIP: verifying real-world C idioms with integer-pointer castsRodolphe Lepigre, Michael Sammler, Kayvan Memarian, Robbert Krebbers 等POPL 2022 · 11 次引用
  4. An SMT Encoding of LLVM's Memory Model for Bounded Translation ValidationJuneyoung Lee, Dongjoo Kim, Chung-Kil Hur, Nuno P. LopesCAV 2021 · 10 次引用
  5. OOElala: order-of-evaluation based alias analysis for compiler optimizationAnkush Phulia, Vaibhav Bhagee, Sorav BansalPLDI 2020 · 9 次引用

相关 Paper

  1. Exploiting Undefined Behavior in C/C++ Programs for Optimization: A Study on the Performance ImpactLucian Popescu, Nuno P. LopesPLDI 2025 · 2 次引用
  2. Type-Alias Analysis: Enabling LLVM IR with Accurate TypesJinmeng Zhou, Ziyue Pan, Wenbo Shen, Xingkai Wang 等ISSTA 2025 · 1 次引用
  3. An Integer Overflow Endgame: Compiler and Architecture Support for Default-On Integer Overflow MitigationZheng Zhang, Qi Ling, Kian Kasad, Brendan Ryan Sweeney 等USENIX Security 2026
  4. IRFuzzer: Specialized Fuzzing for LLVM Backend Code GenerationYuyang Rong, Zhanghan Yu, Zhenkai Weng, Stephen Neuendorffer 等ICSE 2025 · 1 次引用
  5. Translation Validation for LLVM's AArch64 BackendRyan Berger, Mitch Briles, Nader Boushehrinejad Moradi, Nicholas Coughlin 等OOPSLA 2025 · 3 次引用
黄昏的海面,两侧是细线勾勒的悬崖