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

via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 5 06:16:44 PDT 2026


llvmorg-github-actions[bot] wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-llvm-ir

Author: Ralf Jung (RalfJung)

<details>
<summary>Changes</summary>

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 

---
Full diff: https://github.com/llvm/llvm-project/pull/214229.diff


1 Files Affected:

- (modified) llvm/docs/LangRef.md (+2) 


``````````diff
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

``````````

</details>


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


More information about the llvm-commits mailing list