Towards Removing Undef Values from LLVM IR

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

 

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.

 

Published:

P. Lobo, J. McIver, G. Mitenkov, J. Lee, K. Sundararajah, N. P. Lopes. Towards Removing Undef Values from LLVM IR. Proc. of the ACM on Programming Languages, Volume 10 Issue PLDI, June 2026.

 

Download:

 

Bibtex:

@article{byte-type-pldi26,
  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 =	{Proc. of the ACM on Programming Languages},
  volume =	{10},
  articleno =	{172},
  number =	{PLDI},
  publisher =	{ACM},
  doi =		{10.1145/3808250},
  month =	jun,
  year =	2026
}

 

Copyright notice:

© The Authors, 2026. Licensed under the Creative Commons Attribution 4.0 International License.

 

<-- Return