On Thu, Mar 20, 2025 at 09:08:25AM +0100, Richard Biener wrote: > Hmm. I do wonder whether your earlier patch was more "correct" in the > sense that a tail call does not return to the calling function but its caller. > That means it should not have a fallthru edge, so our representation > with feeding a return value to a function-local return stmt isn't a good one.
Tail call certainly doesn't. But what we have in the IL right now, i.e. musttail marked call in the middle, isn't actually a tail call, it is a call that should be turned into a tail call or error should be reported. And that certainly returns to the caller (if it is not non-marked noreturn or say exits/aborts/longjmp/throws) and performs the statements in there and only then returns. So pretending it doesn't return is IMHO risky. We could only do that if we had in the IL something that would be a GIMPLE_RETURN combined with the GIMPLE_CALL. I bet that is how LLVM implements it, but then the discovery needs to be done in the FE, not late, clearly they don't bother with discovering address escaped automatic vars still in scope and just declare that UB, ... All we should ensure is that we don't add after such calls code which would turn those calls from successfully tail-callable into ones on which we error. Jakub