Semantics for Compiler IRs: Undefined Behavior is not Evil!
Building a compiler IR is tricky. First, it should be efficient to compile the desired source language to this IR. Second, the IR should support all the desired optimizations and analyses, and these should run efficiently. Finally, it should be possible to lower this IR into the desired target assembly efficiently. Striking a good tradeoff in this design space isn’t easy.
Undefined behavior (UB) has been used in production compilers’ IRs for a long time. In this talk, we will explore what’s UB, what it achieves, why it may be a good idea, and why it is not as evil as most people think it is.