[llvm] 7435ad3 - [LangRef] Clarifying the copying behaviour of byval (#205576)

via llvm-commits llvm-commits at lists.llvm.org
Sat Jun 27 06:30:41 PDT 2026


Author: Yingwei Zheng
Date: 2026-06-27T21:30:36+08:00
New Revision: 7435ad31b5f4feba1a3d0f8928a5225e546f6ee2

URL: https://github.com/llvm/llvm-project/commit/7435ad31b5f4feba1a3d0f8928a5225e546f6ee2
DIFF: https://github.com/llvm/llvm-project/commit/7435ad31b5f4feba1a3d0f8928a5225e546f6ee2.diff

LOG: [LangRef] Clarifying the copying behaviour of byval (#205576)

The hidden copy of a byval argument can only be treated as a continuous
memcpy with the allocation size. It is incorrect to interpret it as a
load-store forwarding in the specified type, since a padding between
struct fields may still be a part of an active member of a union type.

Added: 
    

Modified: 
    llvm/docs/LangRef.rst

Removed: 
    


################################################################################
diff  --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst
index b7744ad2ff5fd..5640eec987133 100644
--- a/llvm/docs/LangRef.rst
+++ b/llvm/docs/LangRef.rst
@@ -1357,7 +1357,11 @@ Currently, only the following parameter attributes are defined:
     ``byval`` parameters). This is not a valid attribute for return
     values.
 
-    The byval type argument indicates the in-memory value type.
+    The byval type argument is only used for its allocation size and alignment
+    (if there is no explicit align attribute). That is, the hidden copy is
+    interpreted as a call to memcpy with the allocation size of the specified type,
+    instead of loading from the pointee and storing back into the copy in the type.
+    In particular, the padding between field types of a struct type is still copied.
 
     The byval attribute also supports specifying an alignment with the
     ``align`` attribute. It indicates the alignment of the stack slot to


        


More information about the llvm-commits mailing list