Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(699)

Issue 5933044: [pph] Add stats on PPH processing

Can't Edit
Can't Publish+Mail
Start Review
Created:
12 years, 1 month ago by Diego Novillo
Modified:
12 years, 1 month ago
Reviewers:
CC:
Lawrence Crowl, gcc-patches_gcc.gnu.org
Visibility:
Public.

Patch Set 1 #

Unified diffs Side-by-side diffs Delta from patch set Stats (+220 lines, -62 lines) Patch
M gcc/c-family/ChangeLog.pph View 1 chunk +4 lines, -0 lines 0 comments Download
M gcc/c-family/c.opt View 1 chunk +4 lines, -0 lines 0 comments Download
M gcc/cp/ChangeLog.pph View 1 chunk +16 lines, -0 lines 0 comments Download
M gcc/cp/Make-lang.in View 1 chunk +1 line, -1 line 0 comments Download
M gcc/cp/pph.h View 4 chunks +38 lines, -4 lines 0 comments Download
M gcc/cp/pph-core.c View 5 chunks +85 lines, -0 lines 0 comments Download
M gcc/cp/pph-in.c View 14 chunks +23 lines, -16 lines 0 comments Download
M gcc/cp/pph-out.c View 15 chunks +26 lines, -17 lines 0 comments Download
M gcc/cp/pt.c View 7 chunks +8 lines, -8 lines 0 comments Download
M gcc/timevar.def View 1 chunk +15 lines, -16 lines 0 comments Download

Messages

Total messages: 1
Diego Novillo
12 years, 1 month ago (2012-03-27 17:01:24 UTC) #1
Adds a new flag -fpph-statistics.  When used, it shows various collected
stats at the end of PPH processing.

2012-03-27   Diego Novillo  <dnovillo@google.com>

c-family/ChangeLog.pph
	* c.opt (fpph-stats): Add flag.

cp/ChangeLog.pph
	* pph-core.c (pph_stats): Declare.
	(pph_init): Initialize.
	(pph_cache_lookup): Update pph_stats.cache_lookups and
	pph_stats.cache_hits.
	(pph_dump_stats): New.
	(pph_streamer_finish): Call it.
	* pph-in.c (pph_in_record_marker): Update
	pph_stats.num_records_by_marker and
	pph_stats.num_records_by_tag.
	* pph.h (enum pph_record_marker): Add value
	PPH_NUM_RECORD_MARKERS.
	(struct pph_stats_s): Declare.
	(pph_stats_t): Declare.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/pph@185886
138bc75d-0d04-0410-961f-82ee72b054a4
---
 gcc/c-family/ChangeLog.pph |    4 ++
 gcc/c-family/c.opt         |    4 ++
 gcc/cp/ChangeLog.pph       |   16 ++++++++
 gcc/cp/Make-lang.in        |    2 +-
 gcc/cp/pph-core.c          |   85 ++++++++++++++++++++++++++++++++++++++++++++
 gcc/cp/pph-in.c            |   39 ++++++++++++--------
 gcc/cp/pph-out.c           |   43 +++++++++++++---------
 gcc/cp/pph.h               |   42 +++++++++++++++++++--
 gcc/cp/pt.c                |   16 ++++----
 gcc/timevar.def            |   30 ++++++++--------
 10 files changed, 220 insertions(+), 61 deletions(-)

diff --git a/gcc/c-family/ChangeLog.pph b/gcc/c-family/ChangeLog.pph
index eb99f26..4d26a36 100644
--- a/gcc/c-family/ChangeLog.pph
+++ b/gcc/c-family/ChangeLog.pph
@@ -1,3 +1,7 @@
+2012-03-27   Diego Novillo  <dnovillo@google.com>
+
+	* c.opt (fpph-stats): Add flag.
+
 2012-03-15   Lawrence Crowl  <crowl@google.com>
 
 	* c.opt (-fpph-check): New.
diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt
index 10a3150..e4eb696 100644
--- a/gcc/c-family/c.opt
+++ b/gcc/c-family/c.opt
@@ -1013,6 +1013,10 @@ fpph-include-tree
 C++ Var(flag_pph_include_tree)
 -fpph-include-tree	Print the include tree for the current TU to stderr
 
+fpph-stats
+C++ Var(flag_pph_stats)
+-fpph-stats	Print statistics on PPH data structures
+
 fpph-tracer=
 C++ Joined RejectNegative UInteger Var(flag_pph_tracer)
 -fpph-tracer	Enable tracing of PPH streaming operations
diff --git a/gcc/cp/ChangeLog.pph b/gcc/cp/ChangeLog.pph
index 3f6f5bb..f1b23f8 100644
--- a/gcc/cp/ChangeLog.pph
+++ b/gcc/cp/ChangeLog.pph
@@ -1,3 +1,19 @@
+2012-03-27   Diego Novillo  <dnovillo@google.com>
+
+	* pph-core.c (pph_stats): Declare.
+	(pph_init): Initialize.
+	(pph_cache_lookup): Update pph_stats.cache_lookups and
+	pph_stats.cache_hits.
+	(pph_dump_stats): New.
+	(pph_streamer_finish): Call it.
+	* pph-in.c (pph_in_record_marker): Update
+	pph_stats.num_records_by_marker and
+	pph_stats.num_records_by_tag.
+	* pph.h (enum pph_record_marker): Add value
+	PPH_NUM_RECORD_MARKERS.
+	(struct pph_stats_s): Declare.
+	(pph_stats_t): Declare.
+
 2012-03-26   Diego Novillo  <dnovillo@google.com>
 
 	* pph-core.c (pph_include_handler): Use timer TV_PPH.
diff --git a/gcc/cp/Make-lang.in b/gcc/cp/Make-lang.in
index 78328f9..426c3b8 100644
--- a/gcc/cp/Make-lang.in
+++ b/gcc/cp/Make-lang.in
@@ -353,6 +353,6 @@ cp/cxx-pretty-print.o: cp/cxx-pretty-print.c
$(CXX_PRETTY_PRINT_H) \
   $(CONFIG_H) $(SYSTEM_H) $(TM_H) coretypes.h $(CXX_TREE_H) tree-pretty-print.h
 cp/pph-core.o: cp/pph-core.c $(CXX_PPH_COMMON_H) $(CPPLIB_H) $(TIMEVAR_H) \
 	$(TREE_INLINE_H) tree-pretty-print.h fixed-value.h pointer-set.h \
-        toplev.h
+        toplev.h $(TIMEVAR_H)
 cp/pph-out.o: cp/pph-out.c $(CXX_PPH_COMMON_H) $(CGRAPH_H)
 cp/pph-in.o: cp/pph-in.c $(CXX_PPH_COMMON_H) pointer-set.h toplev.h
diff --git a/gcc/cp/pph-core.c b/gcc/cp/pph-core.c
index 2a16f86..f16675c 100644
--- a/gcc/cp/pph-core.c
+++ b/gcc/cp/pph-core.c
@@ -48,7 +48,10 @@ along with GCC; see the file COPYING3.  If not see
 #include "version.h"
 #include "cppbuiltin.h"
 #include "streamer-hooks.h"
+#include "timevar.h"
 
+/* PPH statistics.  */
+pph_stats_t pph_stats;
 
 /* Mapping between a name string and the registry index for the
    corresponding PPH image.  */
@@ -690,6 +693,8 @@ pph_cache_lookup (pph_cache *cache, void *data, unsigned
*ix_p,
   unsigned ix;
   pph_cache_entry *e;
 
+  pph_stats.cache_lookups++;
+
   if (cache == NULL)
     cache = pph_preloaded_cache;
 
@@ -710,6 +715,8 @@ pph_cache_lookup (pph_cache *cache, void *data, unsigned
*ix_p,
          it matches the tag we pulled from the cache.  */
       if (tag != PPH_null)
 	gcc_assert (tag == e->tag);
+
+      pph_stats.cache_hits++;
     }
 
   if (ix_p)
@@ -1517,12 +1524,86 @@ pph_init (void)
 
   pph_reader_init ();
 
+  /* Initialize statistics collection.  */
+  memset (&pph_stats, 0, sizeof (pph_stats));
+
   timevar_stop (TV_PPH);
 }
 
 
 /********************************************************** pph finalization */
 
+#define PERCENT(x,y) ((float)(x) * 100.0 / (float)(y))
+
+static const char *replay_strings[] = {
+  "PPH_REPLAY_DECLARE",
+  "PPH_REPLAY_EXPAND",
+  "PPH_REPLAY_EXPAND_1",
+  "PPH_REPLAY_FINISH_STRUCT_METHODS"
+};
+
+
+/* Dump statistics from PPH processing on F.  */
+
+static void
+pph_dump_stats (FILE *f)
+{
+  size_t i;
+
+  if (f == NULL)
+    f = stderr;
+
+  fprintf (f, "\nPPH statistics\n");
+
+  fprintf (f, "\nRecords by type\n");
+  for (i = (size_t) PPH_RECORD_START; i < (size_t) PPH_NUM_RECORD_MARKERS; i++)
+    if (pph_stats.num_records_by_marker[i])
+      fprintf (f, "%40s: %10lu (%6.2f%%)\n",
+	       marker_strings[i],
+	       pph_stats.num_records_by_marker[i],
+	       PERCENT (pph_stats.num_records_by_marker[i],
+		        pph_stats.num_records));
+  fprintf (f, "%40s: %10lu (100.00%%)\n", "TOTAL", pph_stats.num_records);
+
+  fprintf (f, "\nRecords by tag\n");
+  for (i = (size_t) PPH_null; i < (size_t) PPH_NUM_TAGS; i++)
+    if (pph_stats.num_records_by_tag[i])
+      {
+	const char *name;
+	if (i == (size_t) PPH_null)
+	  name = "PPH_null";
+	else if (i < (size_t) MAX_TREE_CODES)
+	  name = tree_code_name[i];
+	else
+	  name = tag_strings[i - (size_t) PPH_any_tree];
+	fprintf (f, "%40s: %10lu (%6.2f%%)\n",
+		 name,
+		 pph_stats.num_records_by_tag[i],
+		 PERCENT (pph_stats.num_records_by_tag[i],
+		          pph_stats.num_records));
+      }
+  fprintf (f, "%40s: %10lu (100.00%%)\n", "TOTAL", pph_stats.num_records);
+
+  fprintf (f, "\nReplay table\n");
+  for (i = (size_t) PPH_REPLAY_DECLARE; i < PPH_NUM_REPLAY_ACTIONS; i++)
+    if (pph_stats.num_replay_actions_by_action[i])
+      fprintf (f, "%40s: %10lu (%6.2f%%)\n",
+	       replay_strings[i],
+	       pph_stats.num_replay_actions_by_action[i],
+	       PERCENT (pph_stats.num_replay_actions_by_action[i],
+		        pph_stats.num_replay_actions));
+  fprintf (f, "%40s: %10lu (100.00%%)\n", "TOTAL",
+	   pph_stats.num_replay_actions);
+
+  fprintf (f, "\n");
+  fprintf (f, "Cache lookups: %10lu\n", pph_stats.cache_lookups);
+  fprintf (f, "Cache hits:    %10lu (%5.2f%%)\n", pph_stats.cache_hits,
+	   PERCENT (pph_stats.cache_hits, pph_stats.cache_lookups));
+
+  fprintf (f, "\n");
+  timevar_print (f);
+}
+
 
 /* Finalize the streamer.  */
 
@@ -1552,6 +1633,10 @@ pph_streamer_finish (void)
   /* Get rid of all the dead trees we may have had in caches.  */
   pph_cached_trees = NULL;
   ggc_collect ();
+
+  /* If the user requested statistics, show them.  */
+  if (flag_pph_stats)
+    pph_dump_stats (stderr);
 }
 
 
diff --git a/gcc/cp/pph-in.c b/gcc/cp/pph-in.c
index 445e4b6..d50581e 100644
--- a/gcc/cp/pph-in.c
+++ b/gcc/cp/pph-in.c
@@ -353,7 +353,7 @@ pph_in_line_table_and_includes (pph_stream *stream)
   enum pph_linetable_marker next_lt_marker;
   int top_includer_ix;
 
-  timevar_start (TV_PPH_RESTORE_LINE_TABLE);
+  timevar_start (TV_PPH_IN_LINE_TABLE);
 
   used_before = LINEMAPS_ORDINARY_USED (line_table);
   first = true;
@@ -462,7 +462,7 @@ pph_in_line_table_and_includes (pph_stream *stream)
   linemap_add (line_table, LC_LEAVE, 0, NULL, 0);
   gcc_assert (line_table->depth == old_depth);
 
-  timevar_stop (TV_PPH_RESTORE_LINE_TABLE);
+  timevar_stop (TV_PPH_IN_LINE_TABLE);
 
   return MAP_START_LOCATION (LINEMAPS_ORDINARY_MAP_AT (line_table,
used_before));
 }
@@ -504,6 +504,10 @@ pph_in_record_marker (pph_stream *stream, enum pph_tag
*tag_p)
   if (flag_pph_tracer >= 5)
     pph_trace_marker (m, *tag_p);
 
+  pph_stats.num_records_by_marker[m]++;
+  pph_stats.num_records_by_tag[*tag_p]++;
+  pph_stats.num_records++;
+
   return m;
 }
 
@@ -2536,8 +2540,6 @@ pph_in_merge_body_namespace_decl (pph_stream *stream)
   if (flag_pph_tracer)
     pph_trace_tree (decl, "?", pph_trace_front, pph_trace_merge_body);
 
-  gcc_assert (DECL_NAME (decl));
-
   /* If EXPR is a namespace alias, we do not need to merge
      its binding level (namespaces aliases do not have a
      binding level, they use the one from the namespace they
@@ -2887,7 +2889,7 @@ pph_in_replay (pph_stream *stream)
 {
   unsigned i, num;
 
-  timevar_start (TV_PPH_RESTORE_REPLAY);
+  timevar_start (TV_PPH_IN_REPLAY);
 
   /* Register all the symbols in STREAM in the same order of the
      original compilation for this header file.  */
@@ -2979,9 +2981,14 @@ pph_in_replay (pph_stream *stream)
 	}
       else
 	gcc_unreachable ();
+
+      pph_stats.num_replay_actions_by_action[entry.action]++;
     }
 
-  timevar_stop (TV_PPH_RESTORE_REPLAY);
+
+  pph_stats.num_replay_actions = num;
+
+  timevar_stop (TV_PPH_IN_REPLAY);
 }
 
 
@@ -3036,7 +3043,7 @@ pph_in_identifiers (pph_stream *stream, cpp_idents_used
*identifiers)
   unsigned int max_ident_len, max_value_len, num_entries;
   unsigned int ident_len, before_len, after_len;
 
-  timevar_start (TV_PPH_RESTORE_IDENTIFIERS);
+  timevar_start (TV_PPH_IN_IDENTIFIERS);
 
   max_ident_len = pph_in_uint (stream);
   identifiers->max_ident_len = max_ident_len;
@@ -3100,7 +3107,7 @@ pph_in_identifiers (pph_stream *stream, cpp_idents_used
*identifiers)
 	}
     }
 
-  timevar_stop (TV_PPH_RESTORE_IDENTIFIERS);
+  timevar_stop (TV_PPH_IN_IDENTIFIERS);
 }
 
 
@@ -3114,7 +3121,7 @@ pph_in_global_binding_keys (pph_stream *stream)
   cp_binding_level *bl, *other_bl;
   bool existed_p;
 
-  timevar_start (TV_PPH_RESTORE_MERGE_KEYS);
+  timevar_start (TV_PPH_IN_MERGE_KEYS);
 
   bl = scope_chain->bindings;
   other_bl = pph_in_binding_level_start (stream, bl, &existed_p);
@@ -3131,7 +3138,7 @@ pph_in_global_binding_keys (pph_stream *stream)
      bound to scope_chain->bindings.  */
   pph_in_merge_key_binding_level (stream, &bl);
 
-  timevar_stop (TV_PPH_RESTORE_MERGE_KEYS);
+  timevar_stop (TV_PPH_IN_MERGE_KEYS);
 }
 
 
@@ -3144,14 +3151,14 @@ pph_in_global_binding_bodies (pph_stream *stream)
 {
   cp_binding_level *bl = scope_chain->bindings;
 
-  timevar_start (TV_PPH_RESTORE_MERGE_BODIES);
+  timevar_start (TV_PPH_IN_MERGE_BODIES);
 
   /* Once all the symbols and types at every binding level have been
      merged to the corresponding binding levels in the current
      compilation, read all the bodies.  */
   pph_in_merge_body_binding_level (stream, bl);
 
-  timevar_stop (TV_PPH_RESTORE_MERGE_BODIES);
+  timevar_stop (TV_PPH_IN_MERGE_BODIES);
 }
 
 
@@ -3235,14 +3242,14 @@ pph_read_file_1 (pph_stream *stream)
 
   /* Read and merge the other global state collected during parsing of
      the original header.  */
-  timevar_start (TV_PPH_RESTORE_MISC);
+  timevar_start (TV_PPH_IN_MISC);
   pph_union_into_chain (&keyed_classes, pph_in_tree (stream));
   pph_union_into_tree_vec (&unemitted_tinfo_decls, pph_in_tree_vec (stream));
   file_static_aggregates = pph_in_tree (stream);
   static_aggregates = chainon (file_static_aggregates, static_aggregates);
   pph_in_decl2_hidden_state (stream);
   pph_in_canonical_template_parms (stream);
-  timevar_stop (TV_PPH_RESTORE_MISC);
+  timevar_stop (TV_PPH_IN_MISC);
 
   /* Read and process the symbol and type re-play table.  This
      re-executes all the actions done to present symbols and types to
@@ -3290,7 +3297,7 @@ pph_add_include (pph_stream *parent, pph_stream *include)
 pph_stream *
 pph_read_file (const char *filename, pph_stream *parent)
 {
-  timevar_start (TV_PPH_RESTORE);
+  timevar_start (TV_PPH_IN);
 
   pph_stream *stream = pph_stream_open (filename, "rb");
   if (stream)
@@ -3308,7 +3315,7 @@ pph_read_file (const char *filename, pph_stream *parent)
 	pph_add_include (parent, stream);
     }
 
-  timevar_stop (TV_PPH_RESTORE);
+  timevar_stop (TV_PPH_IN);
 
   return stream;
 }
diff --git a/gcc/cp/pph-out.c b/gcc/cp/pph-out.c
index 147416c..018a5f0 100644
--- a/gcc/cp/pph-out.c
+++ b/gcc/cp/pph-out.c
@@ -85,14 +85,14 @@ pph_init_write (pph_stream *stream)
 void
 pph_writer_init (void)
 {
-  timevar_start (TV_PPH_SAVE);
+  timevar_start (TV_PPH_OUT);
 
   gcc_assert (pph_out_stream == NULL);
   pph_out_stream = pph_stream_open (pph_out_file, "wb");
   if (pph_out_stream == NULL)
     fatal_error ("Cannot open PPH file %s for writing: %m", pph_out_file);
 
-  timevar_stop (TV_PPH_SAVE);
+  timevar_stop (TV_PPH_OUT);
 }
 
 
@@ -323,7 +323,7 @@ pph_out_line_table_and_includes (pph_stream *stream)
 {
   int ix;
 
-  timevar_start (TV_PPH_SAVE_LINE_TABLE);
+  timevar_start (TV_PPH_OUT_LINE_TABLE);
 
   /* Any #include should have been fully parsed and exited at this point.  */
   gcc_assert (line_table->depth == 0);
@@ -430,7 +430,7 @@ pph_out_line_table_and_includes (pph_stream *stream)
 
   pph_out_uint (stream, line_table->max_column_hint);
 
-  timevar_stop (TV_PPH_SAVE_LINE_TABLE);
+  timevar_stop (TV_PPH_OUT_LINE_TABLE);
 }
 
 
@@ -519,6 +519,10 @@ pph_out_record_marker (pph_stream *stream, enum
pph_record_marker marker,
 
   if (flag_pph_tracer >= 5)
     pph_trace_marker (marker, tag);
+
+  pph_stats.num_records_by_marker[marker]++;
+  pph_stats.num_records_by_tag[tag]++;
+  pph_stats.num_records++;
 }
 
 
@@ -2440,7 +2444,7 @@ pph_out_replay_action (pph_stream *stream, enum
pph_replay_action action)
 	       || action == PPH_REPLAY_EXPAND
 	       || action == PPH_REPLAY_EXPAND_1
 	       || action == PPH_REPLAY_FINISH_STRUCT_METHODS)
-              && (enum pph_replay_action)(unsigned char) action);
+              && action == (enum pph_replay_action)(unsigned char) action);
   pph_out_uchar (stream, action);
 }
 
@@ -2511,7 +2515,7 @@ pph_out_replay (pph_stream *stream)
   pph_replay_entry *entry;
   unsigned i;
 
-  timevar_start (TV_PPH_SAVE_REPLAY);
+  timevar_start (TV_PPH_OUT_REPLAY);
 
   pph_out_uint (stream, VEC_length (pph_replay_entry, stream->replay.v));
   FOR_EACH_VEC_ELT (pph_replay_entry, stream->replay.v, i, entry)
@@ -2534,9 +2538,14 @@ pph_out_replay (pph_stream *stream)
 				   DECL_STRUCT_FUNCTION (entry->to_replay));
 	  pph_out_bool (stream, cgraph_get_node (entry->to_replay) != NULL);
 	}
+
+      pph_stats.num_replay_actions_by_action[entry->action]++;
     }
 
-  timevar_stop (TV_PPH_SAVE_REPLAY);
+  pph_stats.num_replay_actions = VEC_length (pph_replay_entry,
+					     stream->replay.v);
+
+  timevar_stop (TV_PPH_OUT_REPLAY);
 }
 
 
@@ -2547,7 +2556,7 @@ pph_out_identifiers (pph_stream *stream, cpp_idents_used
*identifiers)
 {
   unsigned int num_entries, active_entries, id;
 
-  timevar_start (TV_PPH_SAVE_IDENTIFIERS);
+  timevar_start (TV_PPH_OUT_IDENTIFIERS);
 
   num_entries = identifiers->num_entries;
   pph_out_uint (stream, identifiers->max_ident_len);
@@ -2590,7 +2599,7 @@ pph_out_identifiers (pph_stream *stream, cpp_idents_used
*identifiers)
 				     entry->after_len);
     }
 
-  timevar_stop (TV_PPH_SAVE_IDENTIFIERS);
+  timevar_stop (TV_PPH_OUT_IDENTIFIERS);
 }
 
 
@@ -2601,7 +2610,7 @@ pph_out_global_binding_keys (pph_stream *stream)
 {
   cp_binding_level *bl;
 
-  timevar_start (TV_PPH_SAVE_MERGE_KEYS);
+  timevar_start (TV_PPH_OUT_MERGE_KEYS);
 
   /* We only need to write out the scope_chain->bindings, everything
      else should be NULL or be some temporary disposable state.
@@ -2634,7 +2643,7 @@ pph_out_global_binding_keys (pph_stream *stream)
      reading multiple PPH images.  */
   pph_out_merge_key_binding_level (stream, bl);
 
-  timevar_stop (TV_PPH_SAVE_MERGE_KEYS);
+  timevar_stop (TV_PPH_OUT_MERGE_KEYS);
 }
 
 
@@ -2645,12 +2654,12 @@ pph_out_global_binding_bodies (pph_stream *stream)
 {
   cp_binding_level *bl = scope_chain->bindings;
 
-  timevar_start (TV_PPH_SAVE_MERGE_BODIES);
+  timevar_start (TV_PPH_OUT_MERGE_BODIES);
 
   /* Now emit all the bodies.  */
   pph_out_merge_body_binding_level (stream, bl);
 
-  timevar_stop (TV_PPH_SAVE_MERGE_BODIES);
+  timevar_stop (TV_PPH_OUT_MERGE_BODIES);
 }
 
 
@@ -2680,13 +2689,13 @@ pph_write_file (pph_stream *stream)
 
   /* Emit other global state kept by the parser.  FIXME pph, these
      globals should be fields in struct cp_parser.  */
-  timevar_start (TV_PPH_SAVE_MISC);
+  timevar_start (TV_PPH_OUT_MISC);
   pph_out_tree (stream, keyed_classes);
   pph_out_tree_vec (stream, unemitted_tinfo_decls);
   pph_out_tree (stream, static_aggregates);
   pph_out_decl2_hidden_state (stream);
   pph_out_canonical_template_parms (stream);
-  timevar_stop (TV_PPH_SAVE_MISC);
+  timevar_stop (TV_PPH_OUT_MISC);
 
   /* Emit the symbol table.  The symbol table must be emitted at the
      end because all the symbols read from children PPH images are not
@@ -2798,7 +2807,7 @@ pph_writer_finish (void)
   if (pph_out_stream == NULL)
     return;
 
-  timevar_start (TV_PPH_SAVE);
+  timevar_start (TV_PPH_OUT);
 
   if (!pph_check_main_missing_guard || pph_check_main_guarded ())
     pph_write_file (pph_out_stream);
@@ -2806,7 +2815,7 @@ pph_writer_finish (void)
   pph_stream_close (pph_out_stream);
   pph_out_stream = NULL;
 
-  timevar_stop (TV_PPH_SAVE);
+  timevar_stop (TV_PPH_OUT);
 }
 
 
diff --git a/gcc/cp/pph.h b/gcc/cp/pph.h
index 09a0bef..74860be 100644
--- a/gcc/cp/pph.h
+++ b/gcc/cp/pph.h
@@ -36,7 +36,7 @@ typedef struct pph_stream pph_stream;
    middle-end.  */
 enum pph_replay_action {
   /* Declare this symbol with rest_of_decl_compilation.  */
-  PPH_REPLAY_DECLARE = 0x23,
+  PPH_REPLAY_DECLARE = 0x0,
 
   /* Expand this function with expand_or_defer_fn.  */
   PPH_REPLAY_EXPAND,
@@ -46,13 +46,16 @@ enum pph_replay_action {
 
   /* Layout the method vector for this type with
      finish_struct_methods.  */
-  PPH_REPLAY_FINISH_STRUCT_METHODS
+  PPH_REPLAY_FINISH_STRUCT_METHODS,
+
+  /* This marker must always be last.  */
+  PPH_NUM_REPLAY_ACTIONS
 };
 
 /* Record markers.  */
 enum pph_record_marker {
   /* This record contains the physical representation of the memory data.  */
-  PPH_RECORD_START = 0x23,
+  PPH_RECORD_START = 0,
 
   /* Like PPH_RECORD_START, but the reconstructed data should not be
      added to the pickle cache (see pph_cache_should_handle).  */
@@ -97,7 +100,10 @@ enum pph_record_marker {
   /* Preloaded reference. This marker indicates that this data is a preloaded
      node created by the front-end at the beginning of compilation, which we
      do not need to stream out as it will already exist on the way in.  */
-  PPH_RECORD_PREF
+  PPH_RECORD_PREF,
+
+  /* This marker must always be last.  */
+  PPH_NUM_RECORD_MARKERS
 };
 
 /* Record type tags.  Every record saved on a PPH image contains a data
@@ -135,6 +141,34 @@ enum pph_tag {
 };
 
 
+/* PPH statistics.  */
+
+typedef struct pph_stats_s {
+  /* Number of records per record class.  */
+  unsigned long num_records_by_marker[PPH_NUM_RECORD_MARKERS];
+
+  /* Number of records per type tag.  */
+  unsigned long num_records_by_tag[PPH_NUM_TAGS];
+
+  /* Total number of records.  */
+  unsigned long num_records;
+
+  /* Pickle cache lookups.  */
+  unsigned long cache_lookups;
+
+  /* Pickle cache hits.  */
+  unsigned long cache_hits;
+
+  /* Number of replay actions in the replay table.  */
+  unsigned long num_replay_actions_by_action[PPH_NUM_REPLAY_ACTIONS];
+
+  /* Total number of replay actions in the replay table.  */
+  unsigned long num_replay_actions;
+} pph_stats_t;
+
+extern pph_stats_t pph_stats;
+
+
 /* Global state.  FIXME pph, get rid of these.  */
 
 /* Log file where PPH analysis is written to.  Controlled by
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 3f00fbe..2cd3835 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -20907,12 +20907,12 @@ pph_in_bodies_spec_entry_htab (pph_stream *stream,
htab_t *table)
 void
 pph_out_merge_key_template_state (pph_stream *stream ATTRIBUTE_UNUSED)
 {
-  timevar_start (TV_PPH_SAVE_MERGE_KEYS);
+  timevar_start (TV_PPH_OUT_MERGE_KEYS);
   pph_out_spec_entry_htab (stream, &decl_specializations,
 			   pph_out_key_spec_entry_slot);
   pph_out_spec_entry_htab (stream, &type_specializations,
 			   pph_out_key_spec_entry_slot);
-  timevar_stop (TV_PPH_SAVE_MERGE_KEYS);
+  timevar_stop (TV_PPH_OUT_MERGE_KEYS);
 }
 
 
@@ -20921,7 +20921,7 @@ pph_out_merge_key_template_state (pph_stream *stream
ATTRIBUTE_UNUSED)
 void
 pph_out_merge_body_template_state (pph_stream *stream)
 {
-  timevar_start (TV_PPH_SAVE_MERGE_BODIES);
+  timevar_start (TV_PPH_OUT_MERGE_BODIES);
 
   pph_out_spec_entry_htab (stream, &decl_specializations,
 			   pph_out_body_spec_entry_slot);
@@ -20935,7 +20935,7 @@ pph_out_merge_body_template_state (pph_stream *stream)
       pph_dump_pending_templates_list (stderr);
     }
 
-  timevar_stop (TV_PPH_SAVE_MERGE_BODIES);
+  timevar_stop (TV_PPH_OUT_MERGE_BODIES);
 }
 
 
@@ -20950,7 +20950,7 @@ static strptrmap_t *type_spec_tbl = NULL;
 void
 pph_in_merge_key_template_state (pph_stream *stream ATTRIBUTE_UNUSED)
 {
-  timevar_start (TV_PPH_RESTORE_MERGE_KEYS);
+  timevar_start (TV_PPH_IN_MERGE_KEYS);
 
   if (!decl_spec_tbl)
     decl_spec_tbl = strptrmap_create ();
@@ -20961,7 +20961,7 @@ pph_in_merge_key_template_state (pph_stream *stream
ATTRIBUTE_UNUSED)
   pph_in_keys_spec_entry_htab (stream, pph_in_search_key_spec,
 			       type_spec_tbl);
 
-  timevar_stop (TV_PPH_RESTORE_MERGE_KEYS);
+  timevar_stop (TV_PPH_IN_MERGE_KEYS);
 }
 
 
@@ -20970,7 +20970,7 @@ pph_in_merge_key_template_state (pph_stream *stream
ATTRIBUTE_UNUSED)
 void
 pph_in_merge_body_template_state (pph_stream *stream)
 {
-  timevar_start (TV_PPH_RESTORE_MERGE_BODIES);
+  timevar_start (TV_PPH_IN_MERGE_BODIES);
 
   pph_in_bodies_spec_entry_htab (stream, &decl_specializations);
   pph_in_bodies_spec_entry_htab (stream, &type_specializations);
@@ -20982,7 +20982,7 @@ pph_in_merge_body_template_state (pph_stream *stream)
       pph_dump_pending_templates_list (stderr);
     }
 
-  timevar_stop (TV_PPH_RESTORE_MERGE_BODIES);
+  timevar_stop (TV_PPH_IN_MERGE_BODIES);
 }
 
 
diff --git a/gcc/timevar.def b/gcc/timevar.def
index 42dfa1a..1b50892 100644
--- a/gcc/timevar.def
+++ b/gcc/timevar.def
@@ -61,24 +61,24 @@ DEFTIMEVAR (TV_PCH_RESTORE           , "PCH main state
restore")
 DEFTIMEVAR (TV_PCH_CPP_RESTORE       , "PCH preprocessor state restore")
 
 /* Time spent saving/restoring PPH state.  */
-DEFTIMEVAR (TV_PPH                     , "PPH (global)")
+DEFTIMEVAR (TV_PPH                   , "PPH (global)")
 DEFTIMEVAR (TV_PPH_VALIDATE_IDENTIFIERS, "PPH validate identifiers")
 
-DEFTIMEVAR (TV_PPH_SAVE                , "PPH save (main)")
-DEFTIMEVAR (TV_PPH_SAVE_LINE_TABLE     , "PPH save (line table)")
-DEFTIMEVAR (TV_PPH_SAVE_IDENTIFIERS    , "PPH save (identifiers)")
-DEFTIMEVAR (TV_PPH_SAVE_MERGE_KEYS     , "PPH save (merge keys)")
-DEFTIMEVAR (TV_PPH_SAVE_MERGE_BODIES   , "PPH save (merge bodies)")
-DEFTIMEVAR (TV_PPH_SAVE_MISC           , "PPH save (misc state)")
-DEFTIMEVAR (TV_PPH_SAVE_REPLAY         , "PPH save (replay table)")
+DEFTIMEVAR (TV_PPH_OUT               , "PPH out (main)")
+DEFTIMEVAR (TV_PPH_OUT_LINE_TABLE    , "PPH out (line table)")
+DEFTIMEVAR (TV_PPH_OUT_IDENTIFIERS   , "PPH out (identifiers)")
+DEFTIMEVAR (TV_PPH_OUT_MERGE_KEYS    , "PPH out (merge keys)")
+DEFTIMEVAR (TV_PPH_OUT_MERGE_BODIES  , "PPH out (merge bodies)")
+DEFTIMEVAR (TV_PPH_OUT_MISC          , "PPH out (misc state)")
+DEFTIMEVAR (TV_PPH_OUT_REPLAY        , "PPH out (replay table)")
 
-DEFTIMEVAR (TV_PPH_RESTORE             , "PPH restore (main)")
-DEFTIMEVAR (TV_PPH_RESTORE_LINE_TABLE  , "PPH restore (line table)")
-DEFTIMEVAR (TV_PPH_RESTORE_IDENTIFIERS , "PPH restore (identifiers)")
-DEFTIMEVAR (TV_PPH_RESTORE_MERGE_KEYS  , "PPH restore (merge keys)")
-DEFTIMEVAR (TV_PPH_RESTORE_MERGE_BODIES, "PPH restore (merge bodies)")
-DEFTIMEVAR (TV_PPH_RESTORE_MISC        , "PPH restore (misc state)")
-DEFTIMEVAR (TV_PPH_RESTORE_REPLAY      , "PPH restore (replay table)")
+DEFTIMEVAR (TV_PPH_IN                , "PPH in (main)")
+DEFTIMEVAR (TV_PPH_IN_LINE_TABLE     , "PPH in (line table)")
+DEFTIMEVAR (TV_PPH_IN_IDENTIFIERS    , "PPH in (identifiers)")
+DEFTIMEVAR (TV_PPH_IN_MERGE_KEYS     , "PPH in (merge keys)")
+DEFTIMEVAR (TV_PPH_IN_MERGE_BODIES   , "PPH in (merge bodies)")
+DEFTIMEVAR (TV_PPH_IN_MISC           , "PPH in (misc state)")
+DEFTIMEVAR (TV_PPH_IN_REPLAY         , "PPH in (replay table)")
 
 DEFTIMEVAR (TV_CGRAPH                , "callgraph construction")
 DEFTIMEVAR (TV_CGRAPHOPT             , "callgraph optimization")
-- 
1.7.7.3


--
This patch is available for review at http://codereview.appspot.com/5933044
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b