+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
sparseset.o \
sreal.o \
stack-ptr-mod.o \
+ statistics.o \
stmt.o \
stor-layout.o \
stringpool.o \
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) \
-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
@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
/* 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. */
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';
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. */
flags &= ~cfun->last_verified;
if (!flags)
return;
-
+
+ statistics_fini_pass ();
+
/* Always cleanup the CFG before trying to update SSA. */
if (flags & TODO_cleanup_cfg)
{
}
while (pass);
}
+
#include "gt-passes.h"
-/* 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.
#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)
#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
+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
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" } } */
}
}
-/* { dg-final { scan-tree-dump "Insertions: 0" "pre" } } */
+/* { dg-final { scan-tree-dump-not "Insertions:" "pre" } } */
/* { dg-final { cleanup-tree-dump "pre" } } */
init_cgraph ();
init_final (main_input_filename);
coverage_init (aux_base_name);
+ statistics_init ();
timevar_push (TV_PARSE);
/* 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. */
fatal_error ("error closing %s: %m", asm_file_name);
}
+ statistics_fini ();
finish_optimization_passes ();
if (mem_report)
/* 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 *);
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)
{
/* 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);
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);
}
/* 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 ();
long num_const_prop;
long num_copy_prop;
long num_pred_folded;
+ long num_dce;
};
static struct prop_stats_d prop_stats;
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))
}
}
- 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;
}