This is similar to the 'tail' marker, except that it guarantees that
tail call optimization will occur. It also comes with convervative IR
verification rules that ensure that tail call optimization is possible.
Details
Diff Detail
Event Timeline
include/llvm/IR/Instructions.h | ||
---|---|---|
1293–1294 | Wouldn't it make more sense to have setTailCall take an enum TailCallKind instead of having both setTailCall and setTailCallKind ? |
For the LangRef, I suggest we remove the text related to when a "tail"
call is guaranteed. With the addition of "musttail" these semantics are
redundant. Instead, "tail" should be advisory only. This would involve
breaking backwards compatibility.
With the new option, should GauranteedTailCallOpt exist? I suggest not.
In code, it would be useful to refer to the old "tail" attribute as "may
tail". This clarifies the semantics in code even if we don't change the
IR name. In particular, I'm referring to CallSite/Instruction here.
In the verifier you need to handle chains of bitcasts. These will
reduce to a single bitcast, but InstCombine may not have run yet. We
don't want each opto pass to need to do this simplification.
Otherwise, LGTM and I support the addition.
Philip
- {F53037, layout=link}
- Make the musttail property of a call immutable
- Add harder LangRef guarantees about arg forwarding and stack growth
I ended up leaving the docs on tail calls in. Removing that support is tricky, because I don't want musttail to change the calling convention of the call. As implemented, -tailcallopt changes the ABI of fastcc, GHC, and HiPE. I checked with GHC and HiPE, and they either never pass args in memory, or always use callee-pop.
But IMO we need to split fastcc into two ccs: one for guaranteed TCO and one for fast codegen. That feels like a big change that I should split out.
- Remove wording about the inliner and variadic arguments, since we don't have Ellipsis support yet
Wouldn't it make more sense to have setTailCall take an enum TailCallKind instead of having both setTailCall and setTailCallKind ?