diff options
| author | Reid Kleckner <rnk@google.com> | 2019-10-07 22:28:58 +0000 |
|---|---|---|
| committer | Reid Kleckner <rnk@google.com> | 2019-10-07 22:28:58 +0000 |
| commit | f9b67b810e2d413606b0d5891ed9477d819bcab9 (patch) | |
| tree | f5bc8a674f930c49b92f653ea7e46be53f13c084 /llvm/docs | |
| parent | daeead4b02f062bf5a21e154ab7726b3e1dd41bd (diff) | |
| download | bcm5719-llvm-f9b67b810e2d413606b0d5891ed9477d819bcab9.tar.gz bcm5719-llvm-f9b67b810e2d413606b0d5891ed9477d819bcab9.zip | |
[X86] Add new calling convention that guarantees tail call optimization
When the target option GuaranteedTailCallOpt is specified, calls with
the fastcc calling convention will be transformed into tail calls if
they are in tail position. This diff adds a new calling convention,
tailcc, currently supported only on X86, which behaves the same way as
fastcc, except that the GuaranteedTailCallOpt flag does not need to
enabled in order to enable tail call optimization.
Patch by Dwight Guth <dwight.guth@runtimeverification.com>!
Reviewed By: lebedev.ri, paquette, rnk
Differential Revision: https://reviews.llvm.org/D67855
llvm-svn: 373976
Diffstat (limited to 'llvm/docs')
| -rw-r--r-- | llvm/docs/BitCodeFormat.rst | 1 | ||||
| -rw-r--r-- | llvm/docs/CodeGenerator.rst | 4 | ||||
| -rw-r--r-- | llvm/docs/LangRef.rst | 17 |
3 files changed, 16 insertions, 6 deletions
diff --git a/llvm/docs/BitCodeFormat.rst b/llvm/docs/BitCodeFormat.rst index 4e653ae55d5..dce84620fd7 100644 --- a/llvm/docs/BitCodeFormat.rst +++ b/llvm/docs/BitCodeFormat.rst @@ -794,6 +794,7 @@ function. The operand fields are: * ``preserve_allcc``: code 15 * ``swiftcc`` : code 16 * ``cxx_fast_tlscc``: code 17 + * ``tailcc`` : code 18 * ``x86_stdcallcc``: code 64 * ``x86_fastcallcc``: code 65 * ``arm_apcscc``: code 66 diff --git a/llvm/docs/CodeGenerator.rst b/llvm/docs/CodeGenerator.rst index 343b9879972..75330a5df3b 100644 --- a/llvm/docs/CodeGenerator.rst +++ b/llvm/docs/CodeGenerator.rst @@ -2068,12 +2068,12 @@ supported on x86/x86-64, PowerPC, and WebAssembly. It is performed on x86/x86-64 and PowerPC if: * Caller and callee have the calling convention ``fastcc``, ``cc 10`` (GHC - calling convention) or ``cc 11`` (HiPE calling convention). + calling convention), ``cc 11`` (HiPE calling convention), or ``tailcc``. * The call is a tail call - in tail position (ret immediately follows call and ret uses value of call or is void). -* Option ``-tailcallopt`` is enabled. +* Option ``-tailcallopt`` is enabled or the calling convention is ``tailcc``. * Platform-specific constraints are met. diff --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst index d9a38907c92..e797b1f9a15 100644 --- a/llvm/docs/LangRef.rst +++ b/llvm/docs/LangRef.rst @@ -299,7 +299,7 @@ added in the future: allows the target to use whatever tricks it wants to produce fast code for the target, without having to conform to an externally specified ABI (Application Binary Interface). `Tail calls can only - be optimized when this, the GHC or the HiPE convention is + be optimized when this, the tailcc, the GHC or the HiPE convention is used. <CodeGenerator.html#id80>`_ This calling convention does not support varargs and requires the prototype of all callees to exactly match the prototype of the function definition. @@ -436,6 +436,14 @@ added in the future: - On X86-64 RCX and R8 are available for additional integer returns, and XMM2 and XMM3 are available for additional FP/vector returns. - On iOS platforms, we use AAPCS-VFP calling convention. +"``tailcc``" - Tail callable calling convention + This calling convention ensures that calls in tail position will always be + tail call optimized. This calling convention is equivalent to fastcc, + except for an additional guarantee that tail calls will be produced + whenever possible. `Tail calls can only be optimized when this, the fastcc, + the GHC or the HiPE convention is used. <CodeGenerator.html#id80>`_ This + calling convention does not support varargs and requires the prototype of + all callees to exactly match the prototype of the function definition. "``cc <n>``" - Numbered convention Any calling convention may be specified by number, allowing target-specific calling conventions to be used. Target specific @@ -10232,11 +10240,12 @@ This instruction requires several arguments: 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``. + - 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, or - ``llvm::GuaranteedTailCallOpt`` is ``true``. + - Option ``-tailcallopt`` is enabled, + ``llvm::GuaranteedTailCallOpt`` is ``true``, or the calling convention + is ``tailcc`` - `Platform-specific constraints are met. <CodeGenerator.html#tailcallopt>`_ |

