[PATCH] D79636: [LangRef] Clarify the semantics of the `byval` attribute

Johannes Doerfert via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat May 9 10:05:21 PDT 2020


jdoerfert updated this revision to Diff 263024.
jdoerfert marked 3 inline comments as done.
jdoerfert added a comment.

Fix spelling


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D79636/new/

https://reviews.llvm.org/D79636

Files:
  llvm/docs/LangRef.rst


Index: llvm/docs/LangRef.rst
===================================================================
--- llvm/docs/LangRef.rst
+++ llvm/docs/LangRef.rst
@@ -1043,10 +1043,18 @@
     is unable to modify the value in the caller. This attribute is only
     valid on LLVM pointer arguments. It is generally used to pass
     structs and arrays by value, but is also valid on pointers to
-    scalars. The copy is considered to belong to the caller not the
-    callee (for example, ``readonly`` functions should not write to
-    ``byval`` parameters). This is not a valid attribute for return
-    values.
+    scalars. The copy is conceptually made on the call edge. This means that
+    the pointer argument at the call site refers to the original memory and
+    the pointer argument in the callee is referring to the copy. Attributes on
+    the call site argument and function argument are associated with the
+    original and copied memory respectively. The copy is considered to be local
+    memory of the callee. That means, a callee can write a ``byval`` parameter
+    and still be ``readonly`` or ``readnone`` because the write is, similar to
+    a write to an ``alloca``, not visible from the outside. To create the copy
+    the original memory, thus the call site argument, is always read. This
+    effect is also associated with the call site, thus it cannot be `readnone`
+    or `writeonly` regardless of the callee. This is not a valid attribute for
+    return values.
 
     The byval attribute also supports an optional type argument, which must be
     the same as the pointee type of the argument.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D79636.263024.patch
Type: text/x-patch
Size: 1619 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200509/57a18ef0/attachment.bin>


More information about the llvm-commits mailing list