Skip to content

CmmToC: emit explicit tail calls when the C compiler supports it

Cheng Shao requested to merge TerrorJack/ghc:unreg-tail-call into master

CmmToC: emit explicit tail calls when the C compiler supports it

Clang 13+ supports annotating a return statement using the musttail attribute, which guarantees that it lowers to a tail call if compilation succeeds.

This patch takes advantage of that feature for the unregisterised code generator. The configure scripts tests availability of the musttail attribute, if it's available, the Cmm tail calls will become C tail calls that avoids the mini interpreter trampoline overhead. Nothing is affected if the musttail attribute is not supported.

Clang documentation: https://clang.llvm.org/docs/AttributeReference.html#musttail

Merge request reports