[gambit-list] Analysis of gcc and -foptimize-sibling-calls: It seems things are good.

Bradley Lucier lucier at purdue.edu
Wed Aug 2 19:42:13 EDT 2023


I built the current mainline gcc instrumented with --enable-coverage:

heine:~/programs/gambit/gambit> /pkgs/gcc-mainline/bin/gcc -v
Using built-in specs.
COLLECT_GCC=/pkgs/gcc-mainline/bin/gcc
COLLECT_LTO_WRAPPER=/pkgs/gcc-mainline/libexec/gcc/x86_64-pc-linux-gnu/14.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../../gcc-mainline/configure --enable-coverage 
--enable-languages=c --disable-multilib --prefix=/pkgs/gcc-mainline 
--disable-werror
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 14.0.0 20230802 (experimental) (GCC)

and built Gambit with

heine:~/programs/gambit/gambit> gsi/gsi -v
v4.9.5-3-ge059fffd 20230730151945 x86_64-pc-linux-gnu "./configure 
'CC=/pkgs/gcc-mainline/bin/gcc' '--enable-single-host' 
'--enable-trust-c-tco'"

The code to "optimize" sibling calls is split between 
gcc/tree-tailcall.cc (suitable_for_tail_opt_p and 
suitable_for_tail_call_opt_p) and gcc/calls.cc (dealt with in 
maybe_complain_about_tail_call).  I think tree-tailcall.cc deals with 
target-independent transformations, while calls.cc deals with low-level, 
target-dependent transformations.  Because of this split, and having 
three places where this optimization can be interrupted/reported, it's 
not clear to me where to place a warning.

By examining the .gcov files, for gcc/tree-tailcall.cc and gcc/calls.cc 
I can see that every tail call in the Gambit source tree was "optimized".

Brad



More information about the Gambit-list mailing list