[PATCH] D135597: [LangRef] Add memory attribute

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 11 02:26:01 PDT 2022


nikic updated this revision to Diff 466741.
nikic marked 2 inline comments as done.
nikic added a comment.

Mention default (all effects) and how effects for a call are derived from call-site and function attributes.


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

https://reviews.llvm.org/D135597

Files:
  llvm/docs/LangRef.rst


Index: llvm/docs/LangRef.rst
===================================================================
--- llvm/docs/LangRef.rst
+++ llvm/docs/LangRef.rst
@@ -1730,6 +1730,46 @@
     a new pointer for the original function, which means that code that depends
     on function-pointer identity can break. So, any function annotated with
     ``jumptable`` must also be ``unnamed_addr``.
+``memory(...)``
+    This attribute specifies the possible memory effects of the call/function.
+    It allows specifying the possible access kinds (``none``, ``read``,
+    ``write``, or ``readwrite``) for the possible memory location kinds
+    (``argmem``, ``inaccessiblemem``, and ``other``). It is best understood by
+    example:
+
+    - ``memory()`` or ``memory(none)``: Does not access any memory.
+    - ``memory(read)``: May read (but not write) any memory.
+    - ``memory(write)``: May write (but not read) any memory.
+    - ``memory(readwrite)``: May read or write any memory.
+    - ``memory(argmem: read)``: May only read argument memory.
+    - ``memory(argmem: read, inaccessiblemem: write)``: May only read argument
+      memory and only write inaccessible memory.
+    - ``memory(read, argmem: readwrite)``: May read any memory (default mode)
+      and additionally write argument memory.
+    - ``memory(readwrite, argmem: none)``: May access any memory apart from
+      argument memory.
+
+    The supported memory location kinds are:
+
+    - ``argmem``: This refers to accesses that are based on pointer arguments
+      to the function.
+    - ``inaccessiblemem``: This refers to accesses to memory which is not
+      accessible by the current module (before return from the function -- an
+      allocator function may return newly accessible memory while only
+      accessing inaccessible memory itself). Inaccessible memory is often used
+      to model control dependencies of intrinsics.
+    - ``other``: An access that does not fall into any of the previous
+      categories. This location kind is expected to split into more precise
+      location kinds in the future. As such, it is recommended to specify a
+      default access kind that covers ``other``, rather than enumerating all
+      currently supported location kinds.
+
+    If the ``memory`` attribute is not specified, then ``memory(readwrite)``
+    is implied (all memory effects are possible).
+
+    The memory effects of a call are the intersection of the call-site
+    ``memory`` attribute with the union of the function ``memory`` attribute
+    and any effects implied by operand bundles.
 ``minsize``
     This attribute suggests that optimization passes and code generator
     passes make choices that keep the code size of this function as small


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D135597.466741.patch
Type: text/x-patch
Size: 2745 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221011/73180adf/attachment.bin>


More information about the llvm-commits mailing list