llvm.org GIT mirror llvm / 25eb40c
[LangRef] Clarify undefined behavior for function attributes. Violating the invariants specified by attributes is undefined behavior. Maybe we could use poison instead for some of the parameter attributes, but I don't think it's worthwhile. Differential Revision: https://reviews.llvm.org/D49041 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@337947 91177308-0d34-0410-b5e6-96231b3b80d8 Eli Friedman 1 year, 2 months ago
1 changed file(s) with 23 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
10471047
10481048 When the call site is reached, the argument allocation must have
10491049 been the most recent stack allocation that is still live, or the
1050 results are undefined. It is possible to allocate additional stack
1050 behavior is undefined. It is possible to allocate additional stack
10511051 space after an argument allocation and before its call site, but it
10521052 must be cleared off with :ref:`llvm.stackrestore
10531053 `.
11211121 ``nonnull``
11221122 This indicates that the parameter or return pointer is not null. This
11231123 attribute may only be applied to pointer typed parameters. This is not
1124 checked or enforced by LLVM, the caller must ensure that the pointer
1125 passed in is non-null, or the callee must ensure that the returned pointer
1126 is non-null.
1124 checked or enforced by LLVM; if the parameter or return pointer is null,
1125 the behavior is undefined.
11271126
11281127 ``dereferenceable()``
11291128 This indicates that the parameter or return pointer is dereferenceable. This
13861385 ``inaccessiblememonly``
13871386 This attribute indicates that the function may only access memory that
13881387 is not accessible by the module being compiled. This is a weaker form
1389 of ``readnone``.
1388 of ``readnone``. If the function reads or writes other memory, the
1389 behavior is undefined.
13901390 ``inaccessiblemem_or_argmemonly``
13911391 This attribute indicates that the function may only access memory that is
13921392 either not accessible by the module being compiled, or is pointed to
1393 by its pointer arguments. This is a weaker form of ``argmemonly``
1393 by its pointer arguments. This is a weaker form of ``argmemonly``. If the
1394 function reads or writes other memory, the behavior is undefined.
13941395 ``inlinehint``
13951396 This attribute indicates that the source code contained a hint that
13961397 inlining this function is desirable (such as the "inline" keyword in
15411542 On an argument, this attribute indicates that the function does not
15421543 dereference that pointer argument, even though it may read or write the
15431544 memory that the pointer points to if accessed through other pointers.
1545
1546 If a readnone function reads or writes memory visible to the program, or
1547 has other side-effects, the behavior is undefined. If a function reads from
1548 or writes to a readnone pointer argument, the behavior is undefined.
15441549 ``readonly``
15451550 On a function, this attribute indicates that the function does not write
15461551 through any pointer arguments (including ``byval`` arguments) or otherwise
15561561 On an argument, this attribute indicates that the function does not write
15571562 through this pointer argument, even though it may write to the memory that
15581563 the pointer points to.
1564
1565 If a readonly function writes memory visible to the program, or
1566 has other side-effects, the behavior is undefined. If a function writes to
1567 a readonly pointer argument, the behavior is undefined.
15591568 ``"stack-probe-size"``
15601569 This attribute controls the behavior of stack probes: either
15611570 the ``"probe-stack"`` attribute, or ABI-required stack probes, if any.
15801589 On an argument, this attribute indicates that the function may write to but
15811590 does not read through this pointer argument (even though it may read from
15821591 the memory that the pointer points to).
1592
1593 If a writeonly function reads memory visible to the program, or
1594 has other side-effects, the behavior is undefined. If a function reads
1595 from a writeonly pointer argument, the behavior is undefined.
15831596 ``argmemonly``
15841597 This attribute indicates that the only memory accesses inside function are
15851598 loads and stores from objects pointed to by its pointer-typed arguments,
15861599 with arbitrary offsets. Or in other words, all memory operations in the
15871600 function can refer to memory only using pointers based on its function
15881601 arguments.
1602
15891603 Note that ``argmemonly`` can be used together with ``readonly`` attribute
15901604 in order to specify that function reads only from its arguments.
1605
1606 If an argmemonly function reads or writes memory other than the pointer
1607 arguments, or has other side-effects, the behavior is undefined.
15911608 ``returns_twice``
15921609 This attribute indicates that this function can return twice. The C
15931610 ``setjmp`` is an example of such a function. The compiler disables