[PATCH] D98684: [LangRef] state that align assume op bundle may take an extra argument

Juneyoung Lee via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 16 01:11:20 PDT 2021


aqjune created this revision.
aqjune added reviewers: jdoerfert, Tyker.
aqjune requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

As discussed in D90529 <https://reviews.llvm.org/D90529>, this patch adds statements about `"align"(i8* ptr, i64 a, i64 b)`.

Besides this, small non-functional edits are added:

- Small edits to assume op bundle's lexical grammar
- A clarification that align/nonnull also raises UB
- etc


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D98684

Files:
  llvm/docs/LangRef.rst


Index: llvm/docs/LangRef.rst
===================================================================
--- llvm/docs/LangRef.rst
+++ llvm/docs/LangRef.rst
@@ -2242,37 +2242,48 @@
 
 ::
 
-      "<tag>"([ <holds for value> [, <attribute argument>] ])
+      "<tag>"(<ty> <holds for value>{, <ty> <attribute argument>}*)
 
 * 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 <int_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 <int_assume>` ``%val`` has an alignment of at least 8.
+:ref:`llvm.assume <int_assume>` ``%val`` has an alignment of at least 8
+because it is otherwise undefined behavior.
+
+:ref:`llvm.assume <int_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 <int_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 <int_assume>` call location is cold, and ``%val`` is not
+null.
 
-Just like for the argument of :ref:`llvm.assume <int_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


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D98684.330895.patch
Type: text/x-patch
Size: 2886 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210316/783a6fbd/attachment.bin>


More information about the llvm-commits mailing list