From 4042dca916ad7f5a99438e37416d4fed2209cc6d Mon Sep 17 00:00:00 2001 From: Gabriel Dos Reis Date: Fri, 16 Aug 2013 10:42:49 +0000 Subject: [PATCH] sched-vis.c (rtl_slim_pp_initialized): Remove. * sched-vis.c (rtl_slim_pp_initialized): Remove. (rtl_slim_pp): Likewise. (init_rtl_slim_pretty_print): Likewise. (dump_value_slim): Don't call it. Use local pretty printer. (dump_insn_slim): Likewise. (dump_rtl_slim): Likewise. (str_pattern_slim): Likewise. * tree-mudflap.c (mf_varname_tree): Use local pretty printer. Simplify. From-SVN: r201785 --- gcc/ChangeLog | 12 ++++++++++++ gcc/sched-vis.c | 53 +++++++++++++++++++---------------------------------- gcc/tree-mudflap.c | 36 +++++++++++++++--------------------- 3 files changed, 46 insertions(+), 55 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 004dfb4..f9c214c 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,15 @@ +2013-08-16 Gabriel Dos Reis + + * sched-vis.c (rtl_slim_pp_initialized): Remove. + (rtl_slim_pp): Likewise. + (init_rtl_slim_pretty_print): Likewise. + (dump_value_slim): Don't call it. Use local pretty printer. + (dump_insn_slim): Likewise. + (dump_rtl_slim): Likewise. + (str_pattern_slim): Likewise. + * tree-mudflap.c (mf_varname_tree): Use local pretty printer. + Simplify. + 2013-08-16 Jakub Jelinek PR tree-optimization/58164 diff --git a/gcc/sched-vis.c b/gcc/sched-vis.c index 2cf3d10..a65e922 100644 --- a/gcc/sched-vis.c +++ b/gcc/sched-vis.c @@ -47,10 +47,6 @@ along with GCC; see the file COPYING3. If not see It is also possible to obtain a string for a single pattern as a string pointer, via str_pattern_slim, but this usage is discouraged. */ -/* A pretty-printer for slim rtl printing. */ -static bool rtl_slim_pp_initialized = false; -static pretty_printer rtl_slim_pp; - /* For insns we print patterns, and for some patterns we print insns... */ static void print_insn_with_notes (pretty_printer *, const_rtx); @@ -760,24 +756,6 @@ print_insn_with_notes (pretty_printer *pp, const_rtx x) } } -/* Return a pretty-print buffer set up to print to file F. */ - -static pretty_printer * -init_rtl_slim_pretty_print (FILE *f) -{ - if (! rtl_slim_pp_initialized) - { - pp_construct (&rtl_slim_pp, /*prefix=*/NULL, /*linewidth=*/0); - rtl_slim_pp_initialized = true; - } - else - /* Clean out any data that str_insn_slim may have left here. */ - pp_clear_output_area (&rtl_slim_pp); - - rtl_slim_pp.buffer->stream = f; - return &rtl_slim_pp; -} - /* Print X, an RTL value node, to file F in slim format. Include additional information if VERBOSE is nonzero. @@ -787,9 +765,11 @@ init_rtl_slim_pretty_print (FILE *f) void dump_value_slim (FILE *f, const_rtx x, int verbose) { - pretty_printer *pp = init_rtl_slim_pretty_print (f); - print_value (pp, x, verbose); - pp_flush (pp); + pretty_printer rtl_slim_pp; + pp_construct (&rtl_slim_pp, /*prefix=*/NULL, /*linewidth=*/0); + rtl_slim_pp.buffer->stream = f; + print_value (&rtl_slim_pp, x, verbose); + pp_flush (&rtl_slim_pp); } /* Emit a slim dump of X (an insn) to the file F, including any register @@ -797,9 +777,11 @@ dump_value_slim (FILE *f, const_rtx x, int verbose) void dump_insn_slim (FILE *f, const_rtx x) { - pretty_printer *pp = init_rtl_slim_pretty_print (f); - print_insn_with_notes (pp, x); - pp_flush (pp); + pretty_printer rtl_slim_pp; + pp_construct (&rtl_slim_pp, /*prefix=*/NULL, /*linewidth=*/0); + rtl_slim_pp.buffer->stream = f; + print_insn_with_notes (&rtl_slim_pp, x); + pp_flush (&rtl_slim_pp); } /* Same as above, but stop at LAST or when COUNT == 0. @@ -810,19 +792,21 @@ dump_rtl_slim (FILE *f, const_rtx first, const_rtx last, int count, int flags ATTRIBUTE_UNUSED) { const_rtx insn, tail; - pretty_printer *pp = init_rtl_slim_pretty_print (f); + pretty_printer rtl_slim_pp; + pp_construct (&rtl_slim_pp, /*prefix=*/NULL, /*linewidth=*/0); + rtl_slim_pp.buffer->stream = f; tail = last ? NEXT_INSN (last) : NULL_RTX; for (insn = first; (insn != NULL) && (insn != tail) && (count != 0); insn = NEXT_INSN (insn)) { - print_insn_with_notes (pp, insn); + print_insn_with_notes (&rtl_slim_pp, insn); if (count > 0) count--; } - pp_flush (pp); + pp_flush (&rtl_slim_pp); } /* Dumps basic block BB to pretty-printer PP in slim form and without and @@ -857,9 +841,10 @@ rtl_dump_bb_for_graph (pretty_printer *pp, basic_block bb) const char * str_pattern_slim (const_rtx x) { - pretty_printer *pp = init_rtl_slim_pretty_print (NULL); - print_pattern (pp, x, 0); - return pp_formatted_text (pp); + pretty_printer rtl_slim_pp; + pp_construct (&rtl_slim_pp, /*prefix=*/NULL, /*linewidth=*/0); + print_pattern (&rtl_slim_pp, x, 0); + return ggc_strdup (pp_formatted_text (&rtl_slim_pp)); } /* Emit a slim dump of X (an insn) to stderr. */ diff --git a/gcc/tree-mudflap.c b/gcc/tree-mudflap.c index adf2f7b..293ee2c 100644 --- a/gcc/tree-mudflap.c +++ b/gcc/tree-mudflap.c @@ -106,20 +106,14 @@ mf_build_string (const char *string) static tree mf_varname_tree (tree decl) { - static pretty_printer buf_rec; - static int initialized = 0; - pretty_printer *buf = & buf_rec; const char *buf_contents; tree result; gcc_assert (decl); - if (!initialized) - { - pp_construct (buf, /* prefix */ NULL, /* line-width */ 0); - initialized = 1; - } - pp_clear_output_area (buf); + pretty_printer buf; + pp_construct (&buf, /* prefix */ NULL, /* line-width */ 0); + pp_clear_output_area (&buf); /* Add FILENAME[:LINENUMBER[:COLUMNNUMBER]]. */ { @@ -134,17 +128,17 @@ mf_varname_tree (tree decl) if (sourcefile == NULL) sourcefile = ""; - pp_string (buf, sourcefile); + pp_string (&buf, sourcefile); if (sourceline != 0) { - pp_colon (buf); - pp_decimal_int (buf, sourceline); + pp_colon (&buf); + pp_decimal_int (&buf, sourceline); if (sourcecolumn != 0) { - pp_colon (buf); - pp_decimal_int (buf, sourcecolumn); + pp_colon (&buf); + pp_decimal_int (&buf, sourcecolumn); } } } @@ -152,7 +146,7 @@ mf_varname_tree (tree decl) if (current_function_decl != NULL_TREE) { /* Add (FUNCTION) */ - pp_string (buf, " ("); + pp_string (&buf, " ("); { const char *funcname = NULL; if (DECL_NAME (current_function_decl)) @@ -160,12 +154,12 @@ mf_varname_tree (tree decl) if (funcname == NULL) funcname = "anonymous fn"; - pp_string (buf, funcname); + pp_string (&buf, funcname); } - pp_string (buf, ") "); + pp_string (&buf, ") "); } else - pp_space (buf); + pp_space (&buf); /* Add , possibly demangled. */ { @@ -186,13 +180,13 @@ mf_varname_tree (tree decl) if (declname == NULL) declname = ""; - pp_string (buf, declname); + pp_string (&buf, declname); } /* Return the lot as a new STRING_CST. */ - buf_contents = pp_formatted_text (buf); + buf_contents = ggc_strdup (pp_formatted_text (&buf)); result = mf_build_string (buf_contents); - pp_clear_output_area (buf); + pp_clear_output_area (&buf); return result; } -- 2.7.4