@@ -1587,8 +1587,6 @@ Currently, only the following parameter attributes are defined:
15871587 :ref:`bitcast instruction <i_bitcast>`. This is not a valid attribute for
15881588 return values and can only be applied to one parameter.
15891589
1590- .. _attr_nonnull:
1591-
15921590``nonnull``
15931591 This indicates that the parameter or return pointer is not null. This
15941592 attribute may only be applied to pointer-typed parameters. This is not
@@ -1600,8 +1598,6 @@ Currently, only the following parameter attributes are defined:
16001598 The ``nonnull`` attribute should be combined with the ``noundef`` attribute
16011599 to ensure a pointer is not null or otherwise the behavior is undefined.
16021600
1603- .. _attr_dereferenceable:
1604-
16051601``dereferenceable(<n>)``
16061602 This indicates that the parameter or return pointer is dereferenceable. This
16071603 attribute may only be applied to pointer-typed parameters. A pointer that
@@ -1614,9 +1610,9 @@ Currently, only the following parameter attributes are defined:
16141610 ``null_pointer_is_valid`` function attribute is present.
16151611 ``n`` should be a positive number. The pointer should be well defined,
16161612 otherwise it is undefined behavior. This means ``dereferenceable(<n>)``
1617- implies ``noundef``.
1618-
1619- .. _attr_dereferenceable_or_null:
1613+ implies ``noundef``. When used in an assume operand bundle, more restricted
1614+ semantics apply. See :ref:`assume operand bundles <assume_opbundles>` for
1615+ more details.
16201616
16211617``dereferenceable_or_null(<n>)``
16221618 This indicates that the parameter or return value isn't both
@@ -1671,8 +1667,6 @@ Currently, only the following parameter attributes are defined:
16711667 only valid on intrinsic declarations and cannot be applied to a
16721668 call site or arbitrary function.
16731669
1674- .. _attr_noundef:
1675-
16761670``noundef``
16771671 This attribute applies to parameters and return values. If the value
16781672 representation contains any undefined or poison bits, the behavior is
@@ -2155,9 +2149,6 @@ For example:
21552149 uses the ``nobuiltin`` attribute. This is only valid at call sites for
21562150 direct calls to functions that are declared with the ``nobuiltin``
21572151 attribute.
2158-
2159- .. _attr_cold:
2160-
21612152``cold``
21622153 This attribute indicates that this function is rarely called. When
21632154 computing edge weights, basic blocks post-dominated by a cold
@@ -3136,57 +3127,33 @@ Assume Operand Bundles
31363127^^^^^^^^^^^^^^^^^^^^^^
31373128
31383129Operand bundles on an :ref:`llvm.assume <int_assume>` allow representing
3139- assumptions that hold at the location of the assume. Operand bundles enable
3140- assumptions that are either hard or impossible to represent as a boolean
3141- argument of an :ref:`llvm.assume <int_assume>`.
3130+ assumptions, such as that a :ref:`parameter attribute <paramattrs>` or a
3131+ :ref:`function attribute <fnattrs>` holds for a certain value at a certain
3132+ location. Operand bundles enable assumptions that are either hard or impossible
3133+ to represent as a boolean argument of an :ref:`llvm.assume <int_assume>`.
31423134
31433135Assumes with operand bundles must have ``i1 true`` as the condition operand.
31443136
3145- Just like for the argument of :ref:`llvm.assume <int_assume>`, if any of the
3146- provided guarantees are violated at runtime the behavior is undefined.
3137+ An assume operand bundle has the form:
31473138
3148- While attributes expect constant arguments, assume operand bundles may be
3149- provided a dynamic value, for example:
3150-
3151- .. code-block:: llvm
3152-
3153- call void @llvm.assume(i1 true) ["align"(ptr %val, i32 %align)]
3154-
3155- The following attributes are currently accepted:
3156-
3157- ``"align"(ptr %p, i64 %align)``, ``"align"(ptr %p, i64 %align, i64 %offset)``
3158- Equivalent to :ref:`align(%align) <attr_align>` on ``%p``, or ``%p - %offset``
3159- if the ``%offset`` argument exists, except that ``%align`` may be a
3160- non-power-of-two alignment (including a zero alignment). If ``%align`` is not
3161- a power of two the pointer value must be all-zero. Otherwise the behavior is
3162- undefined.
3163-
3164- ``"cold"()``
3165- Equivalent to :ref:`cold <attr_cold>`.
3139+ ::
31663140
3167- ``"dereferenceable"(ptr %p, i64 %size)``
3168- Equivalent to :ref:`dereferenceable(%size) <attr_dereferenceable>` on ``%p``,
3169- except that ``%size`` may also be zero, in which case the bundle doesn't
3170- imply ``nonnull``.
3141+ "<tag>"([ <arguments>] ])
31713142
3172- ``"dereferenceable_or_null"(ptr %p, i64 %size)``
3173- Equivalent to :ref:`dereferenceable_or_null(%size)
3174- <attr_dereferenceable_or_null>` on ``%p``, except that ``%size`` may also be
3175- zero.
3143+ In the case of function or parameter attributes, the operand bundle has the
3144+ restricted form:
31763145
3177- ``"ignore"(...)``
3178- Doesn't imply anything and is ignored. This is used to drop an assume where
3179- the ``llvm.assume`` call cannot be replaced or dropped.
3146+ ::
31803147
3181- ``"nonnull"(ptr %p)``
3182- Equivalent to :ref:`nonnull <attr_nonnull>` on ``%p``.
3148+ "<tag>"([ <holds for value> [, <attribute argument>] ])
31833149
3184- ``"noundef"(any_type %v)``
3185- Equivalent to :ref:`noundef <attr_noundef>` on ``%v``.
3150+ * The tag of the operand bundle is usually the name of the attribute that can be
3151+ assumed to hold. It can also be `ignore`; this tag doesn't contain any
3152+ information and should be ignored.
3153+ * The first argument, if present, is the value for which the attribute holds.
3154+ * The second argument, if present, is an argument of the attribute.
31863155
3187- ``"separate_storage"(ptr %p1, ptr %p2)``
3188- This indicates that no pointer :ref:`based <pointeraliasing>` on one of its
3189- arguments can alias any pointer based on the other.
3156+ If there are no arguments the attribute is a property of the call location.
31903157
31913158For example:
31923159
@@ -3204,6 +3171,39 @@ allows the optimizer to assume that at location of call to
32043171allows the optimizer to assume that the :ref:`llvm.assume <int_assume>`
32053172call location is cold and that ``%val`` may not be null.
32063173
3174+ Just like for the argument of :ref:`llvm.assume <int_assume>`, if any of the
3175+ provided guarantees are violated at runtime the behavior is undefined.
3176+
3177+ While attributes expect constant arguments, assume operand bundles may be
3178+ provided a dynamic value, for example:
3179+
3180+ .. code-block:: llvm
3181+
3182+ call void @llvm.assume(i1 true) ["align"(ptr %val, i32 %align)]
3183+
3184+ If the operand bundle value violates any requirements on the attribute value,
3185+ the behavior is undefined, unless one of the following exceptions applies:
3186+
3187+ * ``"align"`` operand bundles may specify a non-power-of-two alignment
3188+ (including a zero alignment). If this is the case, then the pointer value
3189+ must be an all-zero pointer, otherwise the behavior is undefined.
3190+
3191+ * ``dereferenceable(<n>)`` operand bundles only guarantee the pointer is
3192+ dereferenceable at the point of the assumption. The pointer may not be
3193+ dereferenceable at later pointers, e.g., because it could have been freed.
3194+ Only ``n > 0`` implies that the pointer is dereferenceable.
3195+
3196+ In addition to allowing operand bundles encoding function and parameter
3197+ attributes, an assume operand bundle may also encode a ``separate_storage``
3198+ operand bundle. This has the form:
3199+
3200+ .. code-block:: llvm
3201+
3202+ separate_storage(<val1>, <val2>)``
3203+
3204+ This indicates that no pointer :ref:`based <pointeraliasing>` on one of its
3205+ arguments can alias any pointer based on the other.
3206+
32073207Even if the assumed property can be encoded as a boolean value, like
32083208``nonnull``, using operand bundles to express the property can still have
32093209benefits:
@@ -8143,7 +8143,7 @@ Together these two attributes provide a four-way classification:
81438143
81448144- ``body`` only: main vectorized loop body
81458145- ``epilogue`` only: scalar epilogue loop after vectorization
8146- - Both ``body`` and ``epilogue``: vectorized epilogue
8146+ - Both ``body`` and ``epilogue``: vectorized epilogue
81478147 (a remainder loop that was itself vectorized during epilogue
81488148 vectorization)
81498149- Neither: a plain loop not produced by the vectorizer
@@ -8772,7 +8772,7 @@ is executed, followed by ``uint64_t`` value and execution count pairs.
87728772The value profiling kind is 0 for indirect call targets and 1 for memory
87738773operations. For indirect call targets, each profile value is a hash
87748774of the callee function name, and for memory operations each value is the
8775- byte length. It is illegal to have duplicate profile values (e.g.,
8775+ byte length. It is illegal to have duplicate profile values (e.g.,
87768776duplicate function hashes for indirect calls or byte lengths for memory
87778777operations).
87788778
0 commit comments