https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119718
--- Comment #14 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Jakub Jelinek <ja...@gcc.gnu.org>: https://gcc.gnu.org/g:0562e17bd04b65aebff4721db05631b9f34af146 commit r15-9395-g0562e17bd04b65aebff4721db05631b9f34af146 Author: Jakub Jelinek <ja...@redhat.com> Date: Sat Apr 12 13:11:59 2025 +0200 tailc, expand: Tail call -fdump-{tree-tailc,expand-details} changes [PR119718] The following patch makes some adjustments so that users can analyze what calls weren't tail called even without using musttail attribute (though I'm still not convinced it should be a warning, because we don't distinguish between calls in return call (...); statements vs. calls that just happened to end up in tail positions because something has been optimized away etc. E.g. for int foo (int, int, int, int, int, int, int); int bar (int); void qux (int *); int baz (int x) { if (x) return foo (1, 2, 3, 4, 5, 6, 7); else { int y; qux (&y); return bar (x); } } ./xgcc -B ./ -S -O2 -fdump-{tree-tailc,rtl-expand}-details pr119718.c ; grep -B1 '^\(;; \)\?Cannot tail-call:' pr119718.c.* pr119718.c.222t.tailc-_7 = bar (0); pr119718.c.222t.tailc:Cannot tail-call: call invocation refers to locals -- pr119718.c.270r.expand-;; foo (1, 2, 3, 4, 5, 6, 7) [tail call] pr119718.c.270r.expand:;; Cannot tail-call: callee required more stack slots than the caller The changes are: 1) in tailc pass use wording more consistent with the musttail error wording 2) do it only in *-details dump 3) add similar diagnostics on the expand side, but this time only for the CALL_EXPR_TAILCALL calls, if something wasn't marked that way, it is up to tailc pass to emit message about it, if it was and it still can't be tail called, let it tell users about that; in this case I need to use the ;; prefix because it will appear in the middle of the IL dump and ;; is what is used for such purposes in other spots 4) I've tried to improve formatting of the maybe_error_musttail and maybe_complain_about_tail_call calls 2025-04-12 Jakub Jelinek <ja...@redhat.com> PR tree-optimization/119718 * tree-tailcall.cc (maybe_error_musttail): Only dump into dump_file if dump_flags & TDF_DETAILS. Use "Cannot tail-call: " prefix instead of "Cannot convert: ". (find_tail_calls, tree_optimize_tail_calls_1): Formatting fixes for maybe_error_musttail calls. * calls.cc (maybe_complain_about_tail_call): Emit also a message into dump_file when dump_flags & TDF_DETAILS for CALL_EXPR_TAILCALL calls. (initialize_argument_information): Formatting fix for maybe_complain_about_tail_call calls. (can_implement_as_sibling_call_p, expand_call): Likewise.