[PATCH] D99517: Implemented [[clang::musttail]] attribute for guaranteed tail calls.

David Chisnall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 29 01:40:48 PDT 2021


theraven added a comment.

The error message here is very confusing:

  /home/theraven/snmalloc2/src/mem/../ds/../aal/../ds/defines.h:122:27: error: cannot perform a tail call to function 'error' because its signature is incompatible with the calling function
        [[clang::musttail]] return snmalloc::error(str);
                            ^
  /home/theraven/snmalloc2/src/mem/../ds/../aal/../ds/defines.h:63:16: note: target function has different number of parameters (expected 2 but has 1)
    [[noreturn]] SNMALLOC_COLD void error(const char* const str);
                 ^
  /home/theraven/snmalloc2/src/mem/../ds/../aal/../ds/defines.h:21:25: note: expanded from macro 'SNMALLOC_COLD'
  #  define SNMALLOC_COLD __attribute__((cold))
                          ^
  /home/theraven/snmalloc2/src/mem/../ds/../aal/../ds/defines.h:122:9: note: tail call required by 'musttail' attribute here
        [[clang::musttail]] return snmalloc::error(str);
          ^

The caller and callee both have one argument, the error is because the enclosing function has two parameters.  The error appears wrong anyway for two reasons in this particular context:

- The callee is `[[noreturn]]`, so the stack layout doesn't make any difference, anything can be tail called if it's no-return.
- The enclosing function is `always_inline`, so checking its argument-frame layout does not give useful information because it's the caller's argument-frame layout that matters.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D99517/new/

https://reviews.llvm.org/D99517



More information about the cfe-commits mailing list