[llvm] [ARM/X86] Standardize the isEligibleForTailCallOptimization prototypes (PR #90688)

Reid Kleckner via llvm-commits llvm-commits at lists.llvm.org
Wed May 1 11:26:48 PDT 2024


================
@@ -2723,11 +2722,19 @@ bool MatchingStackOffset(SDValue Arg, unsigned Offset, ISD::ArgFlagsTy Flags,
 
 /// Check whether the call is eligible for tail call optimization. Targets
 /// that want to do tail call optimization should implement this function.
+/// Note that musttail calls are not checked for eligibility, so the backend
+/// must support forwarding arguments of any type.
----------------
rnk wrote:

What you said is true for the ARM backend, but this is the X86 backend, where the opposite is true, so I think this is correct as written. This was a point of disagreement in the past, how to approach musttail call eligibility checks.

The ARM backend is extremely conservative, resulting in rejecting tail calls we can probably support (sret forwarding). The X86 backend aggressively assumes it can support everything, because it already does in order to support GuaranteedTCO (not supported by ARM). In practice, this does result in miscompilations (byval forwarding, https://github.com/llvm/llvm-project/issues/46402), so there is a tradeoff between optimistic and conservative.

https://github.com/llvm/llvm-project/pull/90688


More information about the llvm-commits mailing list