This is the mail archive of the
mailing list for the GCC project.
Re: RFA: Add --print-optimizers option
- From: Nick Clifton <nickc at redhat dot com>
- To: Mark Mitchell <mark at codesourcery dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Fri, 01 Dec 2006 09:56:18 +0000
- Subject: Re: RFA: Add --print-optimizers option
- References: <email@example.com> <456DCEB6.firstname.lastname@example.org>
This is a resubmission of an old patch that was originally submitted
when the mainline was in stage 3. It adds a new command line switch
to gcc called "--print-optimizers".
What is the intended usage of this option? I'm in no way trying to be
facetious; I'm just curious.
The intended use (from my point of view) is to enable a script to
automatically discover which optimization switches are supported by gcc
so that it can then iterate over these switches looking for the
combination that provides the best overall optimization for a given
program. The algorithm looks something like this:
1. Find out which optimization options are supported by the gcc.
2. Choose a subset of these options.
3. Compile the user's application with these options.
4. Profile the compiled application and record some kind judgement
about how well it has performed.
5. Go back to step 2 and repeat, choosing a new subset of the
available optimization options. Continue until you have run out
of subsets or time.
We are actually using the Acovea program
to do much of this work for us. Step 1 can be done by hand, but this is
inconvenient, inconsistent and error prone.
In the course of developing that patch I also realised that it would
enable us to easily answer some of the questions we routinely receive
from our customers - such as "which optimizations are enabled at -O2" or
"what new optimizations have been introduced with gcc x.x.x ?" (I know
that this information can be found out through other means, but if I can
tell the customer "run this command and you can find out for yourself"
they are much happier).
> Is this something that we could fold in with --help?
Well maybe. If --help gave a machine-parse-able iindication of the type
of switch it was documenting (optimization/warning/...) then a separate
--print-optimizers switch would not be needed. But that would
complicate the output of --help, which might not be appreciated by other
> Does it make sense to distinguish "optimizers" from "warnings"?
Oh yes definitely. In the scenario outlined above the script is only
interested in optimizations, nothing else.
> What about things like -fuse-cxa-atexit, which isn't really
> an optimization, but which it might also be nice to see an
> enabled/disabled flag for?
I am all for having some way of displaying that information. In fact my
intention is that if the --print-optimizers patch is acceptable I would
then go on to develop and submit an extended version which included
--print-warnings and maybe --print-pre-processor-symbols(*). So adding
something like --print-other-switches would not be a problem.
(Suggestions for a better name for the switch much appreciated).
(*) I know that you can achieve almost the same thing with "-dD -E" but
I never remember this combination.