![]() 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 <jakub@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. |
||
---|---|---|
.forgejo | ||
.github | ||
c++tools | ||
config | ||
contrib | ||
fixincludes | ||
gcc | ||
gnattools | ||
gotools | ||
include | ||
INSTALL | ||
libada | ||
libatomic | ||
libbacktrace | ||
libcc1 | ||
libcody | ||
libcpp | ||
libdecnumber | ||
libffi | ||
libgcc | ||
libgcobol | ||
libgfortran | ||
libgm2 | ||
libgo | ||
libgomp | ||
libgrust | ||
libiberty | ||
libitm | ||
libobjc | ||
libphobos | ||
libquadmath | ||
libsanitizer | ||
libssp | ||
libstdc++-v3 | ||
libvtv | ||
lto-plugin | ||
maintainer-scripts | ||
zlib | ||
.b4-config | ||
.dir-locals.el | ||
.gitattributes | ||
.gitignore | ||
ABOUT-NLS | ||
ar-lib | ||
ChangeLog | ||
ChangeLog.jit | ||
ChangeLog.tree-ssa | ||
compile | ||
config-ml.in | ||
config.guess | ||
config.rpath | ||
config.sub | ||
configure | ||
configure.ac | ||
COPYING | ||
COPYING.LIB | ||
COPYING.RUNTIME | ||
COPYING3 | ||
COPYING3.LIB | ||
depcomp | ||
install-sh | ||
libtool-ldflags | ||
libtool.m4 | ||
ltgcc.m4 | ||
ltmain.sh | ||
ltoptions.m4 | ||
ltsugar.m4 | ||
ltversion.m4 | ||
lt~obsolete.m4 | ||
MAINTAINERS | ||
Makefile.def | ||
Makefile.in | ||
Makefile.tpl | ||
missing | ||
mkdep | ||
mkinstalldirs | ||
move-if-change | ||
multilib.am | ||
README | ||
SECURITY.txt | ||
symlink-tree | ||
test-driver | ||
ylwrap |
This directory contains the GNU Compiler Collection (GCC). The GNU Compiler Collection is free software. See the files whose names start with COPYING for copying permission. The manuals, and some of the runtime libraries, are under different terms; see the individual source files for details. The directory INSTALL contains copies of the installation information as HTML and plain text. The source of this information is gcc/doc/install.texi. The installation information includes details of what is included in the GCC sources and what files GCC installs. See the file gcc/doc/gcc.texi (together with other files that it includes) for usage and porting information. An online readable version of the manual is in the files gcc/doc/gcc.info*. See http://gcc.gnu.org/bugs/ for how to report bugs usefully. Copyright years on GCC source files may be listed using range notation, e.g., 1987-2012, indicating that every year in the range, inclusive, is a copyrightable year that could otherwise be listed individually.