[clang] [clang][bytecode] Use tailcalls via `[[clang::musttail]]` (PR #173756)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Dec 29 05:17:25 PST 2025
Timm =?utf-8?q?Bäder?= <tbaeder at redhat.com>,
Timm =?utf-8?q?Bäder?= <tbaeder at redhat.com>
Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/173756 at github.com>
https://github.com/Sirraide commented:
This is definitely an interesting idea, especially seeing as it lets us get rid of the `#pragma optimize("", on)` jank. Have you tested this with different compilers to see how they optimise this (as in, build Clang itself w/ e.g. GCC or MSVC)?
Speaking of other compilers, `preserve_none` as a calling convention is probably a good idea to keep more state in registers, but I think we should spell it `[[clang::preserve_none]]`, and it should be behind a macro since GCC doesn’t support it.
As for forcing tail calls, GCC does support `[[clang::musttail]]`, but for MSVC, we should probably spell it `[[msvc::musttail]]`, and another issue would be that tail calls are apparently [only supported when optimisations are enabled](https://learn.microsoft.com/en-us/cpp/cpp/attributes?view=msvc-170#msvcmusttail):
> the numbers on the compile-time tracker are slightly worse
>From what I can tell it’s mainly just the file size that’s worse; the other numbers mainly just look like noise to me.
https://github.com/llvm/llvm-project/pull/173756
More information about the cfe-commits
mailing list