This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RFA: Add --print-optimizers option


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
  options:

    % 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
                                globals
    
  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.

Cheers
  Nick

gcc/ChangeLog
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.

Attachment: gcc.print-optimizers.patch.bz2
Description: BZip2 compressed data

Attachment: changes.patch.bz2
Description: BZip2 compressed data


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]