Skip to content

Commit c95daac

Browse files
fhahnnunoplopes
andauthored
[LangRef] Spell out alias attribute/metadata violations are UB. (#116220)
Update the documentation for the noalias attribute, !alias.scope and !loop.parallel_accesses metadata to clarify they are UB on voilation the noalias property. PR: #116220 --------- Co-authored-by: Nuno Lopes <[email protected]>
1 parent 51809e4 commit c95daac

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

llvm/docs/LangRef.rst

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1360,11 +1360,13 @@ Currently, only the following parameter attributes are defined:
13601360
accessed, during the execution of the function, via pointer values not
13611361
*based* on the argument or return value. This guarantee only holds for
13621362
memory locations that are *modified*, by any means, during the execution of
1363-
the function. The attribute on a return value also has additional semantics
1364-
described below. The caller shares the responsibility with the callee for
1365-
ensuring that these requirements are met. For further details, please see
1366-
the discussion of the NoAlias response in :ref:`alias analysis <Must, May,
1367-
or No>`.
1363+
the function. If there are other accesses not based on the argument or
1364+
return value, the behavior is undefined. The attribute on a return value
1365+
also has additional semantics described below. The caller shares the
1366+
responsibility with the callee for described below. The caller shares the
1367+
responsibility with the callee for ensuring that these requirements are met.
1368+
For further details, please see the discussion of the NoAlias response in
1369+
:ref:`alias analysis <Must, May, or No>`.
13681370

13691371
Note that this definition of ``noalias`` is intentionally similar
13701372
to the definition of ``restrict`` in C99 for function arguments.
@@ -6816,7 +6818,9 @@ tuples this way:
68166818
A memory access with an access tag ``(BaseTy1, AccessTy1, Offset1)``
68176819
aliases a memory access with an access tag ``(BaseTy2, AccessTy2,
68186820
Offset2)`` if either ``(BaseTy1, Offset1)`` is reachable from ``(Base2,
6819-
Offset2)`` via the ``Parent`` relation or vice versa.
6821+
Offset2)`` via the ``Parent`` relation or vice versa. If memory accesses
6822+
alias even though they are noalias according to ``!tbaa`` metadata, the
6823+
behavior is undefined.
68206824

68216825
As a concrete example, the type descriptor graph for the following program
68226826

@@ -6936,9 +6940,9 @@ does not carry useful data and need not be preserved.
69366940
noalias memory-access sets. This means that some collection of memory access
69376941
instructions (loads, stores, memory-accessing calls, etc.) that carry
69386942
``noalias`` metadata can specifically be specified not to alias with some other
6939-
collection of memory access instructions that carry ``alias.scope`` metadata.
6940-
Each type of metadata specifies a list of scopes where each scope has an id and
6941-
a domain.
6943+
collection of memory access instructions that carry ``alias.scope`` metadata. If
6944+
accesses from different collections alias, the behavior is undefined. Each type
6945+
of metadata specifies a list of scopes where each scope has an id and a domain.
69426946

69436947
When evaluating an aliasing query, if for some domain, the set
69446948
of scopes with that domain in one instruction's ``alias.scope`` list is a
@@ -7695,7 +7699,8 @@ If all memory-accessing instructions in a loop have
76957699
``llvm.access.group`` metadata that each refer to one of the access
76967700
groups of a loop's ``llvm.loop.parallel_accesses`` metadata, then the
76977701
loop has no loop carried memory dependencies and is considered to be a
7698-
parallel loop.
7702+
parallel loop. If there is a loop-carried dependency, the behavior is
7703+
undefined.
76997704

77007705
Note that if not all memory access instructions belong to an access
77017706
group referred to by ``llvm.loop.parallel_accesses``, then the loop must

0 commit comments

Comments
 (0)