diff --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst --- a/llvm/docs/LangRef.rst +++ b/llvm/docs/LangRef.rst @@ -2242,37 +2242,48 @@ :: - ""([ [, ] ]) + ""( {, }*) * The tag of the operand bundle is usually the name of attribute that can be assumed to hold. It can also be `ignore`, this tag doesn't contain any information and should be ignored. * The first argument if present is the value for which the attribute hold. -* The second argument if present is an argument of the attribute. + If there are no arguments the attribute is a property of the call location. +* The following argument(s) if present is argument(s) of the attribute. -If there are no arguments the attribute is a property of the call location. - -If the represented attribute expects a constant argument, the argument provided -to the operand bundle should be a constant as well. - -For example: +Just like for the argument of :ref:`llvm.assume `, if any of the +provided guarantees are violated at runtime the behavior is undefined. +This also applies to attributes whose violation in a function call is defined +to yield poison, such as ``"nonnull"`` and ``"align"``. +For example, .. code-block:: llvm call void @llvm.assume(i1 true) ["align"(i32* %val, i32 8)] allows the optimizer to assume that at location of call to -:ref:`llvm.assume ` ``%val`` has an alignment of at least 8. +:ref:`llvm.assume ` ``%val`` has an alignment of at least 8 +because it is otherwise undefined behavior. + +:ref:`llvm.assume `'s condition still has an effect even if +operand bundles exist. For example, .. code-block:: llvm call void @llvm.assume(i1 %cond) ["cold"(), "nonnull"(i64* %val)] -allows the optimizer to assume that the :ref:`llvm.assume ` -call location is cold and that ``%val`` may not be null. +allows the optimizer to assume that ``%cond`` is true, +the :ref:`llvm.assume ` call location is cold, and ``%val`` is not +null. -Just like for the argument of :ref:`llvm.assume `, if any of the -provided guarantees are violated at runtime the behavior is undefined. +``"align"`` optionally takes a second argument. +``"align"(i8* ptr, i64 a, i64 ofs)`` is equivalent to GCC's +``__builtin_assume_aligned(ptr, a, ofs)`` and states that ``ptr - ofs`` is +``a``-bytes aligned. + +If the represented attribute expects a constant argument, the argument provided +to the operand bundle should be a constant as well. +For example, ``"align"`` can only take a constant as its attribute argument. Even if the assumed property can be encoded as a boolean value, like ``nonnull``, using operand bundles to express the property can still have