RFA: Add --print-optimizers option

Nick Clifton nickc@redhat.com
Tue Nov 28 09:29:00 GMT 2006

Hi Guys,

  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".  When used it causes gcc to
  display a list of the optimization options it currently supports
  together with an indication of whether they currently active or not.
  For example:

    % gcc -c --print-optimizers
    -falign-jumps                         [disabled]
    -falign-labels                        [disabled]
    -falign-loops                         [enabled]
    -fargument-alias                      [enabled]

  Without the --quiet switch that by default gcc passes on to cc1 (or
  cc1plus or ...) the code will display the descriptive text for the

    % gcc -c --print-optimizers -Q
    -falign-jumps               Align labels which are only reached by jumping
    -falign-labels              Align all labels
    -falign-loops               Align the start of loops
    -fargument-alias            Specify that arguments may alias each other and
  This feature has two uses.  Firstly it allows an external program or
  script to discover which optimization switches are supported by the
  version of gcc that it is interrogating.  It was for this purpose
  that the patch was originally developed as it means that it becomes
  possible to write a script to automatically find the optimal set of
  command line options for compiling a given program.

  The other use of the feature is to investigate gcc's optimization
  options.  For example to find out which optimizations have to be
  explicitly enabled via the command line (rather than via a -Ox
  option) the user can run:

    gcc -c -O3 --print-optimizers | grep disabled

  Or to see which optimizations are specific to C++:

    gcc -c -O3 --print-optimizers > /tmp/cc1-opts
    g++ -c -O3 --print-optimizers > /tmp/cc1plus-opts
    diff /tmp/cc1-opts /tmp/cc1plus-opts | grep enabled

  Tested with an x86_64 linux native port, with no regressions.

  OK to apply ?

  Note - I have included a separate patch to the gcc html
  documentation file htdocs/gcc-4.3/changes.html, which I would hope
  to check in along with the main patch should it be approved.


2006-11-28  Nick Clifton  <nickc@redhat.com>

	* gcc.c (cc1_options): Add --print-optimizers.
	(process_command): Handle --print-optimizers.
	* opts.c (print_optimizers): New function.  Displays the currently
	supported optimization options.
	(common_handle_options): Add support for --print-optimizers.
	* opts.h (CL_OPTIMIZER): Define.
	* opt-functions.awk (function_switch_flags): Add support for
	Optimizer flag.
	* common.opt: Add Optimizer flag to suitable options.
	* c.opt: Likewise.
	* doc/invoke.texi: Document the new feature.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: gcc.print-optimizers.patch.bz2
Type: application/x-bzip2
Size: 9436 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20061128/f5439bef/attachment.bz2>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: changes.patch.bz2
Type: application/x-bzip2
Size: 991 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20061128/f5439bef/attachment-0001.bz2>

More information about the Gcc-patches mailing list