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]

[patch] Reorganization of dump flags


Hello,

gcc currently provides only a fairly limited control over the
information contained in the dump files.  For example, if I am
interested in why ivopts decided to perform some optimization, I will
use -fdump-tree-ivopts-details.  However, in addition to the information
generated by ivopts, most of the resulting dump file consists of
(usually irrelevant) scev analysis reports, making it difficult to
find the interesting information.

Additionally, there is no way how to select the verbosity of the
information; perhaps I am only interested in the most important
information (what transformations were performed), but not the low-level
details; there is no way how to select that -- except for pass-specific
options (ftree-vectorizer-verbose and fsched-verbose); I believe
we do not want to have a separate option for each pass.

This patch implements the following scheme to overcome this problem:

Each piece of information that is printed to a dump file is tagged
with an identifier specifying what kind of information is that
(I will call these identifiers "dump keywords"), and with the importance
of the information.  For example, if I want to write something of medium
importance regarding the scev analysis, I would use

if (dump_file && should_dump_p (DKWD_scev, DI_MEDIUM))
  fprintf (dump_file, "something");

Whether or not the information corresponding to a given dump keyword
will be shown may be specified by an option, e.g., if I would like to
see just scev-related information of medium importance or higher, I
would use

-fdump-tree-all-scev/2

(the importance levels are 0 -- do not dump anything up to 3 -- dump
everything; when the level is not specified, it is taken to be 3).

Additionally, there are some options that do not specify what
information will be dumped, but affect its formating (TDF_BLOCKS,
TDF_VOPS, TDF_STMTADDR and such).  We do not use keywords for these, but
instead we just keep their bitmap as we do now (so they do not have the
four levels, they can be just on or off) -- I will call these "dump
qualifiers". This makes it possible to use the qualifiers in the same
way as it is done now, pass their sets as function arguments, alter it
locally, etc.  The dump flags that are only used internally (TDF_TREE,
TDF_RTL, ...) are handled the same way, except that we do not assign any
option for setting them.

Finally, for convenience we also allow grouping several keywords or
qualifiers to a single option -- defining "dump group" options like
-fdump-tree-somepass-all (the -details option becomes a group, as well)
that activate several different keywords.

So for example, if I want to see all the details from ivopts except for
the scalar evolutions information, I may use
-fdump-tree-ivopts-details-scev/0

All the dump keywords, qualifiers and groups are defined in
dump-flags.def file, so it is easy to add/remove them as necessary.

The patch below basically just introduces this mechanism, without trying
overly hard to to classify the dump information (I have added scev and
data dependence keywords, as these were easy to do and annoy me the most
in the dumps I use, but I put mostly everything else that used to be
in TDF_DETAILS under "optimization" keyword with medium importance).
The followup would be the replacement of ftree-vectorizer-verbose and
fsched-verbose options, and possibly the refinement of the importance
levels in other passes.

I defined the keywords and groups so that the patch implements a
conservative extension of the current state; i.e., all
-fdump-tree-somepass-something options should work exactly as they do
now.

The patch was bootstrapped & regtested on i686.  Now, strictly said,
we are in stage 3 and the patch does not fix any bug, so it should not
be admitted.  On the other hand, it should be fairly safe (it only
affects dump files, after all), and I do not like the idea of maintaining
15000 lines patch for next few months before we reach the next stage1
too much (even though fixing any collisions created through that time
should be fairly straightforward).  

Zdenek

	everywhere: Replace testing of TDF_ flags with should_dump_p calls.
	Use DQUAL_ instead of TDF_ constants.
	* dump-flags.def: New file.
	* tree-dump.c (struct dump_option_list, struct dump_option): New types.
	(actual_dump_options, default_dump_options, default_dump_flags,
	dump_options, dump_option_name_to_code): New variables.
	(dump_files): Add initializer for dump_options field.
	(dump_option_hash, dump_option_eq, find_dump_option,
	initialize_dump_keyword, initialize_dump_qualifier,
	initialize_dump_group, create_dump_option_list, dump_options_init,
	set_dump_keyword_levels, reset_dump_keyword_levels, dump_qualifiers,
	dfi_enable, dump_option_list_copy, dump_option_list_free): New
	functions.
	(struct dump_option_value_info, dump_options): Removed.
	(dump_register): Set dump_options and dump_qualifiers fields.
	(get_dump_file_name): Use DQUAL_ instead of TDF_ constants.
	(dump_begin): Set keyword levels according to the specified pass
	options.
	(dump_end): Set keyword levels to defaults.
	(dump_enable_all): Use dfi_enable.
	(dump_switch_p_1): Record options and required values for the passes.
	(dump_function): Pass extra arguments to dump_begin and
	dump_function_to_file.
	(enable_rtl_dump_file): Pass proper arguments to dump_enable_all.
	* tree-dump.h (enum dump_flag_code, enum dump_qualifier_masks,
	enum dump_importance): New enums.
	(dump_flags, actual_dump_options, dump_qualifiers): Declare.
	(should_dump_p): New inline function.
	(dump_function_to_file, dump_register): Declaration changed.
	* tree-pass.h (TDF_ADDRESS, TDF_SLIM, TDF_RAW, TDF_DETAILS,
	TDF_STATS, TDF_BLOCKS, TDF_VOPS, TDF_LINENO, TDF_UID, TDF_TREE,
	TDF_RTL, TDF_IPA, TDF_STMTADDR, TDF_GRAPH, TDF_MEMSYMS,
	TDF_DIAGNOSTIC): Removed.
	(dump_begin, dump_flags): Declaration changed.
	(struct dump_file_info): Replace flags field by dump_options and
	dump_qualifiers fields.
	* toplev.c (toplev_main): Call dump_options_init.
	* toplev.h (dump_options_init): Declare.
	* tree-flow.h (dump_tree_cfg): Declaration changed.
	* Makefile.in (TREE_DUMP_H): Add dump-flags.def.
	(tree-ssa-structalias.o, tree-ssa-operands.o, tree-predcom.o,
	omp-low.o, omega.o, tree-chrec.o, tree-parloops.o, tree-stdarg.o,
	tree-object-size.o, tree-pretty-print.o, toplev.o, ipa-cp.o,
	var-tracking.o, value-prof.o, cfg.o, combine.o, local-alloc.o,
	sched-vis.o): Add TREE_DUMP_H dependency.
	* passes.c (dump_flags): Removed.
	(finish_optimization_passes): Pass false to dump_begin.
	(register_one_dump_file, execute_function_todo): Use DQUAL_ flags.
	(execute_one_pass): Pass true to dump_begin.

Attachment: diff_dumpreorg.diff.gz
Description: Binary data


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