@@ -1160,22 +1160,40 @@ The return type and each parameter of a function type may have a set of
1160
1160
used to communicate additional information about the result or
1161
1161
parameters of a function. Parameter attributes are considered to be part
1162
1162
of the function, not of the function type, so functions with different
1163
- parameter attributes can have the same function type.
1163
+ parameter attributes can have the same function type. Parameter attributes can
1164
+ be placed both on function declarations/definitions, and at call-sites.
1164
1165
1165
1166
Parameter attributes are either simple keywords or strings that follow the
1166
1167
specified type. Multiple parameter attributes, when required, are separated by
1167
1168
spaces. For example:
1168
1169
1169
1170
.. code-block:: llvm
1170
1171
1172
+ ; On function declarations/definitions:
1171
1173
declare i32 @printf(ptr noalias nocapture, ...)
1172
1174
declare i32 @atoi(i8 zeroext)
1173
1175
declare signext i8 @returns_signed_char()
1174
1176
define void @baz(i32 "amdgpu-flat-work-group-size"="1,256" %x)
1175
1177
1178
+ ; On call-sites:
1179
+ call i32 @atoi(i8 zeroext %x)
1180
+ call signext i8 @returns_signed_char()
1181
+
1176
1182
Note that any attributes for the function result (``nonnull``,
1177
1183
``signext``) come before the result type.
1178
1184
1185
+ Parameter attributes can be broadly separated into two kinds: ABI attributes
1186
+ that affect how values are passed to/from functions, like ``zeroext``,
1187
+ ``inreg``, ``byval``, or ``sret``. And optimization attributes, which provide
1188
+ additional optimization guarantees, like ``noalias``, ``nonnull`` and
1189
+ ``dereferenceable``.
1190
+
1191
+ ABI attributes must be specified *both* at the function declaration/definition
1192
+ and call-site, otherwise the behavior may be undefined. ABI attributes cannot
1193
+ be safely dropped. Optimization attributes do not have to match between
1194
+ call-site and function: The intersection of their implied semantics applies.
1195
+ Optimization attributes can also be freely dropped.
1196
+
1179
1197
If an integer argument to a function is not marked signext/zeroext/noext, the
1180
1198
kind of extension used is target-specific. Some targets depend for
1181
1199
correctness on the kind of extension to be explicitly specified.
@@ -1500,6 +1518,9 @@ Currently, only the following parameter attributes are defined:
1500
1518
undefined. Note that this does not refer to padding introduced by the
1501
1519
type's storage representation.
1502
1520
1521
+ If memory sanitizer is enabled, ``noundef`` becomes an ABI attribute and
1522
+ must match between the call-site and the function definition.
1523
+
1503
1524
.. _nofpclass:
1504
1525
1505
1526
``nofpclass(<test mask>)``
0 commit comments