[llvm] [IR] LangRef: document behavior of double-lifetime.start (PR #184296)
Ralf Jung via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 2 23:50:35 PST 2026
https://github.com/RalfJung created https://github.com/llvm/llvm-project/pull/184296
Semantics suggested by @nikic . I have no idea what optimizations actually rely on here. This choice means optimizations have to be careful moving lifetime.start around and cannot just insert new ones as that may reset the value. It also means liveness analysis can consider the value in a local just before lifetime.start to be irrelevant since it gets overwritten.
The other plausible semantics are: it's UB, or it's a no-op.
Cc @nunoplopes
>From b5d103d23ed5ec220d544ae19815169acc1c2788 Mon Sep 17 00:00:00 2001
From: Ralf Jung <post at ralfj.de>
Date: Tue, 3 Mar 2026 08:43:53 +0100
Subject: [PATCH] [IR] LangRef: document behavior of double-lifetime.start
---
llvm/docs/LangRef.rst | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst
index a1835436ae359..b4a10c0befaa9 100644
--- a/llvm/docs/LangRef.rst
+++ b/llvm/docs/LangRef.rst
@@ -27731,10 +27731,12 @@ If ``ptr`` is a ``poison`` value, the intrinsic has no effect.
Otherwise, the stack-allocated object that ``ptr`` points to is initially
marked as dead. After '``llvm.lifetime.start``', the stack object is marked as
alive and has an uninitialized value.
-The stack object is marked as dead when either
+Calling ``llvm.lifetime.start`` when the stack object is already alive just
+resets its contents to be uninitialized.
+
+The stack object is marked as dead again when either
:ref:`llvm.lifetime.end <int_lifeend>` to the alloca is executed or the
function returns.
-
After :ref:`llvm.lifetime.end <int_lifeend>` is called,
'``llvm.lifetime.start``' on the stack object can be called again.
The second '``llvm.lifetime.start``' call marks the object as alive, but it
More information about the llvm-commits
mailing list