Skip to content

Commit 9d9de5a

Browse files
committed
[LangRef] Add memory attribute
This adds the LangRef wording for the memory attribute proposed at https://discourse.llvm.org/t/rfc-unify-memory-effect-attributes/65579. The old attributes are not removed from LangRef until the migration is finished. Differential Revision: https://reviews.llvm.org/D135597
1 parent 39d8597 commit 9d9de5a

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

llvm/docs/LangRef.rst

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1730,6 +1730,46 @@ example:
17301730
a new pointer for the original function, which means that code that depends
17311731
on function-pointer identity can break. So, any function annotated with
17321732
``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.
17331773
``minsize``
17341774
This attribute suggests that optimization passes and code generator
17351775
passes make choices that keep the code size of this function as small

0 commit comments

Comments
 (0)