Bug 98783 - Wrong ouput of "-O3 -Q --help=optimizers" on gcc built with --enable-frame-pointer
Summary: Wrong ouput of "-O3 -Q --help=optimizers" on gcc built with --enable-frame-p...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: driver (show other bugs)
Version: 10.2.0
: P3 normal
Target Milestone: ---
Assignee: Martin Liška
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-01-21 14:46 UTC by hasse.christoph
Modified: 2021-01-22 13:44 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2021-01-21 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description hasse.christoph 2021-01-21 14:46:14 UTC
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.
Comment 1 Martin Liška 2021-01-21 19:00:44 UTC
Let me take a look.
Comment 2 Martin Liška 2021-01-22 13:15:38 UTC
I think it's duplicate of PR98361.
Can you please mention what --help output is wrong and for which releases?
Comment 3 hasse.christoph 2021-01-22 13:25:21 UTC
--help=optimizers on GCC 10.2.0 build with --enable-frame-pointer prints:

-fomit-frame-pointer        		[enabled]

This flag should however be disabled by default.
Comment 4 Martin Liška 2021-01-22 13:37:37 UTC
(In reply to hasse.christoph from comment #3)
> --help=optimizers on GCC 10.2.0 build with --enable-frame-pointer prints:
> 
> -fomit-frame-pointer        		[enabled]
> 
> This flag should however be disabled by default.

Yes, but tip of gcc-10 branch is fine:
likely since:
https://gcc.gnu.org/git/gitweb.cgi?p=gcc.git;h=f7e39d1f137202a5d554849f6930ade58c312acd

$ ./xgcc -B. -O3 -Q --help=optimizers | grep omit
  -fomit-frame-pointer        		[disabled]
Comment 5 hasse.christoph 2021-01-22 13:43:27 UTC
I wasn't aware of this fix yet, sorry for the duplicate.
I really appreciate you taking the time to solve this so quickly! :)
Comment 6 Martin Liška 2021-01-22 13:44:36 UTC
(In reply to hasse.christoph from comment #5)
> I wasn't aware of this fix yet, sorry for the duplicate.

That's fine, you could not know about it :)

> I really appreciate you taking the time to solve this so quickly! :)

We're trying to do our best.