Remove old trace facility. Having done so, rename pph_new_trace_tree to pph_trace_tree and remove its unused stream parameter. Adjust callers to match.
Bootstrap and PPH tests. Index: gcc/cp/ChangeLog.pph 2011-10-12 Lawrence Crowl <cr...@google.com> * pph-streamer.h (enum pph_trace_type): Remove. (pph_trace): Likewise. (pph_trace_tree): Likewise. (pph_trace_uint): Likewise. (pph_trace_bytes): Likewise. (pph_trace_string): Likewise. (pph_trace_string_with_length): Likewise. (pph_trace_location): Likewise. (pph_trace_chain): Likewise. (pph_trace_bitpack): Likewise. (pph_new_trace_tree): Rename pph_trace_tree. Remove unused stream parameter. * pph-streamer.c (enum pph_trace_type): Remove. (pph_trace): Likewise. (pph_trace_tree): Likewise. (pph_trace_uint): Likewise. (pph_trace_bytes): Likewise. (pph_trace_string): Likewise. (pph_trace_string_with_length): Likewise. (pph_trace_location): Likewise. (pph_trace_chain): Likewise. (pph_trace_bitpack): Likewise. (pph_new_trace_tree): Rename pph_trace_tree. Remove unused stream parameter. * pph-streamer-out.c (pph_out_any_tree): Call new pph_trace_tree instead of old pph_new_trace_tree. * pph-streamer-in.c (pph_in_any_tree): Call new pph_trace_tree instead of old pph_new_trace_tree. (pph_in_location): Change lead comment. Index: gcc/cp/pph-streamer-in.c =================================================================== --- gcc/cp/pph-streamer-in.c (revision 179887) +++ gcc/cp/pph-streamer-in.c (working copy) @@ -577,9 +577,9 @@ pph_read_location (struct lto_input_bloc /* Read and return a location_t from STREAM. - FIXME pph: If pph_trace didn't depend on STREAM, we could avoid having to - call this function, only for it to call lto_input_location, which calls the - streamer hook back to pph_read_location. */ + FIXME pph: Tracing doesn't depend on STREAM any more. We could avoid having + to call this function, only for it to call lto_input_location, which calls + the streamer hook back to pph_read_location. Say what? */ location_t pph_in_location (pph_stream *stream) @@ -2028,7 +2028,7 @@ pph_in_any_tree (pph_stream *stream, tre pph_cache_insert_at (&stream->cache, expr, ix, pph_tree_code_to_tag (expr)); pph_in_tree_body (stream, expr); - pph_new_trace_tree (stream, expr, chain != NULL); + pph_trace_tree (expr, chain != NULL); /* If needed, sign the recently materialized tree to detect mutations. Note that we only need to compute signatures Index: gcc/cp/pph-streamer.c =================================================================== --- gcc/cp/pph-streamer.c (revision 179886) +++ gcc/cp/pph-streamer.c (working copy) @@ -285,137 +285,10 @@ pph_add_include (pph_stream *stream, pph } -/* Data types supported by the PPH tracer. */ -enum pph_trace_type -{ - PPH_TRACE_TREE, - PPH_TRACE_UINT, - PPH_TRACE_BYTES, - PPH_TRACE_STRING, - PPH_TRACE_LOCATION, - PPH_TRACE_CHAIN, - PPH_TRACE_BITPACK -}; - - -/* Print tracing information for STREAM on pph_logfile. DATA is the - memory area to display, SIZE is the number of bytes to print, TYPE - is the kind of data to print. */ - -static void -pph_trace (pph_stream *stream, const void *data, unsigned int nbytes, - enum pph_trace_type type) -{ - const char *op = (stream->write_p) ? "<<" : ">>"; - const char *type_s[] = { "tree", "ref", "uint", "bytes", "string", "chain", - "bitpack" }; - - if ((type == PPH_TRACE_TREE || type == PPH_TRACE_CHAIN) - && !data - && flag_pph_tracer <= 3) - return; - - fprintf (pph_logfile, "PPH: %s %s %s/%u", - stream->name, op, type_s[type], (unsigned) nbytes); - - switch (type) - { - case PPH_TRACE_TREE: - { - const_tree t = (const_tree) data; - if (t) - { - enum tree_code code = TREE_CODE (t); - fprintf (pph_logfile, ", code=%s", pph_tree_code_text (code)); - if (DECL_P (t)) - { - fprintf (pph_logfile, ", value="); -#if 1 - print_generic_decl (pph_logfile, - CONST_CAST (union tree_node *, t), 0); -#else - pph_dump_tree_name (pph_logfile, t, 0); -#endif - } - } - else - fprintf (pph_logfile, ", NULL_TREE"); - } - break; - - case PPH_TRACE_UINT: - { - unsigned int val = *((const unsigned int *) data); - fprintf (pph_logfile, ", value=%u (0x%x)", val, val); - } - break; - - case PPH_TRACE_BYTES: - { - size_t i; - const char *buffer = (const char *) data; - fprintf (pph_logfile, ", value="); - for (i = 0; i < MIN (nbytes, 100); i++) - { - if (ISPRINT (buffer[i])) - fprintf (pph_logfile, "%c", buffer[i]); - else - fprintf (pph_logfile, "[0x%02x]", (unsigned int) buffer[i]); - } - } - break; - - case PPH_TRACE_STRING: - if (data) - fprintf (pph_logfile, ", value=%.*s", - (int) nbytes, (const char *) data); - else - fprintf (pph_logfile, ", NULL_STRING"); - break; - - case PPH_TRACE_LOCATION: - if (data) - fprintf (pph_logfile, ", value=%.*s", - (int) nbytes, (const char *) data); - else - fprintf (pph_logfile, ", NULL_LOCATION"); - break; - - case PPH_TRACE_CHAIN: - { - const_tree t = (const_tree) data; - fprintf (pph_logfile, ", value=" ); - print_generic_expr (pph_logfile, CONST_CAST (union tree_node *, t), - TDF_SLIM); - fprintf (pph_logfile, " (%d nodes in chain)", list_length (t)); - } - break; - - case PPH_TRACE_BITPACK: - { - const struct bitpack_d *bp = (const struct bitpack_d *) data; - fprintf (pph_logfile, ", value=0x%lx", bp->word); - } - break; - - default: - gcc_unreachable (); - } - - fputc ('\n', pph_logfile); -} - - -/* Show tracing information for T on STREAM. */ - -void -pph_trace_tree (pph_stream *stream, tree t) -{ - pph_trace (stream, t, t ? tree_code_size (TREE_CODE (t)) : 0, PPH_TRACE_TREE); -} +/* Print tracing information for a possibly MERGEABLE tree T. */ void -pph_new_trace_tree (pph_stream *stream ATTRIBUTE_UNUSED, tree t, bool mergeable) +pph_trace_tree (tree t, bool mergeable) { bool emit = false; char merging = mergeable ? '*' : '.'; @@ -437,82 +310,6 @@ pph_new_trace_tree (pph_stream *stream A } -/* Show tracing information for VAL on STREAM. */ - -void -pph_trace_uint (pph_stream *stream, unsigned int val) -{ - pph_trace (stream, &val, sizeof (val), PPH_TRACE_UINT); -} - - -/* Show tracing information for NBYTES bytes of memory area DATA on - STREAM. */ - -void -pph_trace_bytes (pph_stream *stream, const void *data, size_t nbytes) -{ - pph_trace (stream, data, nbytes, PPH_TRACE_BYTES); -} - - -/* Show tracing information for S on STREAM. */ - -void -pph_trace_string (pph_stream *stream, const char *s) -{ - pph_trace (stream, s, s ? strlen (s) : 0, PPH_TRACE_STRING); -} - - -/* Show tracing information for LEN bytes of S on STREAM. */ - -void -pph_trace_string_with_length (pph_stream *stream, const char *s, - unsigned int len) -{ - pph_trace (stream, s, len, PPH_TRACE_STRING); -} - - -/* Show tracing information for location_t LOC on STREAM. */ - -void -pph_trace_location (pph_stream *stream, location_t loc) -{ - expanded_location xloc = expand_location (loc); - size_t flen = strlen (xloc.file); - size_t mlen = flen + 12; /* for : and 10 digits and \n */ - size_t llen; - char *str = (char *)xmalloc (mlen); - - strcpy (str, xloc.file); - str[flen] = ':'; - sprintf (str + flen + 1, "%d", xloc.line); - llen = strlen (str); - pph_trace (stream, str, llen, PPH_TRACE_LOCATION); -} - - -/* Show tracing information for a tree chain starting with T on STREAM. */ - -void -pph_trace_chain (pph_stream *stream, tree t) -{ - pph_trace (stream, t, t ? tree_code_size (TREE_CODE (t)) : 0, - PPH_TRACE_CHAIN); -} - - -/* Show tracing information for a bitpack BP on STREAM. */ - -void -pph_trace_bitpack (pph_stream *stream, struct bitpack_d *bp) -{ - pph_trace (stream, bp, sizeof (*bp), PPH_TRACE_BITPACK); -} - - /* Insert DATA in CACHE at slot IX. TAG represents the data structure pointed-to by DATA. As a restriction to prevent stomping on cache entries, this will not allow inserting into the same slot more than Index: gcc/cp/pph-streamer-out.c =================================================================== --- gcc/cp/pph-streamer-out.c (revision 179887) +++ gcc/cp/pph-streamer-out.c (working copy) @@ -1954,7 +1954,7 @@ pph_out_any_tree (pph_stream *stream, tr } else if (marker == PPH_RECORD_START || marker == PPH_RECORD_START_MUTATED) { - pph_new_trace_tree (stream, expr, mergeable); + pph_trace_tree (expr, mergeable); /* This is the first time we see EXPR, write it out. */ if (marker == PPH_RECORD_START) Index: gcc/cp/pph-streamer.h =================================================================== --- gcc/cp/pph-streamer.h (revision 179886) +++ gcc/cp/pph-streamer.h (working copy) @@ -229,15 +229,7 @@ pph_stream *pph_stream_open (const char void pph_mark_stream_read (pph_stream *); void pph_stream_close (pph_stream *); void pph_add_include (pph_stream *, pph_stream *); -void pph_trace_tree (pph_stream *, tree); -void pph_new_trace_tree (pph_stream *, tree, bool); -void pph_trace_uint (pph_stream *, unsigned int); -void pph_trace_bytes (pph_stream *, const void *, size_t); -void pph_trace_string (pph_stream *, const char *); -void pph_trace_string_with_length (pph_stream *, const char *, unsigned); -void pph_trace_location (pph_stream *, location_t); -void pph_trace_chain (pph_stream *, tree); -void pph_trace_bitpack (pph_stream *, struct bitpack_d *); +void pph_trace_tree (tree, bool); void pph_cache_insert_at (pph_cache *, void *, unsigned, enum pph_tag); bool pph_cache_lookup (pph_cache *, void *, unsigned *, enum pph_tag); bool pph_cache_lookup_in_includes (pph_stream *, void *, unsigned *, unsigned *, -- This patch is available for review at http://codereview.appspot.com/5271041