[llvm] [LangRef] allow omitting `va_end` (PR #203087)

Folkert de Vries via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 12 01:34:41 PDT 2026


https://github.com/folkertdev updated https://github.com/llvm/llvm-project/pull/203087

>From 4ee02884ec8b8b84146460df3bb9a64668917f1c Mon Sep 17 00:00:00 2001
From: Folkert de Vries <folkert at folkertdev.nl>
Date: Wed, 10 Jun 2026 21:45:49 +0200
Subject: [PATCH 1/3] [LangRef] allow omitting `va_end`

---
 llvm/docs/LangRef.rst | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst
index cf052513c5ef8..fa363f77c4485 100644
--- a/llvm/docs/LangRef.rst
+++ b/llvm/docs/LangRef.rst
@@ -14631,10 +14631,13 @@ Semantics:
 
 The '``llvm.va_end``' intrinsic works just like the ``va_end`` macro
 available in C. In a target-dependent way, it destroys the ``va_list``
-element to which the argument points. Calls to
+element to which the argument points. Calls to ``llvm.va_end`` can be
+omitted when they are a no-op for the given target. ``llvm.va_end``
+is a no-op for all currently supported targets.
+
+When used, calls to ``llvm.va_end`` must be matched exactly with calls to
 :ref:`llvm.va_start <int_va_start>` and
-:ref:`llvm.va_copy <int_va_copy>` must be matched exactly with calls to
-``llvm.va_end``.
+:ref:`llvm.va_copy <int_va_copy>`.
 
 .. _int_va_copy:
 

>From 537224018e4bf571f7a4ff19830b98e8e093faa7 Mon Sep 17 00:00:00 2001
From: Folkert de Vries <folkert at folkertdev.nl>
Date: Wed, 10 Jun 2026 23:45:35 +0200
Subject: [PATCH 2/3] add notes about

- the argument list getting destroyed
- memcpy being OK when the va_list is trivially copyable
---
 llvm/docs/LangRef.rst | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst
index fa363f77c4485..7b59835388a38 100644
--- a/llvm/docs/LangRef.rst
+++ b/llvm/docs/LangRef.rst
@@ -14535,6 +14535,9 @@ does not define what this type is, so all transformations should be
 prepared to handle these functions regardless of the type used. The intrinsics
 are overloaded, and can be used for pointers to different address spaces.
 
+The underlying argument list is destroyed when a function returns, so
+a ``va_list`` must not outlive the function that created it.
+
 This example shows how the :ref:`va_arg <i_va_arg>` instruction and the
 variable argument handling intrinsic functions are used.
 
@@ -14674,6 +14677,10 @@ available in C. In a target-dependent way, it copies the source
 intrinsic is necessary because the ``llvm.va_start`` intrinsic may be
 arbitrarily complex and require, for example, memory allocation.
 
+On targets where ``va_list`` is trivially copyable, ``memcpy`` can be
+used instead to duplicate a ``va_list``. The ``va_list`` type is
+trivially copyable on all currently supported targets.
+
 Accurate Garbage Collection Intrinsics
 --------------------------------------
 

>From 963b62a5814dd400861cc4f0ff6ca0c28975631d Mon Sep 17 00:00:00 2001
From: Folkert de Vries <folkert at folkertdev.nl>
Date: Fri, 12 Jun 2026 10:34:21 +0200
Subject: [PATCH 3/3] update va_copy description

---
 llvm/docs/LangRef.rst | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst
index 7b59835388a38..32eb7386c9c65 100644
--- a/llvm/docs/LangRef.rst
+++ b/llvm/docs/LangRef.rst
@@ -14677,9 +14677,9 @@ available in C. In a target-dependent way, it copies the source
 intrinsic is necessary because the ``llvm.va_start`` intrinsic may be
 arbitrarily complex and require, for example, memory allocation.
 
-On targets where ``va_list`` is trivially copyable, ``memcpy`` can be
-used instead to duplicate a ``va_list``. The ``va_list`` type is
-trivially copyable on all currently supported targets.
+On targets where ``llvm.va_copy`` is equivalent to ``memcpy``, ``memcpy``
+can be used instead to duplicate a ``va_list``. ``llvm.va_copy`` is
+equivalent to ``memcpy`` on all currently supported targets implement
 
 Accurate Garbage Collection Intrinsics
 --------------------------------------



More information about the llvm-commits mailing list