Skip to content

Commit 7113010

Browse files
[LangRef] Add a description of the semantics of call signatures. (#136189)
This doesn't introduce anything new; it's just a reflection of the semantics we've already had for many years. Per discussion on #63484.
1 parent b3d2dc3 commit 7113010

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

llvm/docs/LangRef.rst

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9475,10 +9475,11 @@ This instruction requires several arguments:
94759475
from the :ref:`datalayout string<langref_datalayout>` will be used.
94769476
#. '``ty``': the type of the call instruction itself which is also the
94779477
type of the return value. Functions that return no value are marked
9478-
``void``.
9478+
``void``. The signature is computed based on the return type and argument
9479+
types.
94799480
#. '``fnty``': shall be the signature of the function being invoked. The
94809481
argument types must match the types implied by this signature. This
9481-
type can be omitted if the function is not varargs.
9482+
is only required if the signature specifies a varargs type.
94829483
#. '``fnptrval``': An LLVM value containing a pointer to a function to
94839484
be invoked. In most cases, this is a direct function invocation, but
94849485
indirect ``invoke``'s are just as possible, calling an arbitrary pointer
@@ -9571,10 +9572,11 @@ This instruction requires several arguments:
95719572
from the :ref:`datalayout string<langref_datalayout>` will be used.
95729573
#. '``ty``': the type of the call instruction itself which is also the
95739574
type of the return value. Functions that return no value are marked
9574-
``void``.
9575+
``void``. The signature is computed based on the return type and argument
9576+
types.
95759577
#. '``fnty``': shall be the signature of the function being called. The
95769578
argument types must match the types implied by this signature. This
9577-
type can be omitted if the function is not varargs.
9579+
is only required if the signature specifies a varargs type.
95789580
#. '``fnptrval``': An LLVM value containing a pointer to a function to
95799581
be called. In most cases, this is a direct function call, but
95809582
other ``callbr``'s are just as possible, calling an arbitrary pointer
@@ -13127,10 +13129,11 @@ This instruction requires several arguments:
1312713129
from the :ref:`datalayout string<langref_datalayout>` will be used.
1312813130
#. '``ty``': the type of the call instruction itself which is also the
1312913131
type of the return value. Functions that return no value are marked
13130-
``void``.
13132+
``void``. The signature is computed based on the return type and argument
13133+
types.
1313113134
#. '``fnty``': shall be the signature of the function being called. The
1313213135
argument types must match the types implied by this signature. This
13133-
type can be omitted if the function is not varargs.
13136+
is only required if the signature specifies a varargs type.
1313413137
#. '``fnptrval``': An LLVM value containing a pointer to a function to
1313513138
be called. In most cases, this is a direct function call, but
1313613139
indirect ``call``'s are just as possible, calling an arbitrary pointer
@@ -13152,6 +13155,16 @@ values. Upon a '``ret``' instruction in the called function, control
1315213155
flow continues with the instruction after the function call, and the
1315313156
return value of the function is bound to the result argument.
1315413157

13158+
If the callee refers to an intrinsic function, the signature of the call must
13159+
match the signature of the callee. Otherwise, if the signature of the call
13160+
does not match the signature of the called function, the behavior is
13161+
target-specific. For a significant mismatch, this likely results in undefined
13162+
behavior. LLVM interprocedural optimizations generally only optimize calls
13163+
where the signature of the caller matches the signature of the callee.
13164+
13165+
Note that it is possible for the signatures to mismatch even if a call appears
13166+
to be a "direct" call, like ``call void @f()``.
13167+
1315513168
Example:
1315613169
""""""""
1315713170

0 commit comments

Comments
 (0)