[PATCH] D105807: [X86] pr51000 struct return tailcalling

Josh Haberman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 12 09:00:02 PDT 2021


haberman added a comment.

When I implemented `[[clang::musttail]]`, I wasn't aware that there were cases like this, where `musttail` in the IR would pass IR verification, but then a tail call would fail to generate in the backend. The IR documentation for musttail <https://llvm.org/docs/LangRef.html#id327> doesn't warn about this case.

Since implementing the attribute, I've become aware of other examples of this problem. For example, PowerPC fails to generate tail calls in several cases, throwing an error like:

  fatal error: error in backend: failed to perform tail call elimination on a call site marked musttail



> It definitely means there *must* be a tail call here, otherwise we will use unbounded amount of stack :)

I agree with this, `[[clang::musttail]]` is supposed to provide a guarantee.

I'm not sure the right way to proceed here. Clang should issue a diagnostic and fail if a tail call is not possible. But only the backend knows authoritatively if a tail call is possible or not.

Do we need a way to query the backend? eg. expose `IsEligibleForTailCallOptimization()` or similar to front-ends like Clang?


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

https://reviews.llvm.org/D105807



More information about the llvm-commits mailing list