[llvm] [docs] Add guide for Undefined Behavior (PR #119220)
Antonio Frighetto via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 10 01:12:07 PST 2024
================
@@ -0,0 +1,351 @@
+======================================
+LLVM IR Undefined Behavior (UB) Manual
+======================================
+
+.. contents::
+ :local:
+ :depth: 2
+
+Abstract
+========
+This document describes the undefined behavior (UB) in LLVM's IR, including
+undef and poison values, as well as the ``freeze`` instruction.
+We also provide guidelines on when to use each form of UB.
+
+
+Introduction
+============
+Undefined behavior is used to specify the behavior of corner cases for which we
+don't wish to specify the concrete results. UB is also used to provide
+additional constraints to the optimizers (e.g., assumptions that the frontend
+guarantees through the language type system or the runtime).
+For example, we could specify the result of division by zero as zero, but
+since we are not really interested in the result, we say it is UB.
+
+There are two forms of UB in LLVM: immediate UB and deferred UB (undef and
+poison values).
----------------
antoniofrighetto wrote:
Wouldn't one be inclined to think undef corresponds to immediate and poison to deferred, as being written? How about something as follows?
```suggestion
There exist two forms of undefined behaviour in LLVM: immediate UB and deferred UB. The latter comes in two flavours: undef and poison values.
```
https://github.com/llvm/llvm-project/pull/119220
More information about the llvm-commits
mailing list