[llvm] LangRef: mention that willreturn can cause time-traveling UB (PR #214229)

Ralf Jung via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 5 06:15:59 PDT 2026


https://github.com/RalfJung created https://github.com/llvm/llvm-project/pull/214229

I think with #192992, the only remaining possible source of time-traveling UB in LLVM are `willreturn` annotations emitted by the frontend. So let's add a note about that.

I think ideally we'd also say somewhere "UB cannot time-travel except if you put `willreturn` on a function that has observable behavior", but I am not sure what would be a good place for that.

Cc @nikic @dtcxzyw @gonzalobg 

>From 549c782423da05804cab0d434dd5fbf68c7238bc Mon Sep 17 00:00:00 2001
From: Ralf Jung <post at ralfj.de>
Date: Wed, 5 Aug 2026 15:10:12 +0200
Subject: [PATCH] LangRef: mention that willreturn can cause time-traveling UB

---
 llvm/docs/LangRef.md | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/llvm/docs/LangRef.md b/llvm/docs/LangRef.md
index 6a3194271b838..3b12982b4d60d 100644
--- a/llvm/docs/LangRef.md
+++ b/llvm/docs/LangRef.md
@@ -2495,6 +2495,8 @@ fn -> other_fn -> other_fn ; fn is norecurse
     Annotated functions may still raise an exception, i.a., `nounwind` is not implied.
     If an invocation of an annotated function does not return control back
     to a point in the call stack, the behavior is undefined.
+    If the annotated function has observable behavior (such as I/O or a volatile access),
+    note that the annotation can cause UB  to time-travel around such behavior.
 
 `nosync`
 :   This function attribute indicates that the function does not introduce any



More information about the llvm-commits mailing list