@@ -1730,6 +1730,46 @@ example:
1730
1730
a new pointer for the original function, which means that code that depends
1731
1731
on function-pointer identity can break. So, any function annotated with
1732
1732
``jumptable`` must also be ``unnamed_addr``.
1733
+ ``memory(...)``
1734
+ This attribute specifies the possible memory effects of the call-site or
1735
+ function. It allows specifying the possible access kinds (``none``,
1736
+ ``read``, ``write``, or ``readwrite``) for the possible memory location
1737
+ kinds (``argmem``, ``inaccessiblemem``, as well as a default). It is best
1738
+ understood by example:
1739
+
1740
+ - ``memory(none)``: Does not access any memory.
1741
+ - ``memory(read)``: May read (but not write) any memory.
1742
+ - ``memory(write)``: May write (but not read) any memory.
1743
+ - ``memory(readwrite)``: May read or write any memory.
1744
+ - ``memory(argmem: read)``: May only read argument memory.
1745
+ - ``memory(argmem: read, inaccessiblemem: write)``: May only read argument
1746
+ memory and only write inaccessible memory.
1747
+ - ``memory(read, argmem: readwrite)``: May read any memory (default mode)
1748
+ and additionally write argument memory.
1749
+ - ``memory(readwrite, argmem: none)``: May access any memory apart from
1750
+ argument memory.
1751
+
1752
+ The supported memory location kinds are:
1753
+
1754
+ - ``argmem``: This refers to accesses that are based on pointer arguments
1755
+ to the function.
1756
+ - ``inaccessiblemem``: This refers to accesses to memory which is not
1757
+ accessible by the current module (before return from the function -- an
1758
+ allocator function may return newly accessible memory while only
1759
+ accessing inaccessible memory itself). Inaccessible memory is often used
1760
+ to model control dependencies of intrinsics.
1761
+ - The default access kind (specified without a location prefix) applies to
1762
+ all locations that haven't been specified explicitly, including those that
1763
+ don't currently have a dedicated location kind (e.g. accesses to globals
1764
+ or captured pointers).
1765
+
1766
+ If the ``memory`` attribute is not specified, then ``memory(readwrite)``
1767
+ is implied (all memory effects are possible).
1768
+
1769
+ The memory effects of a call can be computed as
1770
+ ``CallSiteEffects & (FunctionEffects | OperandBundleEffects)``. Thus, the
1771
+ call-site annotation takes precedence over the potential effects described
1772
+ by either the function annotation or the operand bundles.
1733
1773
``minsize``
1734
1774
This attribute suggests that optimization passes and code generator
1735
1775
passes make choices that keep the code size of this function as small
0 commit comments