]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
tree-pass.h (current_pass): Declare.
authorRichard Guenther <rguenther@suse.de>
Thu, 15 May 2008 13:39:39 +0000 (13:39 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Thu, 15 May 2008 13:39:39 +0000 (13:39 +0000)
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

12 files changed:
gcc/ChangeLog
gcc/Makefile.in
gcc/doc/invoke.texi
gcc/passes.c
gcc/statistics.h
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/tree-ssa/loadpre7.c
gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-10.c
gcc/toplev.c
gcc/tree-pass.h
gcc/tree-ssa-pre.c
gcc/tree-ssa-propagate.c

index b62ea6bc4c83418ff3ec6eacd92aeb273868ff19..cae0c9c58c414b18d2761ff60e5e1d8d77130b74 100644 (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
index f981b1eef5e2ff0ddb1504d092fde1123c1d9e00..99d16a21b9b0996aa3a28155be0cd3073ec7468b 100644 (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) \
index a7704a08323bf6716e572af1084e8df200333ebd..50b5c55ec80b786dc6c4ac37613810ca598461e4 100644 (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
index bd8392646f2a7bf57edf26f79a94ed665166f47c..ede2cd9c5f8808d34646ed1e8efcebaa1e0033de 100644 (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"
index 585240178a1ec17206df6196d6464fbbaf95a14a..6e21e8557974261e2751a371470edb13e852b588 100644 (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)
 #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
index 56493e03fdde82bc139c2186340aa54c3d893a5e..c2af14e25bd245e7fbd955fc8f066e5394df9f5b 100644 (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
index 7cd6838c6ab396b73b15529e1d88b4c7941cfd50..6f68f3ae212b440740e06c2439e7f4598fff6389 100644 (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" } } */
index 0e59df53ee12d2f00e72e7ae7e576478044d4b51..cfbb9c97b163040e1b3e0d2b974ab0310c3d4dfc 100644 (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" } } */
index 65eb550777b9995c46d64e16d1476c07f771fba7..3a2590ade83eba3019c360a8957ed1481e73264b 100644 (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)
index c18c412b9784cf30e266edd6b8eb5e906c7dae1a..b1ac95f52c2573ea4bee392c3a3a62fed1a94785 100644 (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 *);
index a8db47dc06dbca2326f792c18275cbe5a3ee1260..4119467964322d4c373cea79330f3a9a238c289b 100644 (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 ();
index 6423ec6ba524b979143ff19bd95082eae0baa876..1b40bf095ed5b425a22a8177bd1a815af613f825 100644 (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;
 }