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]

Re: [PATCH] Add option for dumping to stderr (issue6190057)


On Wed, Sep 12, 2012 at 3:30 AM, Richard Guenther
<richard.guenther@gmail.com> wrote:
> On Wed, Sep 12, 2012 at 10:12 AM, Sharad Singhai <singhai@google.com> wrote:
>> Thanks for your comments. Please see my responses inline.
>>
>> On Tue, Sep 11, 2012 at 1:16 PM, Xinliang David Li <davidxl@google.com> wrote:
>>> Can you resend your patch in text form (also need to resolve the
>>> latest conflicts) so that it can be commented inline?
>>
>> I tried to include inline patch earlier but my message was bounced
>> back from patches mailing list. I am trying it again.
>>
>>> Please also provide as summary a more up-to-date description of
>>> 1) Command line option syntax and semantics
>>
>> I added some documentation in the patch. Here are the relevant bits
>> from invoke.texi.
>>
>> `-fdump-tree-SWITCH-OPTIONS=FILENAME'
>>      Control the dumping at various stages of processing the
>>      intermediate language tree to a file.  The file name is generated
>>      by appending a switch-specific suffix to the source file name, and
>>      the file is created in the same directory as the output file. In
>>      case of `=FILENAME' option, the dump is output on the given file
>>      instead of the auto named dump files.
>>      ...
>>
>>     `=FILENAME'
>>           Instead of an auto named dump file, output into the given file
>>           name. The file names `stdout' and `stderr' are treated
>>           specially and are considered already open standard streams.
>>           For example,
>>
>>                gcc -O2 -ftree-vectorize -fdump-tree-vect-details=foo.dump
>>                     -fdump-tree-pre=stderr file.c
>>
>>           outputs vectorizer dump into `foo.dump', while the PRE dump
>>           is output on to `stderr'. If two conflicting dump filenames
>>           are given for the same pass, then the latter option
>>           overrides the earlier one.
>>
>> `-fopt-info-PASS'
>> `-fopt-info-PASS-OPTIONS'
>> `-fopt-info-PASS-OPTIONS=FILENAME'
>>      Controls optimization dumps from various passes. If the `-OPTIONS'
>>      form is used, OPTIONS is a list of `-' separated options which
>>      controls the details of the dump.  If OPTIONS is not specified, it
>>      defaults to `optimized'. If the FILENAME is not specified, it
>>      defaults to `stderr'. Note that the output FILENAME will be
>>      overwritten in case of multiple translation units. If a combined
>>      output from multiple the translation units is desired, `stderr'
>>      should be used instead.
>>
>>      The PASS could be one of the tree or rtl passes. The following
>>      options are available
>
> I don't like that we have -PASS here.  That makes it awfully similar
> to -fdump-PASS-OPTIONS=FILENAME.  Are we merely having
> -fopt-info because OPTIONS are "different"?


Having PASS is useful to do filtering. But as your said, the option
design here is very much oriented towards developers not end users
which fopt-info is also intended for.


>
>>     `optimized'
>>           Print information when a particular optimization is
>>           successfully applied. It is up to the pass to decide which
>>           information is relevant. For example, the vectorizer pass
>>           prints the location of loop which got vectorized.
>>
>>     `missed'
>>           Print information about missed optimizations. Individual
>>           passes control which information to include in the output.
>>           For example,
>>
>>                gcc -O2 -ftree-vectorize -fopt-info-tree-vect-missed
>
> At least for -PASS better names should be available.  And given the
> lack of pass support for the new scheme (apart from the vectorizer)
> we should enumerate the set of -PASS values we accept, currently
> -vec only.  IMHO it does not make sense to provide -fopt-info for
> the myriad of passes we have - usually only high-level ones are interesting
> to the user?

I like the idea -- can be done via some mapping. The initial mapping
does not need to complete.

>
>>           will print information about missed vectorization
>>           opportunities on to stderr.
>>
>>     `note'
>>           Print verbose information about optimizations, such as certain
>>           transformations, more detailed information about decisions
>>           etc.
>>
>>     `details'
>>           Print detailed information from a particular pass. This
>>           includes OPTIMIZED, MISSED, and NOTE. For example,
>>
>>                gcc -O2 -ftree-vectorize
>> -fopt-info-tree-vect-details=vect.details
>>
>>           outputs detailed optimization report from the vectorization
>>           pass into `vect.details'.
>
> Can options be chained?  like -fopt-info-vec-missed-note?
>
>> `-fopt-info-tree-all'
>> `-fopt-info-tree-all-OPTIONS'
>> `-fopt-info-tree-all-OPTIONS=FILENAME'
>>      This is similar to `-fopt-info' but instead of a single pass, it
>>      applies the dump options to all the tree passes. If the FILENAME
>>      is provided, the dump from all the passes is concatenated,
>>      otherwise the dump is output onto `stderr'. If OPTIONS is omitted,
>>      it defaults to `optimized'.
>>
>>           gcc -O3 -fopt-info-tree-all-optimized-missed=tree.optdump
>>
>>      This will output information about missed optimizations as well as
>>      optimized locations from all the tree passes into `tree.optdump'.
>
> That should be -fopt-info, thus omitting -PASS should default to enabling
> all.
>

yes.


>>> 2) New dumping APIs and semantics
>>
>> New dumping API:
>>
>> dump_kind_p ==> predicate for whether a particular type of dump is enabled
>> or not. Uses both dump_flags (TDF_*) and opt_info_flags (MSG_*).
>>
>> There are two variants, dump_xxx and dump_xxx_loc, the _loc variant is similar,
>> except it also prints the source location. The source location is
>> useful in certain
>> type of dumps, specially for -fopt-info.
>>
>> Most of these are straightforward.
>>
>> dump_gimple_stmt
>> dump_gimple_stmt_loc
>> dump_generic_expr
>> dump_generic_expr_loc
>> dump_printf
>> dump_printf_loc
>> dump_basic_block
>> dump_combine_total_stats
>>
>> dump_start/dump_finish:
>>
>> Before beginning of each pass, one needs to call dump_start ()
>> and at the end must call dump_finish (). I have already added the required
>> calls in passes.c.
>>
>> Instead of using dump_file directly, use one of the dump_* functions
>> declared in dumpfile.h. For example, dump_basic_block (...)
>> should be used for printing a basic block instead of accessing a dump stream
>> directly.
>>
>>> 3) Conversion changes
>>
>> I have converted vectorizer passes to use the new API. Here is an example
>>
>> -  if (vect_print_dump_info (REPORT_DETAILS))
>> -    fprintf (vect_dump, "=== vect_do_peeling_for_loop_bound ===");
>> +  if (dump_kind_p (MSG_OPTIMIZED_LOCATIONS))
>> +    dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, vect_location,
>> +                     "=== vect_do_peeling_for_loop_bound ===");
>>
>> Instead of calling fprintf on vect_dump directly, use
>> dump_printf_loc. This dump is done only when the
>> MSG_OPTIMIZED_LOCATIONS dump is enabled. Both -fopt-info dumps and
>> regular pass dumps are handled uniformly by treating MSG_* flags as
>> extensions of dump flags.
>>
>> Unfortunately, for vectorizer passes the change was not mechanical. I had to
>> decide for each individual dump site what type of dump was appropriate there.
>> Another added wrinkle was that the source location was printed as a side-effect.
>> Thus I had to convert some calls to use dump_*_loc variant, but not others.
>
> That was expected I guess.
>
>>> Looking at the patch briefly, I am confused with the opt-info syntax.
>>> I thought the following is desired:
>>>
>>> -fopt-info=pass-flags
>>>
>>> where pass is the pass name, and flags is one of [optimized, notes,
>>> missed].  Both pass and flags can be omitted.
>>>
>>> Is it implemented this way in your patch?
>>
>> Close to it but not quite the same way.
>> I considered this syntax and in fact implemented it. But later updated it to
>> use -fopt-info-PASS-FLAGS=filename instead, since it was consistent with the
>> -fdump-PASS-FLAGS=filename. Thus it is very easy to specify opt info
>> flags for a specific
>> pass. For example,
>>
>> -fdump-tree-pre=filename ==> dump PRE pass info
>> -fopt-info-tree-pre=filename  ==> dump PRE optimization info
>>
>> Hopefully this syntax is not confusing.
>
> See above ;)  I think the -fdump- interface is somewhat confusing, so we should
> take the chance to design something better for -fopt-info which is targeted at
> GCC users and not developers.


agree !

thanks,

David

>
> Aside from the -fopt-info flags management the patch is ok.  To go forward
> and allow others to adjust passes besides the vectorizer -fopt-info syntax
> can be massaged as a followup.
>
> Thus, ok if it bootstraps and regtests ok.
>
> Thanks again,
> Richard.
>
>> Thanks,
>> Sharad
>>
>> Actual patch follows.
>> -------------------------------------------
>>
>> 2012-09-12  Sharad Singhai  <singhai@google.com>
>>
>>         * doc/invoke.texi: Add documentation for the new option.
>>         * tree-dump.c: Include "gimple-pretty-print.h".
>>         Include "rtl.h".
>>         (pflags): New variable.
>>         (alt_flags): Ditto.
>>         (alt_dump_file): Ditto.
>>         (dump_files):  Update to include additional fields.
>>         (struct dump_option_value_info): Add additional field.
>>         (get_dump_file_name): Use command line filename if available.
>>         (dump_open_alternate_stream): New function.
>>         (dump_loc): Ditto.
>>         (dump_gimple_stmt): Ditto.
>>         (dump_gimple_stmt_loc): Ditto.
>>         (dump_generic_expr): Ditto.
>>         (dump_generic_expr_loc): Ditto.
>>         (dump_printf): Ditto.
>>         (dump_printf_loc): Ditto.
>>         (dump_start): Ditto.
>>         (dump_finish): Ditto.
>>         (dump_begin): Ditto.
>>         (dump_enabled_p): Return true if either of the dump types is enabled.
>>         (dump_initialized_p): Return true if either type of dump is initialized.
>>         (dump_end): Do not close standard streams.
>>         (dump_enable_all): Handle filenames for regular dumps.
>>         (dump_switch_p_1): Handle command-line dump filenames.
>>         (opt_info_enable_all): New function.
>>         (remap_tdf_to_msg_flags): Ditto.
>>         (opt_info_switch_p_1): Ditto.
>>         (opt_info_switch_p): Ditto.
>>         (dump_kind_p): Ditto.
>>         (dump_basic_block): Ditto.
>>         (dump_combine_total_stats): Ditto.
>>         (dump_remap_tree_vectorizer_verbose): Ditto.
>>         * tree-dump.h: Include "input.h".
>>         * dumpfile.h: Include "coretypes.h".
>>         Include "input.h".
>>         (enum dump_msg_kind): New flags for opt-info.
>>         (struct dump_file_info): Rename flags to pflags, state to pstate,
>>         stream to pstream, filename to pfilename. All callers updated. Add
>>         alt_flags, alt_state, alt_filenmae, alt_stream.
>>         * opts.c: Include "dumpfile.h".
>>         (vect_set_verbosity_level): Remove.
>>         (common_handle_option): Handle -fopt-info flag. Deprecate
>>         -ftree-vectorizer-verbose.
>>         * tree-parloops.c (gather_scalar_reductions): Remove reference to
>>         vect_dump.
>>         * gimple-pretty-print.h: Rename dump_gimple_stmt to
>>         pp_gimple_stmt_1.  All callers updated.
>>         * tree-vect-loop-manip.c: Use dump_printf instead of directly
>>         printing to vect_dump file.
>>         * tree-vect-patterns.c: Include "dumpfile.h".
>>         * tree-vectorizer.c: Include "dumpfile.h". Remove vect_dump.
>>         (vect_set_dump_settings): Remove.
>>         (vect_print_dump_info): Ditto.
>>         * tree-vectorizer.h: Remove declaration of vect_dump and
>>         vect_print_dump_info.
>>         * profile.c: Include "dumpfile.h".
>>         Instead of dump_bb use dump_basic_block.
>>         * tree-vect-loop.c: Include "dumpfile.h".
>>         * tree-vect-data-refs.c: Include "dumpfile.h".
>>         * tree-vect-stmts.c: Include "dumpfile.h".
>>         * tree-vect-slp.c: Include "dumpfile.h".
>>         * flag-types.h: Remove vect_verbosity_levels.
>>         * common.opt: Add -fopt-info. Deprecate -ftree-vectorizer-verbose.
>>         * combine.c: rename dump_combine_stats to debug_combine_stats, and
>>         rename dump_combine_total_stats to print_combine_total_stats. All
>>         callers updated.
>>         * opts-global.c (handle_common_deferred_options): Handle -fopt-info
>>         and -ftree-vectorizer-verbose.
>>         * Makefile.in (tree-dump.o): Update dependencies.
>>         (tree-vect-loop.o): Ditto.
>>         (tree-vect-loop-manip.o): Ditto.
>>         (tree-vect-slp.o): Ditto.
>>         (tree-vect-stmts.o): Ditto.
>>         (tree-vectorizer.o): Ditto.
>>         (opts.o): Ditto.
>>         * passes.c (finish_optimization_passes): Instead of using
>>         dump_begin/dump_end, use dump_start/dump_finish. Do not use dump_file.
>>         (pass_init_dump_file): Ditto.
>>
>> Index: doc/invoke.texi
>> ===================================================================
>> --- doc/invoke.texi     (revision 191208)
>> +++ doc/invoke.texi     (working copy)
>> @@ -330,6 +330,9 @@ Objective-C and Objective-C++ Dialects}.
>>  -fenable-@var{kind}-@var{pass}=@var{range-list} @gol
>>  -fdebug-types-section -fmem-report-wpa @gol
>>  -fmem-report -fpre-ipa-mem-report -fpost-ipa-mem-report -fprofile-arcs @gol
>> +-fopt-info-@var{pass}@r{[}-@var{options}@r{]}@r{[}=@var{file}@r{]} @gol
>> +-fopt-info-tree-all@r{[}-@var{options}@r{]}@r{[}=@var{file}@r{]} @gol
>> +-fopt-info-rtl-all@r{[}-@var{options}@r{]}@r{[}=@var{file}@r{]} @gol
>>  -frandom-seed=@var{string} -fsched-verbose=@var{n} @gol
>>  -fsel-sched-verbose -fsel-sched-dump-cfg -fsel-sched-pipelining-verbose @gol
>>  -fstack-usage  -ftest-coverage  -ftime-report -fvar-tracking @gol
>> @@ -5345,20 +5348,23 @@ Here are some examples showing uses of these optio
>>
>>  @item -d@var{letters}
>>  @itemx -fdump-rtl-@var{pass}
>> +@itemx -fdump-rtl-@var{pass}=@var{filename}
>>  @opindex d
>>  Says to make debugging dumps during compilation at times specified by
>>  @var{letters}.  This is used for debugging the RTL-based passes of the
>>  compiler.  The file names for most of the dumps are made by appending
>>  a pass number and a word to the @var{dumpname}, and the files are
>> -created in the directory of the output file.  Note that the pass
>> -number is computed statically as passes get registered into the pass
>> -manager.  Thus the numbering is not related to the dynamic order of
>> -execution of passes.  In particular, a pass installed by a plugin
>> -could have a number over 200 even if it executed quite early.
>> -@var{dumpname} is generated from the name of the output file, if
>> -explicitly specified and it is not an executable, otherwise it is the
>> -basename of the source file. These switches may have different effects
>> -when @option{-E} is used for preprocessing.
>> +created in the directory of the output file. In case of
>> +@option{=@var{filename}} option, the dump is output on the given file
>> +instead of the pass numbered dump files. Note that the pass number is
>> +computed statically as passes get registered into the pass manager.
>> +Thus the numbering is not related to the dynamic order of execution of
>> +passes.  In particular, a pass installed by a plugin could have a
>> +number over 200 even if it executed quite early.  @var{dumpname} is
>> +generated from the name of the output file, if explicitly specified
>> +and it is not an executable, otherwise it is the basename of the
>> +source file. These switches may have different effects when
>> +@option{-E} is used for preprocessing.
>>
>>  Debug dumps can be enabled with a @option{-fdump-rtl} switch or some
>>  @option{-d} option @var{letters}.  Here are the possible
>> @@ -5739,15 +5745,18 @@ counters for each function compiled.
>>
>>  @item -fdump-tree-@var{switch}
>>  @itemx -fdump-tree-@var{switch}-@var{options}
>> +@itemx -fdump-tree-@var{switch}-@var{options}=@var{filename}
>>  @opindex fdump-tree
>>  Control the dumping at various stages of processing the intermediate
>>  language tree to a file.  The file name is generated by appending a
>>  switch-specific suffix to the source file name, and the file is
>> -created in the same directory as the output file.  If the
>> -@samp{-@var{options}} form is used, @var{options} is a list of
>> -@samp{-} separated options which control the details of the dump.  Not
>> -all options are applicable to all dumps; those that are not
>> -meaningful are ignored.  The following options are available
>> +created in the same directory as the output file. In case of
>> +@option{=@var{filename}} option, the dump is output on the given file
>> +instead of the auto named dump files.  If the @samp{-@var{options}}
>> +form is used, @var{options} is a list of @samp{-} separated options
>> +which control the details of the dump.  Not all options are applicable
>> +to all dumps; those that are not meaningful are ignored.  The
>> +following options are available
>>
>>  @table @samp
>>  @item address
>> @@ -5785,6 +5794,22 @@ Enable showing the tree dump for each statement.
>>  Enable showing the EH region number holding each statement.
>>  @item scev
>>  Enable showing scalar evolution analysis details.
>> +@item =@var{filename}
>> +Instead of an auto named dump file, output into the given file
>> +name. The file names @file{stdout} and @file{stderr} are treated
>> +specially and are considered already open standard streams. For
>> +example,
>> +
>> +@smallexample
>> +gcc -O2 -ftree-vectorize -fdump-tree-vect-details=foo.dump
>> +     -fdump-tree-pre=stderr file.c
>> +@end smallexample
>> +
>> +outputs vectorizer dump into @file{foo.dump}, while the PRE dump is
>> +output on to @file{stderr}. If two conflicting dump filenames are
>> +given for the same pass, then the latter option overrides the earlier
>> +one.
>> +
>>  @item all
>>  Turn on all options, except @option{raw}, @option{slim}, @option{verbose}
>>  and @option{lineno}.
>> @@ -5935,34 +5960,98 @@ is made by appending @file{.vrp} to the source fil
>>  Enable all the available tree dumps with the flags provided in this option.
>>  @end table
>>
>> +@item -fopt-info-@var{pass}
>> +@itemx -fopt-info-@var{pass}-@var{options}
>> +@itemx -fopt-info-@var{pass}-@var{options}=@var{filename}
>> +@opindex fopt-info
>> +Controls optimization dumps from various passes. If the
>> +@samp{-@var{options}} form is used, @var{options} is a list of
>> +@samp{-} separated options which controls the details of the dump.  If
>> +@var{options} is not specified, it defaults to @option{optimized}. If
>> +the @var{filename} is not specified, it defaults to
>> +@file{stderr}. Note that the output @var{filename} will be overwritten
>> +in case of multiple translation units. If a combined output from
>> +multiple the translation units is desired, @file{stderr} should be
>> +used instead.
>> +
>> +The @var{pass} could be one of the tree or rtl passes. The following
>> +options are available
>> +
>> +@table @samp
>> +@item optimized
>> +Print information when a particular optimization is successfully
>> +applied. It is up to the pass to decide which information is
>> +relevant. For example, the vectorizer pass prints the location of loop
>> +which got vectorized.
>> +@item missed
>> +Print information about missed optimizations. Individual passes
>> +control which information to include in the output. For example,
>> +
>> +@smallexample
>> +gcc -O2 -ftree-vectorize -fopt-info-tree-vect-missed
>> +@end smallexample
>> +
>> +will print information about missed vectorization opportunities on
>> +to stderr.
>> +@item note
>> +Print verbose information about optimizations, such as certain
>> +transformations, more detailed information about decisions etc.
>> +@item details
>> +Print detailed information from a particular pass. This includes
>> +@var{optimized}, @var{missed}, and @var{note}. For example,
>> +
>> +@smallexample
>> +gcc -O2 -ftree-vectorize -fopt-info-tree-vect-details=vect.details
>> +@end smallexample
>> +
>> +outputs detailed optimization report from the vectorization pass into
>> +@file{vect.details}.
>> +@end table
>> +
>> +@item -fopt-info-tree-all
>> +@itemx -fopt-info-tree-all-@var{options}
>> +@itemx -fopt-info-tree-all-@var{options}=@var{filename}
>> +@opindex fopt-info-tree-all
>> +This is similar to @option{-fopt-info} but instead of a single pass,
>> +it applies the dump options to all the tree passes. If the
>> +@var{filename} is provided, the dump from all the passes is
>> +concatenated, otherwise the dump is output onto @file{stderr}. If
>> +@var{options} is omitted, it defaults to @option{optimized}.
>> +
>> +@smallexample
>> +gcc -O3 -fopt-info-tree-all-optimized-missed=tree.optdump
>> +@end smallexample
>> +
>> +This will output information about missed optimizations as well as
>> +optimized locations from all the tree passes into @file{tree.optdump}.
>> +
>> +@item -fopt-info-rtl-all
>> +@itemx -fopt-info-rtl-all-@var{options}
>> +@itemx -fopt-info-rtl-all-@var{options}=@var{filename}
>> +@opindex fopt-info-rtl-all
>> +This is similar to @option{-fopt-info-tree-all} but instead of tree
>> +passes, it applies the dump options to all the rtl passes.
>> +
>>  @item -ftree-vectorizer-verbose=@var{n}
>>  @opindex ftree-vectorizer-verbose
>> -This option controls the amount of debugging output the vectorizer prints.
>> -This information is written to standard error, unless
>> -@option{-fdump-tree-all} or @option{-fdump-tree-vect} is specified,
>> -in which case it is output to the usual dump listing file, @file{.vect}.
>> -For @var{n}=0 no diagnostic information is reported.
>> -If @var{n}=1 the vectorizer reports each loop that got vectorized,
>> -and the total number of loops that got vectorized.
>> -If @var{n}=2 the vectorizer also reports non-vectorized loops that passed
>> -the first analysis phase (vect_analyze_loop_form) - i.e.@: countable,
>> -inner-most, single-bb, single-entry/exit loops.  This is the same verbosity
>> -level that @option{-fdump-tree-vect-stats} uses.
>> -Higher verbosity levels mean either more information dumped for each
>> -reported loop, or same amount of information reported for more loops:
>> -if @var{n}=3, vectorizer cost model information is reported.
>> -If @var{n}=4, alignment related information is added to the reports.
>> -If @var{n}=5, data-references related information (e.g.@: memory dependences,
>> -memory access-patterns) is added to the reports.
>> -If @var{n}=6, the vectorizer reports also non-vectorized inner-most loops
>> -that did not pass the first analysis phase (i.e., may not be countable, or
>> -may have complicated control-flow).
>> -If @var{n}=7, the vectorizer reports also non-vectorized nested loops.
>> -If @var{n}=8, SLP related information is added to the reports.
>> -For @var{n}=9, all the information the vectorizer generates during its
>> -analysis and transformation is reported.  This is the same verbosity level
>> -that @option{-fdump-tree-vect-details} uses.
>> +This option is deprecated and is implemented in terms of
>> +@option{-fopt-info}. Please use
>> +@option{-fopt-info-tree-vect-@var{kind}} form instead, where
>> +@var{kind} is one of the valid opt-info kinds. It prints additional
>> +information about the vectorizer pass.  For @var{n}=0 no diagnostic
>> +information is reported.  If @var{n}=1 the vectorizer reports each
>> +loop that got vectorized, and the total number of loops that got
>> +vectorized.  If @var{n}=2 the vectorizer reports locations which could
>> +not be vectorized and the reasons for those. For any higher verbosity
>> +levels all the analysis and transformation information is reported.
>> +This is the same verbosity level that
>> +@option{-fdump-tree-vect-details} uses.
>>
>> +Note that the information output by @option{-ftree-vectorizer-verbose}
>> +option is sent to @file{stderr}. If the equivalent form
>> +@option{-fopt-info-tree-vect-@var{options}=@var{filename}}
>> +is used then the information is output into @var{filename} instead.
>> +
>>  @item -frandom-seed=@var{string}
>>  @opindex frandom-seed
>>  This option provides a seed that GCC uses in place of
>> Index: tree-dump.c
>> ===================================================================
>> --- tree-dump.c (revision 191208)
>> +++ tree-dump.c (working copy)
>> @@ -24,9 +24,11 @@ along with GCC; see the file COPYING3.  If not see
>>  #include "coretypes.h"
>>  #include "tm.h"
>>  #include "tree.h"
>> +#include "gimple-pretty-print.h"
>>  #include "splay-tree.h"
>>  #include "filenames.h"
>>  #include "diagnostic-core.h"
>> +#include "rtl.h"
>>  #include "toplev.h"
>>  #include "tree-dump.h"
>>  #include "langhooks.h"
>> @@ -37,12 +39,18 @@ along with GCC; see the file COPYING3.  If not see
>>  #define skip_leading_substring(whole,  part) \
>>     (strncmp (whole, part, strlen (part)) ? NULL : whole + strlen (part))
>>
>> +static int pflags;                   /* current dump_flags */
>> +static int alt_flags;                /* current opt_info flags */
>> +static FILE *alt_dump_file = NULL;
>>  static unsigned int queue (dump_info_p, const_tree, int);
>>  static void dump_index (dump_info_p, unsigned int);
>>  static void dequeue_and_dump (dump_info_p);
>>  static void dump_new_line (dump_info_p);
>>  static void dump_maybe_newline (dump_info_p);
>> +static void dump_loc (int, FILE *, source_location);
>>
>> +extern void dump_bb (FILE *, basic_block, int, int);
>> +
>>  /* Add T to the end of the queue of nodes to dump.  Returns the index
>>     assigned to T.  */
>>
>> @@ -769,23 +777,28 @@ dump_node (const_tree t, int flags, FILE *stream)
>>
>>
>>  /* Table of tree dump switches. This must be consistent with the
>> -   tree_dump_index enumeration in tree-pass.h.  */
>> +   TREE_DUMP_INDEX enumeration in dumpfile.h.  */
>>  static struct dump_file_info dump_files[TDI_end] =
>>  {
>> -  {NULL, NULL, NULL, 0, 0, 0},
>> -  {".cgraph", "ipa-cgraph", NULL, TDF_IPA, 0,  0},
>> -  {".tu", "translation-unit", NULL, TDF_TREE, 0, 1},
>> -  {".class", "class-hierarchy", NULL, TDF_TREE, 0, 2},
>> -  {".original", "tree-original", NULL, TDF_TREE, 0, 3},
>> -  {".gimple", "tree-gimple", NULL, TDF_TREE, 0, 4},
>> -  {".nested", "tree-nested", NULL, TDF_TREE, 0, 5},
>> -  {".vcg", "tree-vcg", NULL, TDF_TREE, 0, 6},
>> -  {".ads", "ada-spec", NULL, 0, 0, 7},
>> +  {NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 0, 0, 0, 0},
>> +  {".cgraph", "ipa-cgraph", NULL, NULL, NULL, NULL, NULL, TDF_IPA, 0, 0, 0, 0},
>> +  {".tu", "translation-unit", NULL, NULL, NULL, NULL, NULL, TDF_TREE, 0, 0,
>> +   0, 1},
>> +  {".class", "class-hierarchy", NULL, NULL, NULL, NULL, NULL, TDF_TREE, 0, 0,
>> +   0, 2},
>> +  {".original", "tree-original", NULL, NULL, NULL, NULL, NULL, TDF_TREE, 0, 0,
>> +   0, 3},
>> +  {".gimple", "tree-gimple", NULL, NULL, NULL, NULL, NULL, TDF_TREE, 0, 0,
>> +   0, 4},
>> +  {".nested", "tree-nested", NULL, NULL, NULL, NULL, NULL, TDF_TREE, 0, 0,
>> +   0, 5},
>> +  {".vcg", "tree-vcg", NULL, NULL, NULL, NULL, NULL, TDF_TREE, 0, 0, 0, 6},
>> +  {".ads", "ada-spec", NULL, NULL, NULL, NULL, NULL, 0, 0, 0, 0, 7},
>>  #define FIRST_AUTO_NUMBERED_DUMP 8
>>
>> -  {NULL, "tree-all", NULL, TDF_TREE, 0, 0},
>> -  {NULL, "rtl-all", NULL, TDF_RTL, 0, 0},
>> -  {NULL, "ipa-all", NULL, TDF_IPA, 0, 0},
>> +  {NULL, "tree-all", NULL, NULL, NULL, NULL, NULL, TDF_TREE, 0, 0, 0, 0},
>> +  {NULL, "rtl-all", NULL, NULL, NULL, NULL, NULL, TDF_RTL, 0, 0, 0, 0},
>> +  {NULL, "ipa-all", NULL, NULL, NULL, NULL, NULL, TDF_IPA, 0, 0, 0, 0},
>>  };
>>
>>  /* Dynamically registered tree dump files and switches.  */
>> @@ -798,38 +811,57 @@ struct dump_option_value_info
>>  {
>>    const char *const name;      /* the name of the value */
>>    const int value;             /* the value of the name */
>> +  const int msg_flags;           /* corresponding MSG_* flags */
>>  };
>>
>>  /* Table of dump options. This must be consistent with the TDF_* flags
>> -   in tree.h */
>> +   in dumpfile.h and opt_info_options below. */
>>  static const struct dump_option_value_info dump_options[] =
>>  {
>> -  {"address", TDF_ADDRESS},
>> -  {"asmname", TDF_ASMNAME},
>> -  {"slim", TDF_SLIM},
>> -  {"raw", TDF_RAW},
>> -  {"graph", TDF_GRAPH},
>> -  {"details", TDF_DETAILS},
>> -  {"cselib", TDF_CSELIB},
>> -  {"stats", TDF_STATS},
>> -  {"blocks", TDF_BLOCKS},
>> -  {"vops", TDF_VOPS},
>> -  {"lineno", TDF_LINENO},
>> -  {"uid", TDF_UID},
>> -  {"stmtaddr", TDF_STMTADDR},
>> -  {"memsyms", TDF_MEMSYMS},
>> -  {"verbose", TDF_VERBOSE},
>> -  {"eh", TDF_EH},
>> -  {"alias", TDF_ALIAS},
>> -  {"nouid", TDF_NOUID},
>> -  {"enumerate_locals", TDF_ENUMERATE_LOCALS},
>> -  {"scev", TDF_SCEV},
>> +  {"address", TDF_ADDRESS, 0},
>> +  {"asmname", TDF_ASMNAME, 0},
>> +  {"slim", TDF_SLIM, 0},
>> +  {"raw", TDF_RAW, 0},
>> +  {"graph", TDF_GRAPH, 0},
>> +  {"details", TDF_DETAILS, (MSG_OPTIMIZED_LOCATIONS
>> +                            | MSG_MISSED_OPTIMIZATION
>> +                            | MSG_NOTE)},
>> +  {"cselib", TDF_CSELIB, 0},
>> +  {"stats", TDF_STATS, 0},
>> +  {"blocks", TDF_BLOCKS, 0},
>> +  {"vops", TDF_VOPS, 0},
>> +  {"lineno", TDF_LINENO, 0},
>> +  {"uid", TDF_UID, 0},
>> +  {"stmtaddr", TDF_STMTADDR, 0},
>> +  {"memsyms", TDF_MEMSYMS, 0},
>> +  {"verbose", TDF_VERBOSE, 0},
>> +  {"eh", TDF_EH, 0},
>> +  {"alias", TDF_ALIAS, 0},
>> +  {"nouid", TDF_NOUID, 0},
>> +  {"enumerate_locals", TDF_ENUMERATE_LOCALS, 0},
>> +  {"scev", TDF_SCEV, 0},
>>    {"all", ~(TDF_RAW | TDF_SLIM | TDF_LINENO | TDF_TREE | TDF_RTL | TDF_IPA
>>             | TDF_STMTADDR | TDF_GRAPH | TDF_DIAGNOSTIC | TDF_VERBOSE
>> -           | TDF_RHS_ONLY | TDF_NOUID | TDF_ENUMERATE_LOCALS | TDF_SCEV)},
>> -  {NULL, 0}
>> +           | TDF_RHS_ONLY | TDF_NOUID | TDF_ENUMERATE_LOCALS | TDF_SCEV),
>> +   (MSG_OPTIMIZED_LOCATIONS
>> +    | MSG_MISSED_OPTIMIZATION
>> +    | MSG_NOTE)},
>> +  {NULL, 0, 0}
>>  };
>>
>> +/* Table of opt-info options. This must be consistent with the MSG_*
>> +   flags in dumpfile.h. The third field of this table is unused. */
>> +static const struct dump_option_value_info opt_info_options[] =
>> +{
>> +  {"optimized", MSG_OPTIMIZED_LOCATIONS, 0},
>> +  {"missed", MSG_MISSED_OPTIMIZATION, 0},
>> +  {"note", MSG_NOTE, 0},
>> +  {"details", (MSG_OPTIMIZED_LOCATIONS
>> +               | MSG_MISSED_OPTIMIZATION
>> +               | MSG_NOTE), 0},
>> +  {NULL, 0, 0}
>> +};
>> +
>>  unsigned int
>>  dump_register (const char *suffix, const char *swtch, const char *glob,
>>                int flags)
>> @@ -854,7 +886,7 @@ dump_register (const char *suffix, const char *swt
>>    extra_dump_files[count].suffix = suffix;
>>    extra_dump_files[count].swtch = swtch;
>>    extra_dump_files[count].glob = glob;
>> -  extra_dump_files[count].flags = flags;
>> +  extra_dump_files[count].pflags = flags;
>>    extra_dump_files[count].num = num;
>>
>>    return count + TDI_end;
>> @@ -888,17 +920,21 @@ get_dump_file_name (int phase)
>>      return NULL;
>>
>>    dfi = get_dump_file_info (phase);
>> -  if (dfi->state == 0)
>> +  if (dfi->pstate == 0)
>>      return NULL;
>>
>> +  /* If available, use the command line dump filename. */
>> +  if (dfi->pfilename)
>> +    return xstrdup (dfi->pfilename);
>> +
>>    if (dfi->num < 0)
>>      dump_id[0] = '\0';
>>    else
>>      {
>>        char suffix;
>> -      if (dfi->flags & TDF_TREE)
>> +      if (dfi->pflags & TDF_TREE)
>>         suffix = 't';
>> -      else if (dfi->flags & TDF_IPA)
>> +      else if (dfi->pflags & TDF_IPA)
>>         suffix = 'i';
>>        else
>>         suffix = 'r';
>> @@ -910,6 +946,248 @@ get_dump_file_name (int phase)
>>    return concat (dump_base_name, dump_id, dfi->suffix, NULL);
>>  }
>>
>> +/* Open an alternate dump filename for PHASE (which could also be a
>> +   standard stream such as stdout/stderr). If the alternate dump file
>> +   cannot be opened, return NULL.  */
>> +
>> +static FILE *
>> +dump_open_alternate_stream (int phase)
>> +{
>> +  FILE *stream ;
>> +  struct dump_file_info *dfi;
>> +
>> +  dfi = get_dump_file_info (phase);
>> +  if (!dfi->alt_filename)
>> +    return NULL;
>> +
>> +  if (dfi->alt_stream)
>> +    return dfi->alt_stream;
>> +
>> +  stream = strcmp("stderr", dfi->alt_filename) == 0
>> +    ? stderr
>> +    : strcmp("stdout", dfi->alt_filename) == 0
>> +    ?  stdout
>> +    : fopen (dfi->alt_filename, dfi->alt_state < 0 ? "w" : "a");
>> +
>> +  if (!stream)
>> +    error ("could not open dump file %qs: %m", dfi->alt_filename);
>> +  else
>> +    dfi->alt_state = 1;
>> +
>> +  return stream;
>> +}
>> +
>> +/* Print source location on DFILE if enabled.  */
>> +
>> +void
>> +dump_loc (int dump_kind, FILE *dfile, source_location loc)
>> +{
>> +  /* Currently vectorization passes print location information.  */
>> +  if (dump_kind)
>> +    {
>> +      if (loc == UNKNOWN_LOCATION)
>> +        fprintf (dfile, "\n%s:%d: note: ",
>> +                 DECL_SOURCE_FILE (current_function_decl),
>> +                 DECL_SOURCE_LINE (current_function_decl));
>> +     else
>> +        fprintf (dfile, "\n%d: ", LOCATION_LINE (loc));
>> +    }
>> +}
>> +
>> +/* Dump gimple statement GS with SPC indentation spaces and
>> +   EXTRA_DUMP_FLAGS on the dump streams if DUMP_KIND is enabled.  */
>> +
>> +void
>> +dump_gimple_stmt (int dump_kind, int extra_dump_flags, gimple gs, int spc)
>> +{
>> +  if (dump_file && (dump_kind & pflags))
>> +    print_gimple_stmt (dump_file, gs, spc, dump_flags | extra_dump_flags);
>> +
>> +  if (alt_dump_file && (dump_kind & alt_flags))
>> +    print_gimple_stmt (alt_dump_file, gs, spc, dump_flags | extra_dump_flags);
>> +}
>> +
>> +/* Similar to dump_gimple_stmt, except additionally print source location.  */
>> +
>> +void
>> +dump_gimple_stmt_loc (int dump_kind, source_location loc, int extra_dump_flags,
>> +                      gimple gs, int spc)
>> +{
>> +  if (dump_file && (dump_kind & pflags))
>> +    {
>> +      dump_loc (dump_kind, dump_file, loc);
>> +      print_gimple_stmt (dump_file, gs, spc, dump_flags | extra_dump_flags);
>> +    }
>> +
>> +  if (alt_dump_file && (dump_kind & alt_flags))
>> +    {
>> +      dump_loc (dump_kind, alt_dump_file, loc);
>> +      print_gimple_stmt (alt_dump_file, gs, spc, dump_flags |
>> extra_dump_flags);
>> +    }
>> +}
>> +
>> +/* Dump tree T using EXTRA_DUMP_FLAGS on dump streams if DUMP_KIND is
>> +   enabled.  */
>> +
>> +void
>> +dump_generic_expr (int dump_kind, int extra_dump_flags, tree t)
>> +{
>> +  if (dump_file && (dump_kind & pflags))
>> +      print_generic_expr (dump_file, t, dump_flags | extra_dump_flags);
>> +
>> +  if (alt_dump_file && (dump_kind & alt_flags))
>> +      print_generic_expr (alt_dump_file, t, dump_flags | extra_dump_flags);
>> +}
>> +
>> +
>> +/* Similar to dump_generic_expr, except additionally print the source
>> +   location.  */
>> +
>> +void
>> +dump_generic_expr_loc (int dump_kind, source_location loc,
>> +                       int extra_dump_flags, tree t)
>> +{
>> +  if (dump_file && (dump_kind & pflags))
>> +    {
>> +      dump_loc (dump_kind, dump_file, loc);
>> +      print_generic_expr (dump_file, t, dump_flags | extra_dump_flags);
>> +    }
>> +
>> +  if (alt_dump_file && (dump_kind & alt_flags))
>> +    {
>> +      dump_loc (dump_kind, alt_dump_file, loc);
>> +      print_generic_expr (alt_dump_file, t, dump_flags | extra_dump_flags);
>> +    }
>> +}
>> +
>> +/* Output a formatted message using FORMAT on appropriate dump streams.  */
>> +
>> +void
>> +dump_printf (int dump_kind, const char *format, ...)
>> +{
>> +  if (dump_file && (dump_kind & pflags))
>> +    {
>> +      va_list ap;
>> +      va_start (ap, format);
>> +      vfprintf (dump_file, format, ap);
>> +      va_end (ap);
>> +    }
>> +
>> +  if (alt_dump_file && (dump_kind & alt_flags))
>> +    {
>> +      va_list ap;
>> +      va_start (ap, format);
>> +      vfprintf (alt_dump_file, format, ap);
>> +      va_end (ap);
>> +    }
>> +}
>> +
>> +/* Similar to dump_printf, except source location is also printed.  */
>> +
>> +void
>> +dump_printf_loc (int dump_kind, source_location loc, const char *format, ...)
>> +{
>> +  if (dump_file && (dump_kind & pflags))
>> +    {
>> +      va_list ap;
>> +      dump_loc (dump_kind, dump_file, loc);
>> +      va_start (ap, format);
>> +      vfprintf (dump_file, format, ap);
>> +      va_end (ap);
>> +    }
>> +
>> +  if (alt_dump_file && (dump_kind & alt_flags))
>> +    {
>> +      va_list ap;
>> +      dump_loc (dump_kind, alt_dump_file, loc);
>> +      va_start (ap, format);
>> +      vfprintf (alt_dump_file, format, ap);
>> +      va_end (ap);
>> +    }
>> +}
>> +
>> +/* Start a dump for PHASE. Store user-supplied dump flags in
>> +   *FLAG_PTR.  Return the number of streams opened.  Set globals
>> +   DUMP_FILE, and ALT_DUMP_FILE to point to the opened streams, and
>> +   set dump_flags appropriately for both pass dump stream and opt-info
>> +   stream. */
>> +
>> +int
>> +dump_start (int phase, int *flag_ptr)
>> +{
>> +  int count = 0;
>> +  char *name;
>> +  struct dump_file_info *dfi;
>> +  FILE *stream;
>> +  if (phase == TDI_none || !dump_enabled_p (phase))
>> +    return 0;
>> +
>> +  dfi = get_dump_file_info (phase);
>> +  name = get_dump_file_name (phase);
>> +  if (name)
>> +    {
>> +      stream = strcmp("stderr", name) == 0
>> +          ? stderr
>> +          : strcmp("stdout", name) == 0
>> +          ?  stdout
>> +          : fopen (name, dfi->pstate < 0 ? "w" : "a");
>> +      if (!stream)
>> +        error ("could not open dump file %qs: %m", name);
>> +      else
>> +        {
>> +          dfi->pstate = 1;
>> +          count++;
>> +        }
>> +      free (name);
>> +      dfi->pstream = stream;
>> +      dump_file = dfi->pstream;
>> +      /* Initialize current dump flags. */
>> +      pflags = dfi->pflags;
>> +    }
>> +
>> +  stream = dump_open_alternate_stream (phase);
>> +  if (stream)
>> +    {
>> +      dfi->alt_stream = stream;
>> +      count++;
>> +      alt_dump_file = dfi->alt_stream;
>> +      /* Initialize current opt-info flags. */
>> +      alt_flags = dfi->alt_flags;
>> +    }
>> +
>> +  if (flag_ptr)
>> +    *flag_ptr = dfi->pflags;
>> +
>> +  return count;
>> +}
>> +
>> +/* Finish a tree dump for PHASE and close associated dump streams.  Also
>> +   reset the globals DUMP_FILE, ALT_DUMP_FILE, and DUMP_FLAGS.  */
>> +
>> +void
>> +dump_finish (int phase)
>> +{
>> +  struct dump_file_info *dfi;
>> +
>> +  if (phase < 0)
>> +    return;
>> +  dfi = get_dump_file_info (phase);
>> +  if (dfi->pstream)
>> +    fclose (dfi->pstream);
>> +
>> +  if (dfi->alt_stream && strcmp("stderr", dfi->alt_filename) != 0
>> +      && strcmp("stdout", dfi->alt_filename) != 0)
>> +    fclose (dfi->alt_stream);
>> +
>> +  dfi->alt_stream = NULL;
>> +  dfi->pstream = NULL;
>> +  dump_file = NULL;
>> +  alt_dump_file = NULL;
>> +  dump_flags = TDI_none;
>> +  alt_flags = 0;
>> +  pflags = 0;
>> +}
>> +
>>  /* Begin a tree dump for PHASE. Stores any user supplied flag in
>>     *FLAG_PTR and returns a stream to write to. If the dump is not
>>     enabled, returns NULL.
>> @@ -926,22 +1204,33 @@ dump_begin (int phase, int *flag_ptr)
>>      return NULL;
>>
>>    name = get_dump_file_name (phase);
>> +  if (!name)
>> +    return NULL;
>>    dfi = get_dump_file_info (phase);
>> -  stream = fopen (name, dfi->state < 0 ? "w" : "a");
>> +
>> +  stream = strcmp("stderr", name) == 0
>> +    ? stderr
>> +    : strcmp("stdout", name) == 0
>> +    ?  stdout
>> +    : fopen (name, dfi->pstate < 0 ? "w" : "a");
>> +
>>    if (!stream)
>>      error ("could not open dump file %qs: %m", name);
>>    else
>> -    dfi->state = 1;
>> +    dfi->pstate = 1;
>>    free (name);
>>
>>    if (flag_ptr)
>> -    *flag_ptr = dfi->flags;
>> +    *flag_ptr = dfi->pflags;
>>
>> +  /* Initialize current flags */
>> +  pflags = dfi->pflags;
>>    return stream;
>>  }
>>
>> -/* Returns nonzero if tree dump PHASE is enabled.  If PHASE is
>> -   TDI_tree_all, return nonzero if any dump is enabled.  */
>> +/* Returns nonzero if dump PHASE is enabled for at least one stream.
>> +   If PHASE is TDI_tree_all, return nonzero if any dump is enabled for
>> +   any phase.  */
>>
>>  int
>>  dump_enabled_p (int phase)
>> @@ -950,17 +1239,17 @@ dump_enabled_p (int phase)
>>      {
>>        size_t i;
>>        for (i = TDI_none + 1; i < (size_t) TDI_end; i++)
>> -       if (dump_files[i].state)
>> +       if (dump_files[i].pstate || dump_files[i].alt_state)
>>           return 1;
>>        for (i = 0; i < extra_dump_files_in_use; i++)
>> -       if (extra_dump_files[i].state)
>> +       if (extra_dump_files[i].pstate || extra_dump_files[i].alt_state)
>>           return 1;
>>        return 0;
>>      }
>>    else
>>      {
>>        struct dump_file_info *dfi = get_dump_file_info (phase);
>> -      return dfi->state;
>> +      return dfi->pstate || dfi->alt_state;
>>      }
>>  }
>>
>> @@ -970,7 +1259,7 @@ int
>>  dump_initialized_p (int phase)
>>  {
>>    struct dump_file_info *dfi = get_dump_file_info (phase);
>> -  return dfi->state > 0;
>> +  return dfi->pstate > 0 || dfi->alt_state > 0;
>>  }
>>
>>  /* Returns the switch name of PHASE.  */
>> @@ -988,37 +1277,130 @@ dump_flag_name (int phase)
>>  void
>>  dump_end (int phase ATTRIBUTE_UNUSED, FILE *stream)
>>  {
>> -  fclose (stream);
>> +  if (stream != stderr && stream != stdout)
>> +    fclose (stream);
>>  }
>>
>> -/* Enable all tree dumps.  Return number of enabled tree dumps.  */
>> +/* Enable all tree dumps with FLAGS on FILENAME.  Return number of
>> +   enabled tree dumps.  */
>>
>>  static int
>> -dump_enable_all (int flags)
>> +dump_enable_all (int flags, const char *filename)
>>  {
>>    int ir_dump_type = (flags & (TDF_TREE | TDF_RTL | TDF_IPA));
>>    int n = 0;
>>    size_t i;
>>
>>    for (i = TDI_none + 1; i < (size_t) TDI_end; i++)
>> -    if ((dump_files[i].flags & ir_dump_type))
>> -      {
>> -        dump_files[i].state = -1;
>> -        dump_files[i].flags |= flags;
>> -        n++;
>> -      }
>> +    {
>> +      if ((dump_files[i].pflags & ir_dump_type))
>> +        {
>> +          const char *old_filename = dump_files[i].pfilename;
>> +          dump_files[i].pstate = -1;
>> +          dump_files[i].pflags |= flags;
>> +          n++;
>> +          /* Override the existing filename.  */
>> +          if (filename)
>> +            {
>> +              dump_files[i].pfilename = xstrdup (filename);
>> +              /* Since it is a command-line provided file, which is
>> +                 common to all the phases, use it in append mode.  */
>> +              dump_files[i].pstate = 1;
>> +            }
>> +          if (old_filename && filename != old_filename)
>> +            free (CONST_CAST (char *, old_filename));
>> +        }
>> +    }
>>
>>    for (i = 0; i < extra_dump_files_in_use; i++)
>> -    if ((extra_dump_files[i].flags & ir_dump_type))
>> -      {
>> -        extra_dump_files[i].state = -1;
>> -        extra_dump_files[i].flags |= flags;
>> -       n++;
>> -      }
>> +    {
>> +      if ((extra_dump_files[i].pflags & ir_dump_type))
>> +        {
>> +          const char *old_filename = extra_dump_files[i].pfilename;
>> +          extra_dump_files[i].pstate = -1;
>> +          extra_dump_files[i].pflags |= flags;
>> +          n++;
>> +          /* Override the existing filename.  */
>> +          if (filename)
>> +            {
>> +              extra_dump_files[i].pfilename = xstrdup (filename);
>> +              /* Since it is a command-line provided file, which is
>> +                 common to all the phases, use it in append mode.  */
>> +              extra_dump_files[i].pstate = 1;
>> +            }
>> +          if (old_filename && filename != old_filename)
>> +            free (CONST_CAST (char *, old_filename));
>> +        }
>> +    }
>>
>>    return n;
>>  }
>>
>> +/* Enable opt-info dumps on all IR_DUMP_TYPE passes with FLAGS on
>> +   FILENAME.  Return the number of enabled dumps.  */
>> +
>> +static int
>> +opt_info_enable_all (int ir_dump_type, int flags, const char *filename)
>> +{
>> +  int n = 0;
>> +  size_t i;
>> +
>> +  for (i = TDI_none + 1; i < (size_t) TDI_end; i++)
>> +    {
>> +      if ((dump_files[i].pflags & ir_dump_type))
>> +        {
>> +          const char *old_filename = dump_files[i].alt_filename;
>> +          dump_files[i].alt_state = -1;
>> +          dump_files[i].alt_flags |= flags;
>> +          n++;
>> +          /* Override the existing filename.  */
>> +          if (filename)
>> +            dump_files[i].alt_filename = xstrdup (filename);
>> +          if (old_filename && filename != old_filename)
>> +            free (CONST_CAST (char *, old_filename));
>> +        }
>> +    }
>> +
>> +  for (i = 0; i < extra_dump_files_in_use; i++)
>> +    {
>> +      if ((extra_dump_files[i].pflags & ir_dump_type))
>> +        {
>> +          const char *old_filename = extra_dump_files[i].alt_filename;
>> +          extra_dump_files[i].alt_state = -1;
>> +          extra_dump_files[i].alt_flags |= flags;
>> +          n++;
>> +          /* Override the existing filename.  */
>> +          if (filename)
>> +            extra_dump_files[i].alt_filename = xstrdup (filename);
>> +          if (old_filename && filename != old_filename)
>> +            free (CONST_CAST (char *, old_filename));
>> +        }
>> +    }
>> +
>> +  return n;
>> +}
>> +
>> +/* For given TDF_FLAGS, return corresponding MSG_* flags. */
>> +
>> +static int
>> +remap_tdf_to_msg_flags (const int tdf_flags)
>> +{
>> +  const struct dump_option_value_info *option_ptr;
>> +  int msg_flags = 0;
>> +
>> +  for (option_ptr = dump_options; option_ptr->name; option_ptr++)
>> +    if ((tdf_flags & option_ptr->value))
>> +      {
>> +        /* If we have msg flags in the table use those, otherwise just
>> +           use tdf_flags for compatibility reasons. Recall that TDF_*
>> +           and MSG_* flags are in exclusive range.  */
>> +        msg_flags |= (option_ptr->msg_flags)
>> +          ? option_ptr->msg_flags
>> +          : option_ptr->value;
>> +      }
>> +  return msg_flags;
>> +}
>> +
>>  /* Parse ARG as a dump switch. Return nonzero if it is, and store the
>>     relevant details in the dump_files array.  */
>>
>> @@ -1036,7 +1418,7 @@ dump_switch_p_1 (const char *arg, struct dump_file
>>    if (!option_value)
>>      return 0;
>>
>> -  if (*option_value && *option_value != '-')
>> +  if (*option_value && *option_value != '-' && *option_value != '=')
>>      return 0;
>>
>>    ptr = option_value;
>> @@ -1046,11 +1428,17 @@ dump_switch_p_1 (const char *arg, struct dump_file
>>      {
>>        const struct dump_option_value_info *option_ptr;
>>        const char *end_ptr;
>> +      const char *eq_ptr;
>>        unsigned length;
>>
>>        while (*ptr == '-')
>>         ptr++;
>>        end_ptr = strchr (ptr, '-');
>> +      eq_ptr = strchr (ptr, '=');
>> +
>> +      if (eq_ptr && !end_ptr)
>> +        end_ptr = eq_ptr;
>> +
>>        if (!end_ptr)
>>         end_ptr = ptr + strlen (ptr);
>>        length = end_ptr - ptr;
>> @@ -1058,23 +1446,36 @@ dump_switch_p_1 (const char *arg, struct dump_file
>>        for (option_ptr = dump_options; option_ptr->name; option_ptr++)
>>         if (strlen (option_ptr->name) == length
>>             && !memcmp (option_ptr->name, ptr, length))
>> -         {
>> -           flags |= option_ptr->value;
>> +          {
>> +            flags |= option_ptr->value;
>>             goto found;
>> -         }
>> -      warning (0, "ignoring unknown option %q.*s in %<-fdump-%s%>",
>> -              length, ptr, dfi->swtch);
>> +          }
>> +
>> +      if (*ptr == '=')
>> +        {
>> +          /* Interpret rest of the argument as a dump filename.  This
>> +             filename overrides other command line filenames.  */
>> +          if (dfi->pfilename)
>> +            free (CONST_CAST (char *, dfi->pfilename));
>> +          dfi->pfilename = xstrdup (ptr + 1);
>> +          break;
>> +        }
>> +      else
>> +        warning (0, "ignoring unknown option %q.*s in %<-fdump-%s%>",
>> +                 length, ptr, dfi->swtch);
>>      found:;
>>        ptr = end_ptr;
>>      }
>>
>> -  dfi->state = -1;
>> -  dfi->flags |= flags;
>> +  dfi->pstate = -1;
>> +  dfi->pflags |= flags;
>> +  /* Translate these TDF_* flags to the additional MSG_* flags.  */
>> +  dfi->pflags |= remap_tdf_to_msg_flags (flags);
>>
>>    /* Process -fdump-tree-all and -fdump-rtl-all, by enabling all the
>>       known dumps.  */
>>    if (dfi->suffix == NULL)
>> -    dump_enable_all (dfi->flags);
>> +    dump_enable_all (dfi->pflags, dfi->pfilename);
>>
>>    return 1;
>>  }
>> @@ -1104,6 +1505,101 @@ dump_switch_p (const char *arg)
>>    return any;
>>  }
>>
>> +/* Parse ARG as a -fopt-info= switch and store corresponding info in
>> +   DFI.  Return non-zero if it is a recognized switch.  */
>> +
>> +static int
>> +opt_info_switch_p_1 (const char *arg, struct dump_file_info *dfi)
>> +{
>> +  const char *option_value;
>> +  const char *ptr;
>> +  int flags;
>> +
>> +  option_value = skip_leading_substring (arg, dfi->swtch);
>> +  if (!option_value)
>> +    return 0;
>> +
>> +  if (*option_value && *option_value != '-' && *option_value != '=')
>> +    return 0;
>> +
>> +  ptr = option_value;
>> +  flags = 0;
>> +
>> +  while (*ptr)
>> +    {
>> +      const struct dump_option_value_info *option_ptr;
>> +      const char *end_ptr;
>> +      const char *eq_ptr;
>> +      unsigned length;
>> +
>> +      while (*ptr == '-')
>> +       ptr++;
>> +      end_ptr = strchr (ptr, '-');
>> +      eq_ptr = strchr (ptr, '=');
>> +
>> +      if (eq_ptr && !end_ptr)
>> +        end_ptr = eq_ptr;
>> +
>> +      if (!end_ptr)
>> +       end_ptr = ptr + strlen (ptr);
>> +      length = end_ptr - ptr;
>> +
>> +      for (option_ptr = opt_info_options; option_ptr->name; option_ptr++)
>> +       if (strlen (option_ptr->name) == length
>> +           && !memcmp (option_ptr->name, ptr, length))
>> +          {
>> +            flags |= option_ptr->value;
>> +           goto found;
>> +          }
>> +
>> +      if (*ptr == '=')
>> +        {
>> +          /* Interpret rest of the argument as a dump filename.  This
>> +             filename overrides other command line filenames.  */
>> +          if (dfi->alt_filename)
>> +            free (CONST_CAST (char *, dfi->alt_filename));
>> +          dfi->alt_filename = xstrdup (ptr + 1);
>> +          break;
>> +        }
>> +      else
>> +        warning (0, "ignoring unknown option %q.*s in %<-fopt-info=%s%>",
>> +                 length, ptr, dfi->swtch);
>> +    found:;
>> +      ptr = end_ptr;
>> +    }
>> +
>> +  dfi->alt_state = -1;
>> +  /* If there was no command line opt-info dump option, use a default.  */
>> +  if (!flags)
>> +    flags = MSG_OPTIMIZED_LOCATIONS;
>> +  dfi->alt_flags |= flags;
>> +  /* If no filename was provided, use 'stderr'. */
>> +  if (!dfi->alt_filename)
>> +    dfi->alt_filename = xstrdup ("stderr");
>> +
>> +  /* Process -fopt-info-tree-all and -fopt-info-rtl-all, by enabling
>> +     all the known dumps.  */
>> +  if (dfi->suffix == NULL)
>> +    opt_info_enable_all (dfi->pflags, dfi->alt_flags, dfi->alt_filename);
>> +
>> +  return 1;
>> +}
>> +
>> +int
>> +opt_info_switch_p (const char *arg)
>> +{
>> +  size_t i;
>> +  int any = 0;
>> +
>> +  for (i = TDI_none + 1; i != TDI_end; i++)
>> +    any |= opt_info_switch_p_1 (arg, &dump_files[i]);
>> +
>> +  for (i = 0; i < extra_dump_files_in_use; i++)
>> +    any |= opt_info_switch_p_1 (arg, &extra_dump_files[i]);
>> +
>> +  return any;
>> +}
>> +
>>  /* Dump FUNCTION_DECL FN as tree dump PHASE.  */
>>
>>  void
>> @@ -1123,5 +1619,71 @@ dump_function (int phase, tree fn)
>>  bool
>>  enable_rtl_dump_file (void)
>>  {
>> -  return dump_enable_all (TDF_RTL | TDF_DETAILS | TDF_BLOCKS) > 0;
>> +  return dump_enable_all (TDF_RTL | TDF_DETAILS | TDF_BLOCKS, NULL) > 0;
>>  }
>> +
>> +/* Return true if any dumps are enabled for the given MSG_TYPE, false
>> +   otherwise.  */
>> +
>> +bool
>> +dump_kind_p (int msg_type)
>> +{
>> +  if (!current_function_decl)
>> +    return 0;
>> +  return ((msg_type & pflags) || (msg_type & alt_flags));
>> +}
>> +
>> +/* Print basic block on the dump streams.  */
>> +
>> +void
>> +dump_basic_block (int dump_kind, basic_block bb, int indent)
>> +{
>> +  if (dump_file && (dump_kind & pflags))
>> +    dump_bb (dump_file, bb, indent, TDF_DETAILS);
>> +  if (alt_dump_file && (dump_kind & alt_flags))
>> +    dump_bb (alt_dump_file, bb, indent, TDF_DETAILS);
>> +}
>> +
>> +void
>> +dump_combine_total_stats (void)
>> +{
>> +  if (dump_file)
>> +    print_combine_total_stats (dump_file);
>> +  if (alt_dump_file && (alt_flags & MSG_NOTE))
>> +    print_combine_total_stats (alt_dump_file);
>> +}
>> +
>> +/* Handle -ftree-vectorizer-verbose ARG by remapping it to -fopt-info.
>> +   It remaps the old verbosity values as following:
>> +
>> +   REPORT_NONE ==> No dump is output
>> +   REPORT_VECTORIZED_LOCATIONS ==> "-optimized"
>> +   REPORT_UNVECTORIZED_LOCATIONS ==> "-missed"
>> +
>> +   Any higher verbosity levels result get mapped to "-details" flags.
>> +  */
>> +
>> +void
>> +dump_remap_tree_vectorizer_verbose (const char *arg)
>> +{
>> +  int value = atoi (arg);
>> +  const char *remapped_opt_info = NULL;
>> +
>> +  switch (value)
>> +    {
>> +    case 0:
>> +      break;
>> +    case 1:
>> +      remapped_opt_info = "tree-vect-optimized";
>> +      break;
>> +    case 2:
>> +      remapped_opt_info = "tree-vect-missed";
>> +      break;
>> +    default:
>> +      remapped_opt_info = "tree-vect-details";
>> +      break;
>> +    }
>> +
>> +  if (remapped_opt_info)
>> +    opt_info_switch_p (remapped_opt_info);
>> +}
>> Index: tree-dump.h
>> ===================================================================
>> --- tree-dump.h (revision 191208)
>> +++ tree-dump.h (working copy)
>> @@ -22,6 +22,7 @@ along with GCC; see the file COPYING3.  If not see
>>  #ifndef GCC_TREE_DUMP_H
>>  #define GCC_TREE_DUMP_H
>>
>> +#include "input.h"
>>  #include "splay-tree.h"
>>  #include "dumpfile.h"
>>
>> Index: c-family/c-ada-spec.c
>> ===================================================================
>> --- c-family/c-ada-spec.c       (revision 191208)
>> +++ c-family/c-ada-spec.c       (working copy)
>> @@ -2524,7 +2524,7 @@ print_ada_declaration (pretty_printer *buffer, tre
>>    int is_class = false;
>>    tree name = TYPE_NAME (TREE_TYPE (t));
>>    tree decl_name = DECL_NAME (t);
>> -  bool dump_internal = get_dump_file_info (TDI_ada)->flags & TDF_RAW;
>> +  bool dump_internal = get_dump_file_info (TDI_ada)->pflags & TDF_RAW;
>>    tree orig = NULL_TREE;
>>
>>    if (cpp_check && cpp_check (t, IS_TEMPLATE))
>> Index: c/c-decl.c
>> ===================================================================
>> --- c/c-decl.c  (revision 191208)
>> +++ c/c-decl.c  (working copy)
>> @@ -10082,7 +10082,7 @@ c_write_global_declarations (void)
>>    if (dump_enabled_p (TDI_ada))
>>      {
>>        /* Build a table of files to generate specs for */
>> -      if (get_dump_file_info (TDI_ada)->flags & TDF_SLIM)
>> +      if (get_dump_file_info (TDI_ada)->pflags & TDF_SLIM)
>>         collect_source_ref (main_input_filename);
>>        else
>>         for_each_global_decl (collect_source_ref_cb);
>> Index: dumpfile.h
>> ===================================================================
>> --- dumpfile.h  (revision 191208)
>> +++ dumpfile.h  (working copy)
>> @@ -22,6 +22,9 @@ along with GCC; see the file COPYING3.  If not see
>>  #ifndef GCC_DUMPFILE_H
>>  #define GCC_DUMPFILE_H 1
>>
>> +#include "coretypes.h"
>> +#include "input.h"
>> +
>>  /* Different tree dump places.  When you add new tree dump places,
>>     extend the DUMP_FILES array in tree-dump.c.  */
>>  enum tree_dump_index
>> @@ -43,9 +46,11 @@ enum tree_dump_index
>>    TDI_end
>>  };
>>
>> -/* Bit masks to control dumping. Not all values are applicable to
>> -   all dumps. Add new ones at the end. When you define new
>> -   values, extend the DUMP_OPTIONS array in tree-dump.c */
>> +/* Bit masks to control dumping. Not all values are applicable to all
>> +   dumps. Add new ones at the end. When you define new values, extend
>> +   the DUMP_OPTIONS array in tree-dump.c. These TDF_* flags coexist
>> +   with MSG_* flags and the bit values must be chosen to allow that.
>> +*/
>>  #define TDF_ADDRESS    (1 << 0)        /* dump node addresses */
>>  #define TDF_SLIM       (1 << 1)        /* don't go wild following links */
>>  #define TDF_RAW        (1 << 2)        /* don't unparse the function */
>> @@ -83,6 +88,16 @@ enum tree_dump_index
>>  #define TDF_SCEV       (1 << 24)       /* Dump SCEV details.  */
>>  #define TDF_COMMENT    (1 << 25)       /* Dump lines with prefix ";;"  */
>>
>> +/* Different types of dump classifications. These are extension of
>> +   TDF_* flags and the bit values should be chosen accordingly. */
>> +enum dump_msg_kind {
>> +  /* During the transition to MSG_* dump system, the TDF_* flags and
>> +     MSG_* flags may coexist in a single word. Hence the MSG_* flag
>> +     bits start after the TDF_* bits. */
>> +  MSG_OPTIMIZED_LOCATIONS = 1 << 26,
>> +  MSG_MISSED_OPTIMIZATION = 1 << 27,
>> +  MSG_NOTE = 1 << 28
>> +};
>>
>>  /* In tree-dump.c */
>>
>> @@ -91,9 +106,23 @@ extern int dump_enabled_p (int);
>>  extern int dump_initialized_p (int);
>>  extern FILE *dump_begin (int, int *);
>>  extern void dump_end (int, FILE *);
>> +extern int dump_start (int, int *);
>> +extern void dump_finish (int);
>>  extern void dump_node (const_tree, int, FILE *);
>>  extern int dump_switch_p (const char *);
>> +extern int opt_info_switch_p (const char *);
>>  extern const char *dump_flag_name (int);
>> +extern bool dump_kind_p (int);
>> +extern void dump_printf (int, const char *, ...) ATTRIBUTE_PRINTF_2;
>> +extern void dump_printf_loc (int, source_location,
>> +                             const char *, ...) ATTRIBUTE_PRINTF_3;
>> +extern void dump_basic_block (int, basic_block, int);
>> +extern void dump_generic_expr_loc (int, source_location, int, tree);
>> +extern void dump_generic_expr (int, int, tree);
>> +extern void dump_gimple_stmt_loc (int, source_location, int, gimple, int);
>> +extern void dump_gimple_stmt (int, int, gimple, int);
>> +extern void dump_combine_total_stats (void);
>> +extern void dump_remap_tree_vectorizer_verbose (const char *);
>>
>>  /* Global variables used to communicate with passes.  */
>>  extern FILE *dump_file;
>> @@ -109,8 +138,14 @@ struct dump_file_info
>>    const char *suffix;           /* suffix to give output file.  */
>>    const char *swtch;            /* command line switch */
>>    const char *glob;             /* command line glob  */
>> -  int flags;                    /* user flags */
>> -  int state;                    /* state of play */
>> +  const char *pfilename;        /* filename for the pass-specific stream  */
>> +  const char *alt_filename;     /* filename for the opt-info stream  */
>> +  FILE *pstream;                /* pass-specific dump stream  */
>> +  FILE *alt_stream;             /* opt-info stream */
>> +  int pflags;                   /* dump flags */
>> +  int alt_flags;                /* flags for opt-info */
>> +  int pstate;                   /* state of pass-specific stream */
>> +  int alt_state;                /* state of the opt-info stream */
>>    int num;                      /* dump file number */
>>  };
>>
>> Index: tree-vect-loop-manip.c
>> ===================================================================
>> --- tree-vect-loop-manip.c      (revision 191208)
>> +++ tree-vect-loop-manip.c      (working copy)
>> @@ -23,6 +23,7 @@ along with GCC; see the file COPYING3.  If not see
>>  #include "config.h"
>>  #include "system.h"
>>  #include "coretypes.h"
>> +#include "dumpfile.h"
>>  #include "tm.h"
>>  #include "ggc.h"
>>  #include "tree.h"
>> @@ -791,14 +792,12 @@ slpeel_make_loop_iterate_ntimes (struct loop *loop
>>    free_stmt_vec_info (orig_cond);
>>
>>    loop_loc = find_loop_location (loop);
>> -  if (dump_file && (dump_flags & TDF_DETAILS))
>> +  if (dump_kind_p (MSG_NOTE))
>>      {
>> -      if (loop_loc != UNKNOWN_LOC)
>> -        fprintf (dump_file, "\nloop at %s:%d: ",
>> -                 LOC_FILE (loop_loc), LOC_LINE (loop_loc));
>> -      print_gimple_stmt (dump_file, cond_stmt, 0, TDF_SLIM);
>> +      dump_printf (MSG_NOTE, "\nloop at %s:%d: ", LOC_FILE (loop_loc),
>> +                   LOC_LINE (loop_loc));
>> +      dump_gimple_stmt (MSG_NOTE, TDF_SLIM, cond_stmt, 0);
>>      }
>> -
>>    loop->nb_iterations = niters;
>>  }
>>
>> @@ -1220,13 +1219,8 @@ slpeel_tree_peel_loop_to_edge (struct loop *loop,
>>    if (!(new_loop = slpeel_tree_duplicate_loop_to_edge_cfg (loop, e)))
>>      {
>>        loop_loc = find_loop_location (loop);
>> -      if (dump_file && (dump_flags & TDF_DETAILS))
>> -        {
>> -          if (loop_loc != UNKNOWN_LOC)
>> -            fprintf (dump_file, "\n%s:%d: note: ",
>> -                     LOC_FILE (loop_loc), LOC_LINE (loop_loc));
>> -          fprintf (dump_file, "tree_duplicate_loop_to_edge_cfg failed.\n");
>> -        }
>> +      dump_printf_loc (MSG_MISSED_OPTIMIZATION, loop_loc,
>> +                       "tree_duplicate_loop_to_edge_cfg failed.\n");
>>        return NULL;
>>      }
>>
>> @@ -1642,19 +1636,18 @@ vect_can_advance_ivs_p (loop_vec_info loop_vinfo)
>>
>>    /* Analyze phi functions of the loop header.  */
>>
>> -  if (vect_print_dump_info (REPORT_DETAILS))
>> -    fprintf (vect_dump, "vect_can_advance_ivs_p:");
>> -
>> +  if (dump_kind_p (MSG_NOTE))
>> +    dump_printf_loc (MSG_NOTE, vect_location, "vect_can_advance_ivs_p:");
>>    for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi))
>>      {
>>        tree access_fn = NULL;
>>        tree evolution_part;
>>
>>        phi = gsi_stmt (gsi);
>> -      if (vect_print_dump_info (REPORT_DETAILS))
>> +      if (dump_kind_p (MSG_NOTE))
>>         {
>> -          fprintf (vect_dump, "Analyze phi: ");
>> -          print_gimple_stmt (vect_dump, phi, 0, TDF_SLIM);
>> +          dump_printf_loc (MSG_NOTE, vect_location, "Analyze phi: ");
>> +          dump_gimple_stmt (MSG_NOTE, TDF_SLIM, phi, 0);
>>         }
>>
>>        /* Skip virtual phi's. The data dependences that are associated with
>> @@ -1662,8 +1655,9 @@ vect_can_advance_ivs_p (loop_vec_info loop_vinfo)
>>
>>        if (virtual_operand_p (PHI_RESULT (phi)))
>>         {
>> -         if (vect_print_dump_info (REPORT_DETAILS))
>> -           fprintf (vect_dump, "virtual phi. skip.");
>> +         if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
>> +           dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
>> +                             "virtual phi. skip.");
>>           continue;
>>         }
>>
>> @@ -1671,8 +1665,9 @@ vect_can_advance_ivs_p (loop_vec_info loop_vinfo)
>>
>>        if (STMT_VINFO_DEF_TYPE (vinfo_for_stmt (phi)) == vect_reduction_def)
>>          {
>> -          if (vect_print_dump_info (REPORT_DETAILS))
>> -            fprintf (vect_dump, "reduc phi. skip.");
>> +          if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
>> +            dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
>> +                             "reduc phi. skip.");
>>            continue;
>>          }
>>
>> @@ -1683,23 +1678,25 @@ vect_can_advance_ivs_p (loop_vec_info loop_vinfo)
>>
>>        if (!access_fn)
>>         {
>> -         if (vect_print_dump_info (REPORT_DETAILS))
>> -           fprintf (vect_dump, "No Access function.");
>> +         if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
>> +           dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
>> +                             "No Access function.");
>>           return false;
>>         }
>>
>> -      if (vect_print_dump_info (REPORT_DETAILS))
>> +      if (dump_kind_p (MSG_NOTE))
>>          {
>> -         fprintf (vect_dump, "Access function of PHI: ");
>> -         print_generic_expr (vect_dump, access_fn, TDF_SLIM);
>> +         dump_printf_loc (MSG_NOTE, vect_location,
>> +                           "Access function of PHI: ");
>> +         dump_generic_expr (MSG_NOTE, TDF_SLIM, access_fn);
>>          }
>>
>>        evolution_part = evolution_part_in_loop_num (access_fn, loop->num);
>>
>>        if (evolution_part == NULL_TREE)
>>          {
>> -         if (vect_print_dump_info (REPORT_DETAILS))
>> -           fprintf (vect_dump, "No evolution.");
>> +         if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
>> +           dump_printf (MSG_MISSED_OPTIMIZATION, "No evolution.");
>>           return false;
>>          }
>>
>> @@ -1783,17 +1780,19 @@ vect_update_ivs_after_vectorizer (loop_vec_info lo
>>
>>        phi = gsi_stmt (gsi);
>>        phi1 = gsi_stmt (gsi1);
>> -      if (vect_print_dump_info (REPORT_DETAILS))
>> +      if (dump_kind_p (MSG_NOTE))
>>          {
>> -          fprintf (vect_dump, "vect_update_ivs_after_vectorizer: phi: ");
>> -         print_gimple_stmt (vect_dump, phi, 0, TDF_SLIM);
>> +          dump_printf_loc (MSG_NOTE, vect_location,
>> +                           "vect_update_ivs_after_vectorizer: phi: ");
>> +         dump_gimple_stmt (MSG_NOTE, TDF_SLIM, phi, 0);
>>          }
>>
>>        /* Skip virtual phi's.  */
>>        if (virtual_operand_p (PHI_RESULT (phi)))
>>         {
>> -         if (vect_print_dump_info (REPORT_DETAILS))
>> -           fprintf (vect_dump, "virtual phi. skip.");
>> +         if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
>> +           dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
>> +                             "virtual phi. skip.");
>>           continue;
>>         }
>>
>> @@ -1801,8 +1800,9 @@ vect_update_ivs_after_vectorizer (loop_vec_info lo
>>        stmt_info = vinfo_for_stmt (phi);
>>        if (STMT_VINFO_DEF_TYPE (stmt_info) == vect_reduction_def)
>>          {
>> -          if (vect_print_dump_info (REPORT_DETAILS))
>> -            fprintf (vect_dump, "reduc phi. skip.");
>> +         if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
>> +           dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
>> +                             "reduc phi. skip.");
>>            continue;
>>          }
>>
>> @@ -1863,8 +1863,9 @@ vect_do_peeling_for_loop_bound (loop_vec_info loop
>>    tree cond_expr = NULL_TREE;
>>    gimple_seq cond_expr_stmt_list = NULL;
>>
>> -  if (vect_print_dump_info (REPORT_DETAILS))
>> -    fprintf (vect_dump, "=== vect_do_peeling_for_loop_bound ===");
>> +  if (dump_kind_p (MSG_OPTIMIZED_LOCATIONS))
>> +    dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, vect_location,
>> +                     "=== vect_do_peeling_for_loop_bound ===");
>>
>>    initialize_original_copy_tables ();
>>
>> @@ -1909,9 +1910,9 @@ vect_do_peeling_for_loop_bound (loop_vec_info loop
>>    if (check_profitability)
>>      max_iter = MAX (max_iter, (int) th);
>>    record_niter_bound (new_loop, double_int::from_shwi (max_iter), false, true);
>> -  if (dump_file && (dump_flags & TDF_DETAILS))
>> -    fprintf (dump_file, "Setting upper bound of nb iterations for epilogue "
>> -            "loop to %d\n", max_iter);
>> +  dump_printf (MSG_OPTIMIZED_LOCATIONS,
>> +               "Setting upper bound of nb iterations for epilogue "
>> +               "loop to %d\n", max_iter);
>>
>>    /* After peeling we have to reset scalar evolution analyzer.  */
>>    scev_reset ();
>> @@ -1973,8 +1974,8 @@ vect_gen_niters_for_prolog_loop (loop_vec_info loo
>>      {
>>        int npeel = LOOP_PEELING_FOR_ALIGNMENT (loop_vinfo);
>>
>> -      if (vect_print_dump_info (REPORT_DETAILS))
>> -        fprintf (vect_dump, "known peeling = %d.", npeel);
>> +      if (dump_kind_p (MSG_OPTIMIZED_LOCATIONS))
>> +        dump_printf (MSG_OPTIMIZED_LOCATIONS, "known peeling = %d.", npeel);
>>
>>        iters = build_int_cst (niters_type, npeel);
>>      }
>> @@ -2024,10 +2025,11 @@ vect_gen_niters_for_prolog_loop (loop_vec_info loo
>>    if (TREE_CODE (loop_niters) != INTEGER_CST)
>>      iters = fold_build2 (MIN_EXPR, niters_type, iters, loop_niters);
>>
>> -  if (vect_print_dump_info (REPORT_DETAILS))
>> +  if (dump_kind_p (MSG_OPTIMIZED_LOCATIONS))
>>      {
>> -      fprintf (vect_dump, "niters for prolog loop: ");
>> -      print_generic_expr (vect_dump, iters, TDF_SLIM);
>> +      dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, vect_location,
>> +                       "niters for prolog loop: ");
>> +      dump_generic_expr (MSG_OPTIMIZED_LOCATIONS, TDF_SLIM, iters);
>>      }
>>
>>    var = create_tmp_var (niters_type, "prolog_loop_niters");
>> @@ -2080,10 +2082,11 @@ vect_update_inits_of_drs (loop_vec_info loop_vinfo
>>    unsigned int i;
>>    VEC (data_reference_p, heap) *datarefs = LOOP_VINFO_DATAREFS (loop_vinfo);
>>    struct data_reference *dr;
>> +
>> + if (dump_kind_p (MSG_OPTIMIZED_LOCATIONS))
>> +    dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, vect_location,
>> +                     "=== vect_update_inits_of_dr ===");
>>
>> -  if (vect_print_dump_info (REPORT_DETAILS))
>> -    fprintf (vect_dump, "=== vect_update_inits_of_dr ===");
>> -
>>    FOR_EACH_VEC_ELT (data_reference_p, datarefs, i, dr)
>>      vect_update_init_of_dr (dr, niters);
>>  }
>> @@ -2108,8 +2111,9 @@ vect_do_peeling_for_alignment (loop_vec_info loop_
>>    struct loop *new_loop;
>>    int max_iter;
>>
>> -  if (vect_print_dump_info (REPORT_DETAILS))
>> -    fprintf (vect_dump, "=== vect_do_peeling_for_alignment ===");
>> +  if (dump_kind_p (MSG_OPTIMIZED_LOCATIONS))
>> +    dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, vect_location,
>> +                     "=== vect_do_peeling_for_alignment ===");
>>
>>    initialize_original_copy_tables ();
>>
>> @@ -2131,9 +2135,9 @@ vect_do_peeling_for_alignment (loop_vec_info loop_
>>    if (check_profitability)
>>      max_iter = MAX (max_iter, (int) th);
>>    record_niter_bound (new_loop, double_int::from_shwi (max_iter), false, true);
>> -  if (dump_file && (dump_flags & TDF_DETAILS))
>> -    fprintf (dump_file, "Setting upper bound of nb iterations for prologue "
>> -            "loop to %d\n", max_iter);
>> +  dump_printf (MSG_OPTIMIZED_LOCATIONS,
>> +               "Setting upper bound of nb iterations for prologue "
>> +               "loop to %d\n", max_iter);
>>
>>    /* Update number of times loop executes.  */
>>    n_iters = LOOP_VINFO_NITERS (loop_vinfo);
>> @@ -2416,13 +2420,13 @@ vect_create_cond_for_alias_checks (loop_vec_info l
>>        segment_length_a = vect_vfa_segment_size (dr_a, length_factor);
>>        segment_length_b = vect_vfa_segment_size (dr_b, length_factor);
>>
>> -      if (vect_print_dump_info (REPORT_DR_DETAILS))
>> +      if (dump_kind_p (MSG_OPTIMIZED_LOCATIONS))
>>         {
>> -         fprintf (vect_dump,
>> -                  "create runtime check for data references ");
>> -         print_generic_expr (vect_dump, DR_REF (dr_a), TDF_SLIM);
>> -         fprintf (vect_dump, " and ");
>> -         print_generic_expr (vect_dump, DR_REF (dr_b), TDF_SLIM);
>> +         dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, vect_location,
>> +                           "create runtime check for data references ");
>> +         dump_generic_expr (MSG_OPTIMIZED_LOCATIONS, TDF_SLIM, DR_REF (dr_a));
>> +         dump_printf (MSG_OPTIMIZED_LOCATIONS, " and ");
>> +         dump_generic_expr (MSG_OPTIMIZED_LOCATIONS, TDF_SLIM, DR_REF (dr_b));
>>         }
>>
>>        seg_a_min = addr_base_a;
>> @@ -2447,9 +2451,10 @@ vect_create_cond_for_alias_checks (loop_vec_info l
>>         *cond_expr = part_cond_expr;
>>      }
>>
>> -  if (vect_print_dump_info (REPORT_VECTORIZED_LOCATIONS))
>> -    fprintf (vect_dump, "created %u versioning for alias checks.\n",
>> -             VEC_length (ddr_p, may_alias_ddrs));
>> +  if (dump_kind_p (MSG_OPTIMIZED_LOCATIONS))
>> +    dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, vect_location,
>> +                    "created %u versioning for alias checks.\n",
>> +                    VEC_length (ddr_p, may_alias_ddrs));
>>  }
>>
>>
>> Index: cp/decl2.c
>> ===================================================================
>> --- cp/decl2.c  (revision 191208)
>> +++ cp/decl2.c  (working copy)
>> @@ -3695,7 +3695,7 @@ cp_write_global_declarations (void)
>>    /* Handle -fdump-ada-spec[-slim] */
>>    if (dump_enabled_p (TDI_ada))
>>      {
>> -      if (get_dump_file_info (TDI_ada)->flags & TDF_SLIM)
>> +      if (get_dump_file_info (TDI_ada)->pflags & TDF_SLIM)
>>         collect_source_ref (main_input_filename);
>>        else
>>         collect_source_refs (global_namespace);
>> Index: opts.c
>> ===================================================================
>> --- opts.c      (revision 191208)
>> +++ opts.c      (working copy)
>> @@ -25,6 +25,7 @@ along with GCC; see the file COPYING3.  If not see
>>  #include "system.h"
>>  #include "intl.h"
>>  #include "coretypes.h"
>> +#include "dumpfile.h"
>>  #include "opts.h"
>>  #include "options.h"
>>  #include "tm.h" /* For STACK_CHECK_BUILTIN,
>> @@ -139,19 +140,6 @@ set_struct_debug_option (struct gcc_options *opts,
>>      }
>>  }
>>
>> -/* Handle -ftree-vectorizer-verbose=VAL for options OPTS.  */
>> -
>> -static void
>> -vect_set_verbosity_level (struct gcc_options *opts, int val)
>> -{
>> -   if (val < MAX_VERBOSITY_LEVEL)
>> -     opts->x_user_vect_verbosity_level = (enum vect_verbosity_levels) val;
>> -   else
>> -     opts->x_user_vect_verbosity_level
>> -      = (enum vect_verbosity_levels) (MAX_VERBOSITY_LEVEL - 1);
>> -}
>> -
>> -
>>  /* Strip off a legitimate source ending from the input string NAME of
>>     length LEN.  Rather than having to know the names used by all of
>>     our front ends, we strip off an ending of a period followed by
>> @@ -1671,8 +1659,14 @@ common_handle_option (struct gcc_options *opts,
>>        opts->x_flag_stack_usage_info = value != 0;
>>        break;
>>
>> +    case OPT_fopt_info_:
>> +      /* Deferred.  */
>> +      break;
>> +
>>      case OPT_ftree_vectorizer_verbose_:
>> -      vect_set_verbosity_level (opts, value);
>> +      /* -ftree-vectorizer-verbose is deprecated. It is defined in
>> +         -terms of fopt-info=N. */
>> +      /* Deferred.  */
>>        break;
>>
>>      case OPT_g:
>> Index: tree-parloops.c
>> ===================================================================
>> --- tree-parloops.c     (revision 191208)
>> +++ tree-parloops.c     (working copy)
>> @@ -1943,7 +1943,6 @@ gather_scalar_reductions (loop_p loop, htab_t redu
>>    gimple_stmt_iterator gsi;
>>    loop_vec_info simple_loop_info;
>>
>> -  vect_dump = NULL;
>>    simple_loop_info = vect_analyze_loop_form (loop);
>>
>>    for (gsi = gsi_start_phis (loop->header); !gsi_end_p (gsi); gsi_next (&gsi))
>> Index: gimple-pretty-print.c
>> ===================================================================
>> --- gimple-pretty-print.c       (revision 191208)
>> +++ gimple-pretty-print.c       (working copy)
>> @@ -69,7 +69,7 @@ maybe_init_pretty_print (FILE *file)
>>  }
>>
>>
>> -/* Emit a newline and SPC indentantion spaces to BUFFER.  */
>> +/* Emit a newline and SPC indentation spaces to BUFFER.  */
>>
>>  static void
>>  newline_and_indent (pretty_printer *buffer, int spc)
>> @@ -89,20 +89,20 @@ debug_gimple_stmt (gimple gs)
>>  }
>>
>>
>> -/* Dump GIMPLE statement G to FILE using SPC indentantion spaces and
>> -   FLAGS as in dump_gimple_stmt.  */
>> +/* Print GIMPLE statement G to FILE using SPC indentation spaces and
>> +   FLAGS as in pp_gimple_stmt_1.  */
>>
>>  void
>>  print_gimple_stmt (FILE *file, gimple g, int spc, int flags)
>>  {
>>    maybe_init_pretty_print (file);
>> -  dump_gimple_stmt (&buffer, g, spc, flags);
>> +  pp_gimple_stmt_1 (&buffer, g, spc, flags);
>>    pp_newline_and_flush (&buffer);
>>  }
>>
>>
>> -/* Dump GIMPLE statement G to FILE using SPC indentantion spaces and
>> -   FLAGS as in dump_gimple_stmt.  Print only the right-hand side
>> +/* Print GIMPLE statement G to FILE using SPC indentation spaces and
>> +   FLAGS as in pp_gimple_stmt_1.  Print only the right-hand side
>>     of the statement.  */
>>
>>  void
>> @@ -110,12 +110,12 @@ print_gimple_expr (FILE *file, gimple g, int spc,
>>  {
>>    flags |= TDF_RHS_ONLY;
>>    maybe_init_pretty_print (file);
>> -  dump_gimple_stmt (&buffer, g, spc, flags);
>> +  pp_gimple_stmt_1 (&buffer, g, spc, flags);
>>  }
>>
>>
>> -/* Print the GIMPLE sequence SEQ on BUFFER using SPC indentantion
>> -   spaces and FLAGS as in dump_gimple_stmt.
>> +/* Print the GIMPLE sequence SEQ on BUFFER using SPC indentation
>> +   spaces and FLAGS as in pp_gimple_stmt_1.
>>     The caller is responsible for calling pp_flush on BUFFER to finalize
>>     the pretty printer.  */
>>
>> @@ -128,15 +128,15 @@ dump_gimple_seq (pretty_printer *buffer, gimple_se
>>      {
>>        gimple gs = gsi_stmt (i);
>>        INDENT (spc);
>> -      dump_gimple_stmt (buffer, gs, spc, flags);
>> +      pp_gimple_stmt_1 (buffer, gs, spc, flags);
>>        if (!gsi_one_before_end_p (i))
>>         pp_newline (buffer);
>>      }
>>  }
>>
>>
>> -/* Dump GIMPLE sequence SEQ to FILE using SPC indentantion spaces and
>> -   FLAGS as in dump_gimple_stmt.  */
>> +/* Print GIMPLE sequence SEQ to FILE using SPC indentation spaces and
>> +   FLAGS as in pp_gimple_stmt_1.  */
>>
>>  void
>>  print_gimple_seq (FILE *file, gimple_seq seq, int spc, int flags)
>> @@ -245,7 +245,7 @@ dump_gimple_fmt (pretty_printer *buffer, int spc,
>>
>>
>>  /* Helper for dump_gimple_assign.  Print the unary RHS of the
>> -   assignment GS.  BUFFER, SPC and FLAGS are as in dump_gimple_stmt.  */
>> +   assignment GS.  BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1.  */
>>
>>  static void
>>  dump_unary_rhs (pretty_printer *buffer, gimple gs, int spc, int flags)
>> @@ -329,7 +329,7 @@ dump_unary_rhs (pretty_printer *buffer, gimple gs,
>>
>>
>>  /* Helper for dump_gimple_assign.  Print the binary RHS of the
>> -   assignment GS.  BUFFER, SPC and FLAGS are as in dump_gimple_stmt.  */
>> +   assignment GS.  BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1.  */
>>
>>  static void
>>  dump_binary_rhs (pretty_printer *buffer, gimple gs, int spc, int flags)
>> @@ -385,7 +385,7 @@ dump_binary_rhs (pretty_printer *buffer, gimple gs
>>  }
>>
>>  /* Helper for dump_gimple_assign.  Print the ternary RHS of the
>> -   assignment GS.  BUFFER, SPC and FLAGS are as in dump_gimple_stmt.  */
>> +   assignment GS.  BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1.  */
>>
>>  static void
>>  dump_ternary_rhs (pretty_printer *buffer, gimple gs, int spc, int flags)
>> @@ -470,7 +470,7 @@ dump_ternary_rhs (pretty_printer *buffer, gimple g
>>
>>
>>  /* Dump the gimple assignment GS.  BUFFER, SPC and FLAGS are as in
>> -   dump_gimple_stmt.  */
>> +   pp_gimple_stmt_1.  */
>>
>>  static void
>>  dump_gimple_assign (pretty_printer *buffer, gimple gs, int spc, int flags)
>> @@ -529,7 +529,7 @@ dump_gimple_assign (pretty_printer *buffer, gimple
>>
>>
>>  /* Dump the return statement GS.  BUFFER, SPC and FLAGS are as in
>> -   dump_gimple_stmt.  */
>> +   pp_gimple_stmt_1.  */
>>
>>  static void
>>  dump_gimple_return (pretty_printer *buffer, gimple gs, int spc, int flags)
>> @@ -616,7 +616,7 @@ pp_points_to_solution (pretty_printer *buffer, str
>>  }
>>
>>  /* Dump the call statement GS.  BUFFER, SPC and FLAGS are as in
>> -   dump_gimple_stmt.  */
>> +   pp_gimple_stmt_1.  */
>>
>>  static void
>>  dump_gimple_call (pretty_printer *buffer, gimple gs, int spc, int flags)
>> @@ -749,7 +749,7 @@ dump_gimple_call (pretty_printer *buffer, gimple g
>>
>>
>>  /* Dump the switch statement GS.  BUFFER, SPC and FLAGS are as in
>> -   dump_gimple_stmt.  */
>> +   pp_gimple_stmt_1.  */
>>
>>  static void
>>  dump_gimple_switch (pretty_printer *buffer, gimple gs, int spc, int flags)
>> @@ -782,7 +782,7 @@ dump_gimple_switch (pretty_printer *buffer, gimple
>>
>>
>>  /* Dump the gimple conditional GS.  BUFFER, SPC and FLAGS are as in
>> -   dump_gimple_stmt.  */
>> +   pp_gimple_stmt_1.  */
>>
>>  static void
>>  dump_gimple_cond (pretty_printer *buffer, gimple gs, int spc, int flags)
>> @@ -1573,7 +1573,7 @@ dump_gimple_asm (pretty_printer *buffer, gimple gs
>>  }
>>
>>
>> -/* Dump a PHI node PHI.  BUFFER, SPC and FLAGS are as in dump_gimple_stmt.
>> +/* Dump a PHI node PHI.  BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1.
>>     The caller is responsible for calling pp_flush on BUFFER to finalize
>>     pretty printer.  */
>>
>> @@ -1807,7 +1807,7 @@ dump_gimple_omp_atomic_store (pretty_printer *buff
>>
>>
>>  /* Dump all the memory operands for statement GS.  BUFFER, SPC and
>> -   FLAGS are as in dump_gimple_stmt.  */
>> +   FLAGS are as in pp_gimple_stmt_1.  */
>>
>>  static void
>>  dump_gimple_mem_ops (pretty_printer *buffer, gimple gs, int spc, int flags)
>> @@ -1838,13 +1838,13 @@ dump_gimple_mem_ops (pretty_printer *buffer, gimpl
>>  }
>>
>>
>> -/* Dump the gimple statement GS on the pretty printer BUFFER, SPC
>> +/* Print the gimple statement GS on the pretty printer BUFFER, SPC
>>     spaces of indent.  FLAGS specifies details to show in the dump (see
>>     TDF_* in dumpfile.h).  The caller is responsible for calling
>>     pp_flush on BUFFER to finalize the pretty printer.  */
>>
>>  void
>> -dump_gimple_stmt (pretty_printer *buffer, gimple gs, int spc, int flags)
>> +pp_gimple_stmt_1 (pretty_printer *buffer, gimple gs, int spc, int flags)
>>  {
>>    if (!gs)
>>      return;
>> @@ -2253,7 +2253,7 @@ gimple_dump_bb_buff (pretty_printer *buffer, basic
>>        curr_indent = gimple_code (stmt) == GIMPLE_LABEL ? label_indent : indent;
>>
>>        INDENT (curr_indent);
>> -      dump_gimple_stmt (buffer, stmt, curr_indent, flags);
>> +      pp_gimple_stmt_1 (buffer, stmt, curr_indent, flags);
>>        pp_newline_and_flush (buffer);
>>        gcc_checking_assert (DECL_STRUCT_FUNCTION (current_function_decl));
>>        dump_histograms_for_stmt (DECL_STRUCT_FUNCTION (current_function_decl),
>> Index: gimple-pretty-print.h
>> ===================================================================
>> --- gimple-pretty-print.h       (revision 191208)
>> +++ gimple-pretty-print.h       (working copy)
>> @@ -31,6 +31,6 @@ extern void debug_gimple_seq (gimple_seq);
>>  extern void print_gimple_seq (FILE *, gimple_seq, int, int);
>>  extern void print_gimple_stmt (FILE *, gimple, int, int);
>>  extern void print_gimple_expr (FILE *, gimple, int, int);
>> -extern void dump_gimple_stmt (pretty_printer *, gimple, int, int);
>> +extern void pp_gimple_stmt_1 (pretty_printer *, gimple, int, int);
>>
>>  #endif /* ! GCC_GIMPLE_PRETTY_PRINT_H */
>> Index: tree-vectorizer.c
>> ===================================================================
>> --- tree-vectorizer.c   (revision 191208)
>> +++ tree-vectorizer.c   (working copy)
>> @@ -58,6 +58,7 @@ along with GCC; see the file COPYING3.  If not see
>>  #include "config.h"
>>  #include "system.h"
>>  #include "coretypes.h"
>> +#include "dumpfile.h"
>>  #include "tm.h"
>>  #include "ggc.h"
>>  #include "tree.h"
>> @@ -67,13 +68,6 @@ along with GCC; see the file COPYING3.  If not see
>>  #include "tree-vectorizer.h"
>>  #include "tree-pass.h"
>>
>> -/* vect_dump will be set to stderr or dump_file if exist.  */
>> -FILE *vect_dump;
>> -
>> -/* vect_verbosity_level set to an invalid value
>> -   to mark that it's uninitialized.  */
>> -static enum vect_verbosity_levels vect_verbosity_level = MAX_VERBOSITY_LEVEL;
>> -
>>  /* Loop or bb location.  */
>>  LOC vect_location;
>>
>> @@ -81,82 +75,6 @@ LOC vect_location;
>>  VEC(vec_void_p,heap) *stmt_vec_info_vec;
>>
>>
>> -
>> -/* Function vect_set_dump_settings.
>> -
>> -   Fix the verbosity level of the vectorizer if the
>> -   requested level was not set explicitly using the flag
>> -   -ftree-vectorizer-verbose=N.
>> -   Decide where to print the debugging information (dump_file/stderr).
>> -   If the user defined the verbosity level, but there is no dump file,
>> -   print to stderr, otherwise print to the dump file.  */
>> -
>> -static void
>> -vect_set_dump_settings (bool slp)
>> -{
>> -  vect_dump = dump_file;
>> -
>> -  /* Check if the verbosity level was defined by the user:  */
>> -  if (user_vect_verbosity_level != MAX_VERBOSITY_LEVEL)
>> -    {
>> -      vect_verbosity_level = user_vect_verbosity_level;
>> -      /* Ignore user defined verbosity if dump flags require higher level of
>> -         verbosity.  */
>> -      if (dump_file)
>> -        {
>> -          if (((dump_flags & TDF_DETAILS)
>> -                && vect_verbosity_level >= REPORT_DETAILS)
>> -              || ((dump_flags & TDF_STATS)
>> -                   && vect_verbosity_level >= REPORT_UNVECTORIZED_LOCATIONS))
>> -            return;
>> -        }
>> -      else
>> -        {
>> -          /* If there is no dump file, print to stderr in case of loop
>> -             vectorization.  */
>> -          if (!slp)
>> -            vect_dump = stderr;
>> -
>> -          return;
>> -        }
>> -    }
>> -
>> -  /* User didn't specify verbosity level:  */
>> -  if (dump_file && (dump_flags & TDF_DETAILS))
>> -    vect_verbosity_level = REPORT_DETAILS;
>> -  else if (dump_file && (dump_flags & TDF_STATS))
>> -    vect_verbosity_level = REPORT_UNVECTORIZED_LOCATIONS;
>> -  else
>> -    vect_verbosity_level = REPORT_NONE;
>> -
>> -  gcc_assert (dump_file || vect_verbosity_level == REPORT_NONE);
>> -}
>> -
>> -
>> -/* Function debug_loop_details.
>> -
>> -   For vectorization debug dumps.  */
>> -
>> -bool
>> -vect_print_dump_info (enum vect_verbosity_levels vl)
>> -{
>> -  if (vl > vect_verbosity_level)
>> -    return false;
>> -
>> -  if (!current_function_decl || !vect_dump)
>> -    return false;
>> -
>> -  if (vect_location == UNKNOWN_LOC)
>> -    fprintf (vect_dump, "\n%s:%d: note: ",
>> -            DECL_SOURCE_FILE (current_function_decl),
>> -            DECL_SOURCE_LINE (current_function_decl));
>> -  else
>> -    fprintf (vect_dump, "\n%d: ", LOC_LINE (vect_location));
>> -
>> -  return true;
>> -}
>> -
>> -
>>  /* Function vectorize_loops.
>>     Entry point to loop vectorization phase.  */
>> @@ -176,9 +94,6 @@ vectorize_loops (void)
>>    if (vect_loops_num <= 1)
>>      return 0;
>>
>> -  /* Fix the verbosity level if not defined explicitly by the user.  */
>> -  vect_set_dump_settings (false);
>> -
>>    init_stmt_vec_info_vec ();
>>
>>    /*  ----------- Analyze loops. -----------  */
>> @@ -192,10 +107,9 @@ vectorize_loops (void)
>>         loop_vec_info loop_vinfo;
>>
>>         vect_location = find_loop_location (loop);
>> -        if (vect_location != UNKNOWN_LOC
>> -            && vect_verbosity_level > REPORT_NONE)
>> -         fprintf (vect_dump, "\nAnalyzing loop at %s:%d\n",
>> -            LOC_FILE (vect_location), LOC_LINE (vect_location));
>> +        if (vect_location != UNKNOWN_LOC && dump_kind_p (MSG_NOTE))
>> +         dump_printf (MSG_NOTE, "\nAnalyzing loop at %s:%d\n",
>> +                       LOC_FILE (vect_location), LOC_LINE (vect_location));
>>
>>         loop_vinfo = vect_analyze_loop (loop);
>>         loop->aux = loop_vinfo;
>> @@ -203,11 +117,9 @@ vectorize_loops (void)
>>         if (!loop_vinfo || !LOOP_VINFO_VECTORIZABLE_P (loop_vinfo))
>>           continue;
>>
>> -        if (vect_location != UNKNOWN_LOC
>> -            && vect_verbosity_level > REPORT_NONE)
>> -          fprintf (vect_dump, "\n\nVectorizing loop at %s:%d\n",
>> -            LOC_FILE (vect_location), LOC_LINE (vect_location));
>> -
>> +        if (vect_location != UNKNOWN_LOC && dump_kind_p (MSG_NOTE))
>> +          dump_printf (MSG_NOTE, "\n\nVectorizing loop at %s:%d\n",
>> +                       LOC_FILE (vect_location), LOC_LINE (vect_location));
>>         vect_transform_loop (loop_vinfo);
>>         num_vectorized_loops++;
>>        }
>> @@ -215,11 +127,11 @@ vectorize_loops (void)
>>    vect_location = UNKNOWN_LOC;
>>
>>    statistics_counter_event (cfun, "Vectorized loops", num_vectorized_loops);
>> -  if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS)
>> -      || (num_vectorized_loops > 0
>> -         && vect_print_dump_info (REPORT_VECTORIZED_LOCATIONS)))
>> -    fprintf (vect_dump, "vectorized %u loops in function.\n",
>> -            num_vectorized_loops);
>> +  if (dump_kind_p (MSG_MISSED_OPTIMIZATION)
>> +      || (num_vectorized_loops > 0 && dump_kind_p (MSG_OPTIMIZED_LOCATIONS)))
>> +    dump_printf_loc (MSG_OPTIMIZED_LOCATIONS | MSG_MISSED_OPTIMIZATION,
>> +                     vect_location, "vectorized %u loops in function.\n",
>> +                     num_vectorized_loops);
>>
>>    /*  ----------- Finalize. -----------  */
>>
>> @@ -248,9 +160,6 @@ execute_vect_slp (void)
>>  {
>>    basic_block bb;
>>
>> -  /* Fix the verbosity level if not defined explicitly by the user.  */
>> -  vect_set_dump_settings (true);
>> -
>>    init_stmt_vec_info_vec ();
>>
>>    FOR_EACH_BB (bb)
>> @@ -260,9 +169,9 @@ execute_vect_slp (void)
>>        if (vect_slp_analyze_bb (bb))
>>          {
>>            vect_slp_transform_bb (bb);
>> -
>> -          if (vect_print_dump_info (REPORT_VECTORIZED_LOCATIONS))
>> -            fprintf (vect_dump, "basic block vectorized using SLP\n");
>> +          if (dump_kind_p (MSG_OPTIMIZED_LOCATIONS))
>> +            dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, vect_location,
>> +                            "basic block vectorized using SLP\n");
>>          }
>>      }
>>
>> @@ -335,12 +244,9 @@ increase_alignment (void)
>>          {
>>            DECL_ALIGN (decl) = TYPE_ALIGN (vectype);
>>            DECL_USER_ALIGN (decl) = 1;
>> -          if (dump_file)
>> -            {
>> -              fprintf (dump_file, "Increasing alignment of decl: ");
>> -              print_generic_expr (dump_file, decl, TDF_SLIM);
>> -             fprintf (dump_file, "\n");
>> -            }
>> +          dump_printf (MSG_NOTE, "Increasing alignment of decl: ");
>> +          dump_generic_expr (MSG_NOTE, TDF_SLIM, decl);
>> +          dump_printf (MSG_NOTE, "\n");
>>          }
>>      }
>>    return 0;
>> Index: tree-vectorizer.h
>> ===================================================================
>> --- tree-vectorizer.h   (revision 191208)
>> +++ tree-vectorizer.h   (working copy)
>> @@ -848,9 +848,8 @@ known_alignment_for_access_p (struct data_referenc
>>    return (DR_MISALIGNMENT (data_ref_info) != -1);
>>  }
>>
>> -/* vect_dump will be set to stderr or dump_file if exist.  */
>> -extern FILE *vect_dump;
>> -extern LOC vect_loop_location;
>> +/* Source location */
>> +extern LOC vect_location;
>>
>>  /*-----------------------------------------------------------------*/
>>  /* Function prototypes.                                            */
>> @@ -1012,7 +1011,5 @@ void vect_pattern_recog (loop_vec_info, bb_vec_inf
>>
>>  /* In tree-vectorizer.c.  */
>>  unsigned vectorize_loops (void);
>> -/* Vectorization debug information */
>> -extern bool vect_print_dump_info (enum vect_verbosity_levels);
>>
>>  #endif  /* GCC_TREE_VECTORIZER_H  */
>> Index: profile.c
>> ===================================================================
>> --- profile.c   (revision 191208)
>> +++ profile.c   (working copy)
>> @@ -52,6 +52,7 @@ along with GCC; see the file COPYING3.  If not see
>>  #include "config.h"
>>  #include "system.h"
>>  #include "coretypes.h"
>> +#include "dumpfile.h"
>>  #include "tm.h"
>>  #include "rtl.h"
>>  #include "flags.h"
>> @@ -133,8 +134,8 @@ instrument_edges (struct edge_list *el)
>>           if (!inf->ignore && !inf->on_tree)
>>             {
>>               gcc_assert (!(e->flags & EDGE_ABNORMAL));
>> -             if (dump_file)
>> -               fprintf (dump_file, "Edge %d to %d instrumented%s\n",
>> +             if (dump_kind_p (MSG_NOTE))
>> +               dump_printf (MSG_NOTE, "Edge %d to %d instrumented%s\n",
>>                          e->src->index, e->dest->index,
>>                          EDGE_CRITICAL_P (e) ? " (and split)" : "");
>>               gimple_gen_edge_profiler (num_instr_edges++, e);
>> @@ -143,8 +144,8 @@ instrument_edges (struct edge_list *el)
>>      }
>>
>>    total_num_blocks_created += num_edges;
>> -  if (dump_file)
>> -    fprintf (dump_file, "%d edges instrumented\n", num_instr_edges);
>> +  if (dump_kind_p (MSG_NOTE))
>> +    dump_printf (MSG_NOTE, "%d edges instrumented\n", num_instr_edges);
>>    return num_instr_edges;
>>  }
>>
>> @@ -397,13 +398,13 @@ is_edge_inconsistent (VEC(edge,gc) *edges)
>>               && (!(e->flags & EDGE_FAKE)
>>                   || !block_ends_with_call_p (e->src)))
>>             {
>> -             if (dump_file)
>> +             if (dump_kind_p (MSG_NOTE))
>>                 {
>> -                 fprintf (dump_file,
>> +                 dump_printf (MSG_NOTE,
>>                            "Edge %i->%i is inconsistent, count"HOST_WIDEST_INT_PRINT_DEC,
>>                            e->src->index, e->dest->index, e->count);
>> -                 dump_bb (dump_file, e->src, 0, TDF_DETAILS);
>> -                 dump_bb (dump_file, e->dest, 0, TDF_DETAILS);
>> +                 dump_basic_block (MSG_NOTE, e->src, 0);
>> +                  dump_basic_block (MSG_NOTE, e->dest, 0);
>>                 }
>>                return true;
>>             }
>> @@ -446,40 +447,40 @@ is_inconsistent (void)
>>         return true;
>>        if (bb->count < 0)
>>          {
>> -         if (dump_file)
>> +         if (dump_kind_p (MSG_NOTE))
>>             {
>> -             fprintf (dump_file, "BB %i count is negative "
>> +             dump_printf (MSG_NOTE, "BB %i count is negative "
>>                        HOST_WIDEST_INT_PRINT_DEC,
>>                        bb->index,
>>                        bb->count);
>> -             dump_bb (dump_file, bb, 0, TDF_DETAILS);
>> +             dump_basic_block (MSG_NOTE, bb, 0);
>>             }
>>           inconsistent = true;
>>         }
>>        if (bb->count != sum_edge_counts (bb->preds))
>>          {
>> -         if (dump_file)
>> +         if (dump_kind_p (MSG_NOTE))
>>             {
>> -             fprintf (dump_file, "BB %i count does not match sum of incoming edges "
>> +             dump_printf (MSG_NOTE, "BB %i count does not match sum of
>> incoming edges "
>>                        HOST_WIDEST_INT_PRINT_DEC" should be " HOST_WIDEST_INT_PRINT_DEC,
>>                        bb->index,
>>                        bb->count,
>>                        sum_edge_counts (bb->preds));
>> -             dump_bb (dump_file, bb, 0, TDF_DETAILS);
>> +             dump_basic_block (MSG_NOTE, bb, 0);
>>             }
>>           inconsistent = true;
>>         }
>>        if (bb->count != sum_edge_counts (bb->succs) &&
>>            ! (find_edge (bb, EXIT_BLOCK_PTR) != NULL &&
>> block_ends_with_call_p (bb)))
>>         {
>> -         if (dump_file)
>> +         if (dump_kind_p (MSG_NOTE))
>>             {
>> -             fprintf (dump_file, "BB %i count does not match sum of outgoing edges "
>> +             dump_printf (MSG_NOTE, "BB %i count does not match sum of
>> outgoing edges "
>>                        HOST_WIDEST_INT_PRINT_DEC" should be " HOST_WIDEST_INT_PRINT_DEC,
>>                        bb->index,
>>                        bb->count,
>>                        sum_edge_counts (bb->succs));
>> -             dump_bb (dump_file, bb, 0, TDF_DETAILS);
>> +             dump_basic_block (MSG_NOTE, bb, 0);
>>             }
>>           inconsistent = true;
>>         }
>> @@ -547,11 +548,11 @@ read_profile_edge_counts (gcov_type *exec_counts)
>>             EDGE_INFO (e)->count_valid = 1;
>>             BB_INFO (bb)->succ_count--;
>>             BB_INFO (e->dest)->pred_count--;
>> -           if (dump_file)
>> +           if (dump_kind_p (MSG_NOTE))
>>               {
>> -               fprintf (dump_file, "\nRead edge from %i to %i, count:",
>> +               dump_printf (MSG_NOTE, "\nRead edge from %i to %i, count:",
>>                          bb->index, e->dest->index);
>> -               fprintf (dump_file, HOST_WIDEST_INT_PRINT_DEC,
>> +               dump_printf (MSG_NOTE, HOST_WIDEST_INT_PRINT_DEC,
>>                          (HOST_WIDEST_INT) e->count);
>>               }
>>           }
>> @@ -647,8 +648,8 @@ compute_branch_probabilities (unsigned cfg_checksu
>>
>>    num_edges = read_profile_edge_counts (exec_counts);
>>
>> -  if (dump_file)
>> -    fprintf (dump_file, "\n%d edge counts read\n", num_edges);
>> +  if (dump_kind_p (MSG_NOTE))
>> +    dump_printf (MSG_NOTE, "\n%d edge counts read\n", num_edges);
>>
>>    /* For every block in the file,
>>       - if every exit/entrance edge has a known count, then set the block count
>> @@ -762,18 +763,18 @@ compute_branch_probabilities (unsigned cfg_checksu
>>             }
>>         }
>>      }
>> -  if (dump_file)
>> +  if (dump_kind_p (MSG_NOTE))
>>      {
>>        int overlap = compute_frequency_overlap ();
>>        gimple_dump_cfg (dump_file, dump_flags);
>> -      fprintf (dump_file, "Static profile overlap: %d.%d%%\n",
>> +      dump_printf (MSG_NOTE, "Static profile overlap: %d.%d%%\n",
>>                overlap / (OVERLAP_BASE / 100),
>>                overlap % (OVERLAP_BASE / 100));
>>      }
>>
>>    total_num_passes += passes;
>> -  if (dump_file)
>> -    fprintf (dump_file, "Graph solving took %d passes.\n\n", passes);
>> +  if (dump_kind_p (MSG_NOTE))
>> +    dump_printf (MSG_NOTE, "Graph solving took %d passes.\n\n", passes);
>>
>>    /* If the graph has been correctly solved, every block will have a
>>       succ and pred count of zero.  */
>> @@ -799,8 +800,8 @@ compute_branch_probabilities (unsigned cfg_checksu
>>           correct_negative_edge_counts ();
>>           /* Set bb counts to the sum of the outgoing edge counts */
>>           set_bb_counts ();
>> -         if (dump_file)
>> -           fprintf (dump_file, "\nCalling mcf_smooth_cfg\n");
>> +         if (dump_kind_p (MSG_NOTE))
>> +           dump_printf (MSG_NOTE, "\nCalling mcf_smooth_cfg\n");
>>           mcf_smooth_cfg ();
>>         }
>>       else
>> @@ -912,12 +913,12 @@ compute_branch_probabilities (unsigned cfg_checksu
>>    profile_status = PROFILE_READ;
>>    compute_function_frequency ();
>>
>> -  if (dump_file)
>> +  if (dump_kind_p (MSG_NOTE))
>>      {
>> -      fprintf (dump_file, "%d branches\n", num_branches);
>> +      dump_printf (MSG_NOTE, "%d branches\n", num_branches);
>>        if (num_branches)
>>         for (i = 0; i < 10; i++)
>> -         fprintf (dump_file, "%d%% branches in range %d-%d%%\n",
>> +         dump_printf (MSG_NOTE, "%d%% branches in range %d-%d%%\n",
>>                    (hist_br_prob[i] + hist_br_prob[19-i]) * 100 / num_branches,
>>                    5 * i, 5 * i + 5);
>>
>> @@ -1152,15 +1153,15 @@ branch_prob (void)
>>
>>        if (need_exit_edge && !have_exit_edge)
>>         {
>> -         if (dump_file)
>> -           fprintf (dump_file, "Adding fake exit edge to bb %i\n",
>> +         if (dump_kind_p (MSG_NOTE))
>> +           dump_printf (MSG_NOTE, "Adding fake exit edge to bb %i\n",
>>                      bb->index);
>>           make_edge (bb, EXIT_BLOCK_PTR, EDGE_FAKE);
>>         }
>>        if (need_entry_edge && !have_entry_edge)
>>         {
>> -         if (dump_file)
>> -           fprintf (dump_file, "Adding fake entry edge to bb %i\n",
>> +         if (dump_kind_p (MSG_NOTE))
>> +           dump_printf (MSG_NOTE, "Adding fake entry edge to bb %i\n",
>>                      bb->index);
>>           make_edge (ENTRY_BLOCK_PTR, bb, EDGE_FAKE);
>>           /* Avoid bbs that have both fake entry edge and also some
>> @@ -1192,8 +1193,8 @@ branch_prob (void)
>>                       && (DECL_FUNCTION_CODE (fndecl)
>>                           != BUILT_IN_SETJMP_DISPATCHER)))
>>                 {
>> -                 if (dump_file)
>> -                   fprintf (dump_file, "Splitting bb %i after labels\n",
>> +                 if (dump_kind_p (MSG_NOTE))
>> +                   dump_printf (MSG_NOTE, "Splitting bb %i after labels\n",
>>                              bb->index);
>>                   split_block_after_labels (bb);
>>                 }
>> @@ -1248,20 +1249,20 @@ branch_prob (void)
>>      }
>>
>>    total_num_blocks += n_basic_blocks;
>> -  if (dump_file)
>> -    fprintf (dump_file, "%d basic blocks\n", n_basic_blocks);
>> +  if (dump_kind_p (MSG_NOTE))
>> +    dump_printf (MSG_NOTE, "%d basic blocks\n", n_basic_blocks);
>>
>>    total_num_edges += num_edges;
>> -  if (dump_file)
>> -    fprintf (dump_file, "%d edges\n", num_edges);
>> +  if (dump_kind_p (MSG_NOTE))
>> +    dump_printf (MSG_NOTE, "%d edges\n", num_edges);
>>
>>    total_num_edges_ignored += ignored_edges;
>> -  if (dump_file)
>> -    fprintf (dump_file, "%d ignored edges\n", ignored_edges);
>> +  if (dump_kind_p (MSG_NOTE))
>> +    dump_printf (MSG_NOTE, "%d ignored edges\n", ignored_edges);
>>
>>    total_num_edges_instrumented += num_instrumented;
>> -  if (dump_file)
>> -    fprintf (dump_file, "%d instrumentation edges\n", num_instrumented);
>> +  if (dump_kind_p (MSG_NOTE))
>> +    dump_printf (MSG_NOTE, "%d instrumentation edges\n", num_instrumented);
>>
>>    /* Compute two different checksums. Note that we want to compute
>>       the checksum in only once place, since it depends on the shape
>> @@ -1467,8 +1468,8 @@ find_spanning_tree (struct edge_list *el)
>>           && !EDGE_INFO (e)->ignore
>>           && (find_group (e->src) != find_group (e->dest)))
>>         {
>> -         if (dump_file)
>> -           fprintf (dump_file, "Abnormal edge %d to %d put to tree\n",
>> +         if (dump_kind_p (MSG_NOTE))
>> +           dump_printf (MSG_NOTE, "Abnormal edge %d to %d put to tree\n",
>>                      e->src->index, e->dest->index);
>>           EDGE_INFO (e)->on_tree = 1;
>>           union_groups (e->src, e->dest);
>> @@ -1482,8 +1483,8 @@ find_spanning_tree (struct edge_list *el)
>>        if (EDGE_CRITICAL_P (e) && !EDGE_INFO (e)->ignore
>>           && find_group (e->src) != find_group (e->dest))
>>         {
>> -         if (dump_file)
>> -           fprintf (dump_file, "Critical edge %d to %d put to tree\n",
>> +         if (dump_kind_p (MSG_NOTE))
>> +           dump_printf (MSG_NOTE, "Critical edge %d to %d put to tree\n",
>>                      e->src->index, e->dest->index);
>>           EDGE_INFO (e)->on_tree = 1;
>>           union_groups (e->src, e->dest);
>> @@ -1497,8 +1498,8 @@ find_spanning_tree (struct edge_list *el)
>>        if (!EDGE_INFO (e)->ignore
>>           && find_group (e->src) != find_group (e->dest))
>>         {
>> -         if (dump_file)
>> -           fprintf (dump_file, "Normal edge %d to %d put to tree\n",
>> +         if (dump_kind_p (MSG_NOTE))
>> +           dump_printf (MSG_NOTE, "Normal edge %d to %d
> ...
>
> [Message clipped]


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