Skip to content

[LangRef] Fix code segment and numbering issue in the 'call' instruction section #122294

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 10, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 26 additions & 28 deletions llvm/docs/LangRef.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12759,11 +12759,11 @@ This instruction requires several arguments:
attributes like "disable-tail-calls". The ``musttail`` marker provides these
guarantees:

#. The call will not cause unbounded stack growth if it is part of a
- The call will not cause unbounded stack growth if it is part of a
recursive cycle in the call graph.
#. Arguments with the :ref:`inalloca <attr_inalloca>` or
- Arguments with the :ref:`inalloca <attr_inalloca>` or
:ref:`preallocated <attr_preallocated>` attribute are forwarded in place.
#. If the musttail call appears in a function with the ``"thunk"`` attribute
- If the musttail call appears in a function with the ``"thunk"`` attribute
and the caller and callee both have varargs, then any unprototyped
arguments in register or memory are forwarded to the callee. Similarly,
the return value of the callee is returned to the caller's caller, even
Expand All @@ -12774,7 +12774,7 @@ This instruction requires several arguments:
argument may be passed to the callee as a byval argument, which can be
dereferenced inside the callee. For example:

.. code-block:: llvm
.. code-block:: llvm

declare void @take_byval(ptr byval(i64))
declare void @take_ptr(ptr)
Expand Down Expand Up @@ -12828,43 +12828,41 @@ This instruction requires several arguments:
ret void
}


Calls marked ``musttail`` must obey the following additional rules:

- The call must immediately precede a :ref:`ret <i_ret>` instruction,
or a pointer bitcast followed by a ret instruction.
- The ret instruction must return the (possibly bitcasted) value
produced by the call, undef, or void.
- The calling conventions of the caller and callee must match.
- The callee must be varargs iff the caller is varargs. Bitcasting a
non-varargs function to the appropriate varargs type is legal so
long as the non-varargs prefixes obey the other rules.
- The return type must not undergo automatic conversion to an `sret` pointer.
- The call must immediately precede a :ref:`ret <i_ret>` instruction,
or a pointer bitcast followed by a ret instruction.
- The ret instruction must return the (possibly bitcasted) value
produced by the call, undef, or void.
- The calling conventions of the caller and callee must match.
- The callee must be varargs iff the caller is varargs. Bitcasting a
non-varargs function to the appropriate varargs type is legal so
long as the non-varargs prefixes obey the other rules.
- The return type must not undergo automatic conversion to an `sret` pointer.

In addition, if the calling convention is not `swifttailcc` or `tailcc`:
In addition, if the calling convention is not `swifttailcc` or `tailcc`:

- All ABI-impacting function attributes, such as sret, byval, inreg,
returned, and inalloca, must match.
- The caller and callee prototypes must match. Pointer types of parameters
or return types may differ in pointee type, but not in address space.
- All ABI-impacting function attributes, such as sret, byval, inreg,
returned, and inalloca, must match.
- The caller and callee prototypes must match. Pointer types of parameters
or return types may differ in pointee type, but not in address space.

On the other hand, if the calling convention is `swifttailcc` or `tailcc`:
On the other hand, if the calling convention is `swifttailcc` or `tailcc`:

- Only these ABI-impacting attributes attributes are allowed: sret, byval,
swiftself, and swiftasync.
- Prototypes are not required to match.
- Only these ABI-impacting attributes attributes are allowed: sret, byval,
swiftself, and swiftasync.
- Prototypes are not required to match.

Tail call optimization for calls marked ``tail`` is guaranteed to occur if
the following conditions are met:

- Caller and callee both have the calling convention ``fastcc`` or ``tailcc``.
- The call is in tail position (ret immediately follows call and ret
uses value of call or is void).
- Option ``-tailcallopt`` is enabled,
``llvm::GuaranteedTailCallOpt`` is ``true``, or the calling convention
is ``tailcc``
- `Platform-specific constraints are
met. <CodeGenerator.html#tail-call-optimization>`_
- Option ``-tailcallopt`` is enabled, ``llvm::GuaranteedTailCallOpt`` is
``true``, or the calling convention is ``tailcc``.
- `Platform-specific constraints are met.
<CodeGenerator.html#tail-call-optimization>`_

#. The optional ``notail`` marker indicates that the optimizers should not add
``tail`` or ``musttail`` markers to the call. It is used to prevent tail
Expand Down
Loading