https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98783
Bug ID: 98783
Summary: Wrong ouput of "-O3 -Q --help=optimizers" on gcc
built with --enable-frame-pointer
Product: gcc
Version: 10.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: driver
Assignee: unassigned at gcc dot gnu.org
Reporter: hasse.christoph at cern dot ch
Target Milestone: ---
Dear all,
I've got a GCC build that was configured with "--enable-frame-pointer"
./bin/gcc -v:
Using built-in specs.
COLLECT_GCC=./bin/gcc
COLLECT_LTO_WRAPPER=***/gccinstall/libexec/gcc/x86_64-pc-linux-gnu/10.2.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-10.2.0/configure --enable-frame-pointer
--disable-multilib --prefix=***/gccinstall -with-system-zlib
--enable-languages=all
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 10.2.0 (GCC)
Yet doing:
./bin/gcc -O3 -Q --help=optimizers | grep omit
prints:
-fomit-frame-pointer [enabled]
I originally tried "--enable-frame-pointer" on gcc 9.3.0, there I noticed that
the above command yields "enabled" for -m64 and "disabled" for -m32.
The fact that the frame-pointer was disabled on 64bit was a bug that was
reported & fixed. (Bug #89221).
I'm mentioning this because in gcc 9.3.0 the command "-O3 -Q --help=optimizers"
at least reported what was enabled and disabled. So I would assume it should do
the same in gcc 10.2.0.
Yet on 10.2.0 this returns "enabled" for both 32 and 64 bit.
However, I think this is only a bug in the printing, because
echo "int main(){}" | ./bin/gcc -O3 -Q -v -x c - 2>&1 | grep omit
correctly prints nothing thus tells us that the "-fomit-frame-pointer" flag is
in fact not in the set of used optimization options which are printed in this
output.
I've done a bit of digging and saw that there was quite a bit of change between
9.3.0 and 10.2.0 in this area.
>From what I can tell right now the "fomit-frame-pointer" flag is set to
disabled in the function ix86_recompute_optlev_based_flags defined in
gcc/config/i386/i386-options.c:1638
I checked and can see that this function is not called when doing "gcc -O3 -Q
--help=optimizers" but it is when doing the test via "echo "int main(){}" |
./bin/gcc -O3 -Q -v -x c - 2>&1"
{more detail:
seems that the target specific override function is called inside
process_options() in gcc/toplev.c:1389
process_options() is called via do_compile() from within toplev::main.
While both of the above commands enter toplev::main, --help triggers an early
exit, thus not calling do_compile and the eventual override.
}
So that's kind of where I lost track as I'm lacking the bigger picture view of
the codebase to figure out if or with what modification one can best make "gcc
-O3 -Q --help=optimizers" work.