tree-pass.h (current_pass): Declare.

2008-05-15  Richard Guenther  <rguenther@suse.de>

	* tree-pass.h (current_pass): Declare.
	(get_pass_for_id): Likewise.
	* passes.c (passes_by_id, passes_by_id_size): New globals.
	(set_pass_for_id): New function.
	(get_pass_for_id): Likewise.
	(register_one_dump_file): Use set_pass_for_id to populate passes_by_id.
	(execute_function_todo): Flush per function statistics.
	* toplev.c (compile_file): Init statistics.
	(general_init): Do early statistics initialization.
	(finalize): Finish statistics.
	* statistics.h (statistics_early_init): Declare.
	(statistics_init): Likewise.
	(statistics_fini): Likewise.
	(statistics_fini_pass): Likewise.
	(statistics_counter_event): Likewise.
	(statistics_histogram_event): Likewise.
	* statistics.c: New file.
	* Makefile.in (OBJS-common): Add statistics.o.
	(statistics.o): Add dependencies.
	* doc/invoke.texi (-fdump-statistics): Document.

	* tree-ssa-pre.c (compute_antic): Use statistics_histogram_event.
	(insert): Likewise.
	(execute_pre): Use statistics_counter_event.
	* tree-ssa-propagate.c (struct prop_stats_d): Add num_dce field.
	(substitute_and_fold): Increment it.  Use statistics_counter_event.

	* gcc.dg/tree-ssa/loadpre7.c: Adjust scan for not performed
	transformation.
	* gcc.dg/tree-ssa/ssa-fre-10.c: Likewise.

From-SVN: r135358
This commit is contained in:
Richard Guenther 2008-05-15 13:39:39 +00:00 committed by Richard Biener
parent 77f377f70e
commit 9fe0cb7d88
12 changed files with 129 additions and 33 deletions

View file

@ -1,3 +1,32 @@
2008-05-15 Richard Guenther <rguenther@suse.de>
* tree-pass.h (current_pass): Declare.
(get_pass_for_id): Likewise.
* passes.c (passes_by_id, passes_by_id_size): New globals.
(set_pass_for_id): New function.
(get_pass_for_id): Likewise.
(register_one_dump_file): Use set_pass_for_id to populate passes_by_id.
(execute_function_todo): Flush per function statistics.
* toplev.c (compile_file): Init statistics.
(general_init): Do early statistics initialization.
(finalize): Finish statistics.
* statistics.h (statistics_early_init): Declare.
(statistics_init): Likewise.
(statistics_fini): Likewise.
(statistics_fini_pass): Likewise.
(statistics_counter_event): Likewise.
(statistics_histogram_event): Likewise.
* statistics.c: New file.
* Makefile.in (OBJS-common): Add statistics.o.
(statistics.o): Add dependencies.
* doc/invoke.texi (-fdump-statistics): Document.
* tree-ssa-pre.c (compute_antic): Use statistics_histogram_event.
(insert): Likewise.
(execute_pre): Use statistics_counter_event.
* tree-ssa-propagate.c (struct prop_stats_d): Add num_dce field.
(substitute_and_fold): Increment it. Use statistics_counter_event.
2008-05-15 Diego Novillo <dnovillo@google.com>
http://gcc.gnu.org/ml/gcc-patches/2008-05/msg00893.html

View file

@ -1131,6 +1131,7 @@ OBJS-common = \
sparseset.o \
sreal.o \
stack-ptr-mod.o \
statistics.o \
stmt.o \
stor-layout.o \
stringpool.o \
@ -2396,6 +2397,8 @@ function.o : function.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) \
output.h toplev.h except.h $(HASHTAB_H) $(GGC_H) $(TM_P_H) langhooks.h \
gt-function.h $(TARGET_H) $(BASIC_BLOCK_H) $(INTEGRATE_H) $(PREDICT_H) \
tree-pass.h $(DF_H) timevar.h vecprim.h
statistics.o : statistics.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
$(FLAGS_H) $(FUNCTION_H) $(HASHTAB_H) $(TREE_DUMP_H) tree-pass.h
stmt.o : stmt.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) \
$(TREE_H) $(FLAGS_H) $(FUNCTION_H) insn-config.h hard-reg-set.h $(EXPR_H) \
libfuncs.h except.h $(RECOG_H) toplev.h output.h $(GGC_H) $(TM_P_H) \

View file

@ -276,6 +276,7 @@ Objective-C and Objective-C++ Dialects}.
-fdump-noaddr -fdump-unnumbered -fdump-translation-unit@r{[}-@var{n}@r{]} @gol
-fdump-class-hierarchy@r{[}-@var{n}@r{]} @gol
-fdump-ipa-all -fdump-ipa-cgraph -fdump-ipa-inline @gol
-fdump-statistics @gol
-fdump-tree-all @gol
-fdump-tree-original@r{[}-@var{n}@r{]} @gol
-fdump-tree-optimized@r{[}-@var{n}@r{]} @gol
@ -4724,6 +4725,15 @@ Dump after function inlining.
@end table
@item -fdump-statistics-@var{option}
@opindex -fdump-statistics
Enable and control dumping of pass statistics in a separate file. The
file name is generated by appending a suffix ending in @samp{.statistics}
to the source file name. If the @samp{-@var{option}} form is used,
@samp{-stats} will cause counters to be summed over the whole compilation unit
while @samp{-details} will dump every event as the passes generate them.
The default with no option is to sum counters for each function compiled.
@item -fdump-tree-@var{switch}
@itemx -fdump-tree-@var{switch}-@var{options}
@opindex fdump-tree

View file

@ -333,6 +333,37 @@ struct rtl_opt_pass pass_postreload =
/* The root of the compilation pass tree, once constructed. */
struct opt_pass *all_passes, *all_ipa_passes, *all_lowering_passes;
/* A map from static pass id to optimization pass. */
struct opt_pass **passes_by_id;
int passes_by_id_size;
/* Set the static pass number of pass PASS to ID and record that
in the mapping from static pass number to pass. */
static void
set_pass_for_id (int id, struct opt_pass *pass)
{
pass->static_pass_number = id;
if (passes_by_id_size <= id)
{
passes_by_id = xrealloc (passes_by_id, (id + 1) * sizeof (void *));
memset (passes_by_id + passes_by_id_size, 0,
(id + 1 - passes_by_id_size) * sizeof (void *));
passes_by_id_size = id + 1;
}
passes_by_id[id] = pass;
}
/* Return the pass with the static pass number ID. */
struct opt_pass *
get_pass_for_id (int id)
{
if (id >= passes_by_id_size)
return NULL;
return passes_by_id[id];
}
/* Iterate over the pass tree allocating dump file numbers. We want
to do this depth first, and independent of whether the pass is
enabled or not. */
@ -343,7 +374,7 @@ register_one_dump_file (struct opt_pass *pass)
char *dot_name, *flag_name, *glob_name;
const char *prefix;
char num[10];
int flags;
int flags, id;
/* See below in next_pass_1. */
num[0] = '\0';
@ -361,8 +392,8 @@ register_one_dump_file (struct opt_pass *pass)
flag_name = concat (prefix, pass->name, num, NULL);
glob_name = concat (prefix, pass->name, NULL);
pass->static_pass_number = dump_register (dot_name, flag_name, glob_name,
flags);
id = dump_register (dot_name, flag_name, glob_name, flags);
set_pass_for_id (id, pass);
}
/* Recursive worker function for register_dump_files. */
@ -883,7 +914,9 @@ execute_function_todo (void *data)
flags &= ~cfun->last_verified;
if (!flags)
return;
statistics_fini_pass ();
/* Always cleanup the CFG before trying to update SSA. */
if (flags & TODO_cleanup_cfg)
{
@ -1346,4 +1379,5 @@ execute_ipa_pass_list (struct opt_pass *pass)
}
while (pass);
}
#include "gt-passes.h"

View file

@ -1,5 +1,5 @@
/* Memory statistics helpers.
Copyright (C) 2004, 2007
/* Memory and optimization statistics helpers.
Copyright (C) 2004, 2007, 2008
Free Software Foundation, Inc.
Contributed by Cygnus Solutions.
@ -21,6 +21,7 @@
#ifndef GCC_STATISTICS
#define GCC_STATISTICS
#ifdef GATHER_STATISTICS
#define MEM_STAT_DECL , const char * ARG_UNUSED (_loc_name), int ARG_UNUSED (_loc_line), const char * ARG_UNUSED (_loc_function)
#define ALONE_MEM_STAT_DECL const char * ARG_UNUSED (_loc_name), int ARG_UNUSED (_loc_line), const char * ARG_UNUSED (_loc_function)
@ -36,4 +37,15 @@
#define MEM_STAT_INFO
#define ALONE_MEM_STAT_INFO
#endif
struct function;
/* In statistics.c */
extern void statistics_early_init (void);
extern void statistics_init (void);
extern void statistics_fini (void);
extern void statistics_fini_pass (void);
extern void statistics_counter_event (struct function *, const char *, int);
extern void statistics_histogram_event (struct function *, const char *, int);
#endif

View file

@ -1,3 +1,9 @@
2008-05-15 Richard Guenther <rguenther@suse.de>
* gcc.dg/tree-ssa/loadpre7.c: Adjust scan for not performed
transformation.
* gcc.dg/tree-ssa/ssa-fre-10.c: Likewise.
2008-05-15 Richard Guenther <rguenther@suse.de>
PR middle-end/36244

View file

@ -13,5 +13,5 @@ enormlz (x)
eshup8 (x);
}
}
/* { dg-final { scan-tree-dump-times "Eliminated: 0" 1 "pre"} } */
/* { dg-final { scan-tree-dump-not "Eliminated:" "pre"} } */
/* { dg-final { cleanup-tree-dump "pre" } } */

View file

@ -16,5 +16,5 @@ void __frame_state_for (volatile char *state_in, int x)
}
}
/* { dg-final { scan-tree-dump "Insertions: 0" "pre" } } */
/* { dg-final { scan-tree-dump-not "Insertions:" "pre" } } */
/* { dg-final { cleanup-tree-dump "pre" } } */

View file

@ -954,6 +954,7 @@ compile_file (void)
init_cgraph ();
init_final (main_input_filename);
coverage_init (aux_base_name);
statistics_init ();
timevar_push (TV_PARSE);
@ -1598,6 +1599,7 @@ general_init (const char *argv0)
/* This must be done after add_params but before argument processing. */
init_ggc_heuristics();
init_optimization_passes ();
statistics_early_init ();
}
/* Return true if the current target supports -fsection-anchors. */
@ -2118,6 +2120,7 @@ finalize (void)
fatal_error ("error closing %s: %m", asm_file_name);
}
statistics_fini ();
finish_optimization_passes ();
if (mem_report)

View file

@ -508,6 +508,10 @@ extern struct gimple_opt_pass pass_update_address_taken;
/* The root of the compilation pass tree, once constructed. */
extern struct opt_pass *all_passes, *all_ipa_passes, *all_lowering_passes;
/* Current optimization pass. */
extern struct opt_pass *current_pass;
extern struct opt_pass * get_pass_for_id (int);
extern void execute_pass_list (struct opt_pass *);
extern void execute_ipa_pass_list (struct opt_pass *);
extern void print_current_pass (FILE *);

View file

@ -2031,9 +2031,8 @@ compute_antic (void)
gcc_assert (num_iterations < 50);
}
if (dump_file && (dump_flags & TDF_STATS))
fprintf (dump_file, "compute_antic required %d iterations\n",
num_iterations);
statistics_histogram_event (cfun, "compute_antic iterations",
num_iterations);
if (do_partial_partial)
{
@ -2061,9 +2060,8 @@ compute_antic (void)
/* Theoretically possible, but *highly* unlikely. */
gcc_assert (num_iterations < 50);
}
if (dump_file && (dump_flags & TDF_STATS))
fprintf (dump_file, "compute_partial_antic required %d iterations\n",
num_iterations);
statistics_histogram_event (cfun, "compute_partial_antic iterations",
num_iterations);
}
sbitmap_free (has_abnormal_preds);
sbitmap_free (changed_blocks);
@ -2936,8 +2934,7 @@ insert (void)
new_stuff = false;
new_stuff = insert_aux (ENTRY_BLOCK_PTR);
}
if (num_iterations > 2 && dump_file && (dump_flags & TDF_STATS))
fprintf (dump_file, "insert required %d iterations\n", num_iterations);
statistics_histogram_event (cfun, "insert iterations", num_iterations);
}
@ -4019,14 +4016,11 @@ execute_pre (bool do_fre)
/* Remove all the redundant expressions. */
todo |= eliminate ();
if (dump_file && (dump_flags & TDF_STATS))
{
fprintf (dump_file, "Insertions: %d\n", pre_stats.insertions);
fprintf (dump_file, "PA inserted: %d\n", pre_stats.pa_insert);
fprintf (dump_file, "New PHIs: %d\n", pre_stats.phis);
fprintf (dump_file, "Eliminated: %d\n", pre_stats.eliminations);
fprintf (dump_file, "Constified: %d\n", pre_stats.constified);
}
statistics_counter_event (cfun, "Insertions", pre_stats.insertions);
statistics_counter_event (cfun, "PA inserted", pre_stats.pa_insert);
statistics_counter_event (cfun, "New PHIs", pre_stats.phis);
statistics_counter_event (cfun, "Eliminated", pre_stats.eliminations);
statistics_counter_event (cfun, "Constified", pre_stats.constified);
bsi_commit_edge_inserts ();
clear_expression_ids ();

View file

@ -890,6 +890,7 @@ struct prop_stats_d
long num_const_prop;
long num_copy_prop;
long num_pred_folded;
long num_dce;
};
static struct prop_stats_d prop_stats;
@ -1255,6 +1256,7 @@ substitute_and_fold (prop_value_t *prop_value, bool use_ranges_p)
print_generic_expr (dump_file, stmt, 0);
fprintf (dump_file, "\n");
}
prop_stats.num_dce++;
bsi_remove (&i, true);
release_defs (stmt);
if (!bsi_end_p (i))
@ -1341,15 +1343,14 @@ substitute_and_fold (prop_value_t *prop_value, bool use_ranges_p)
}
}
if (dump_file && (dump_flags & TDF_STATS))
{
fprintf (dump_file, "Constants propagated: %6ld\n",
prop_stats.num_const_prop);
fprintf (dump_file, "Copies propagated: %6ld\n",
prop_stats.num_copy_prop);
fprintf (dump_file, "Predicates folded: %6ld\n",
prop_stats.num_pred_folded);
}
statistics_counter_event (cfun, "Constants propagated",
prop_stats.num_const_prop);
statistics_counter_event (cfun, "Copies propagated",
prop_stats.num_copy_prop);
statistics_counter_event (cfun, "Predicates folded",
prop_stats.num_pred_folded);
statistics_counter_event (cfun, "Statements deleted",
prop_stats.num_dce);
return something_changed;
}