This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH v2 04/N] Simplify usage of some TDF_* flags.


On 05/17/2017 02:36 PM, Richard Biener wrote:
> On Tue, May 16, 2017 at 3:53 PM, Martin Liška <mliska@suse.cz> wrote:
>> There's one another patch that merges some TDF_* flags that have
>> very similar meaning and do not influence test-suite, because
>> nobody is using them for scanning.
>>
>> Patch can bootstrap on ppc64le-redhat-linux and survives regression tests.
>>
>> Ready to be installed?
> 
> I think the patch removes too many TDF flags.  For example
> -fdump-tree-xxx-address
> will then print not only addresses of gimple stmts but also of each


Hi.

Ok, I'll preserve TDF_STMTADDR flag.

> tree operand.  The
> change to dump_generic_node looks ok though.
> 
> Did you look who intoduced TDF_COMMENT?  ISTR it was for some graph
> dumping stuff.

Adding Steven, author of the TDF_COMMENT.

> 
> Likewise the TDF_VERBOSE use in tree-cfg.c shouldn't be replaced with
> -details but
> dropped if you trop the flag.

Done in v2.

> 
> Did you look at effects in dump-files at all?

I did, with -fdump-tree-all-all and -fdump-rtl-all-all the only difference with my patch are ';; ',
where it only differs for:

 Removing basic block 53
-basic block 53, loop depth 1
- pred:      
- succ:       30
+;; basic block 53, loop depth 1
+;;  pred:      
+;;  succ:       30

while even only file looks as follows (011t.cfg dumpfile):

;; Loop 4
;;  header 7, latch 6
;;  depth 2, outer 1
;;  nodes: 7 6 8
;; 2 succs { 18 3 }
;; 3 succs { 4 11 }
;; 4 succs { 10 }
;; 5 succs { 7 }
;; 6 succs { 7 }
;; 7 succs { 8 9 }
;; 8 succs { 6 9 }
;; 9 succs { 10 }
;; 10 succs { 5 11 }
;; 11 succs { 17 }
;; 12 succs { 14 }
;; 13 succs { 14 }
;; 14 succs { 15 16 }
;; 15 succs { 13 16 }
;; 16 succs { 17 }
;; 17 succs { 12 18 }
;; 18 succs { 1 }

Pass statistics of "cfg": ----------------

fallbackSimpleSort (UInt32D.1796 * fmapD.1799, UInt32D.1796 * eclassD.1800, Int32D.1795 loD.1801, Int32D.1795 hiD.1802)
{
  UInt32D.1796 ec_tmpD.1808;
  Int32D.1795 tmpD.1807;
  Int32D.1795 jD.1806;
  Int32D.1795 iD.1805;

;;   basic block 2, loop depth 0, count 0, freq 0, maybe hot
;;    prev block 0, next block 3, flags: (NEW, REACHABLE)
;;    pred:       ENTRY (FALLTHRU)
  if (loD.1801 == hiD.1802)
    goto <bb 18>; [0.00%]
  else
    goto <bb 3>; [0.00%]
;;    succ:       18 (TRUE_VALUE)
;;                3 (FALSE_VALUE)

;;   basic block 3, loop depth 0, count 0, freq 0, maybe hot
;;    prev block 2, next block 4, flags: (NEW, REACHABLE)
;;    pred:       2 (FALSE_VALUE)

Martin

> 
> Richard.
> 
>> Martin


>From 0aff275b520dc72b13b5d127c36bc6a41af495cd Mon Sep 17 00:00:00 2001
From: marxin <mliska@suse.cz>
Date: Fri, 12 May 2017 15:55:24 +0200
Subject: [PATCH 4/4] Simplify usage of some TDF_* flags.

gcc/ChangeLog:

2017-05-12  Martin Liska  <mliska@suse.cz>

	* cfg.c (check_bb_profile): Do not use TDF_COMMENT and print
	always leading ';; '.
	(dump_bb_info): Likewise.
	(brief_dump_cfg): Likewise.
	* cfgrtl.c (print_rtl_with_bb): Do not use TDF_COMMENT.
	* dumpfile.c: Remove usage of TDF_VERBOSE.
	* dumpfile.h (enum dump_kind): Likewise.
	(dump_gimple_bb_header): Do not use TDF_COMMENT.
	* print-tree.c (debug_verbose): Remove.
	* tree-cfg.c (gimple_dump_cfg): Do not use TDF_COMMENT.
	(dump_function_to_file): Remove dumps guarded with TDF_VERBOSE.
	* tree-diagnostic.c (default_tree_printer): Replace
	TDF_DIAGNOSTIC with TDF_SLIM.
---
 gcc/cfg.c                 | 56 +++++++++++++++++++----------------------------
 gcc/cfgrtl.c              |  4 ++--
 gcc/dumpfile.c            |  4 +---
 gcc/dumpfile.h            |  7 +-----
 gcc/gimple-pretty-print.c |  3 +--
 gcc/print-tree.c          | 15 -------------
 gcc/tree-cfg.c            | 11 ++--------
 gcc/tree-diagnostic.c     |  3 +--
 8 files changed, 31 insertions(+), 72 deletions(-)

diff --git a/gcc/cfg.c b/gcc/cfg.c
index ffac69f266d..aef053f5d22 100644
--- a/gcc/cfg.c
+++ b/gcc/cfg.c
@@ -396,7 +396,7 @@ clear_bb_flags (void)
    It is still practical to have them reported for debugging of simple
    testcases.  */
 static void
-check_bb_profile (basic_block bb, FILE * file, int indent, dump_flags_t flags)
+check_bb_profile (basic_block bb, FILE * file, int indent)
 {
   edge e;
   int sum = 0;
@@ -425,17 +425,17 @@ check_bb_profile (basic_block bb, FILE * file, int indent, dump_flags_t flags)
       if (found)
 	{
 	  if (EDGE_COUNT (bb->succs) && abs (sum - REG_BR_PROB_BASE) > 100)
-	    fprintf (file, "%s%sInvalid sum of outgoing probabilities %.1f%%\n",
-		     (flags & TDF_COMMENT) ? ";; " : "", s_indent,
-		     sum * 100.0 / REG_BR_PROB_BASE);
+	    fprintf (file,
+		     ";; %sInvalid sum of outgoing probabilities %.1f%%\n",
+		     s_indent, sum * 100.0 / REG_BR_PROB_BASE);
 	  lsum = 0;
 	  FOR_EACH_EDGE (e, ei, bb->succs)
 	    lsum += e->count;
 	  if (EDGE_COUNT (bb->succs)
 	      && (lsum - bb->count > 100 || lsum - bb->count < -100))
-	    fprintf (file, "%s%sInvalid sum of outgoing counts %i, should be %i\n",
-		     (flags & TDF_COMMENT) ? ";; " : "", s_indent,
-		     (int) lsum, (int) bb->count);
+	    fprintf (file,
+		     ";; %sInvalid sum of outgoing counts %i, should be %i\n",
+		     s_indent, (int) lsum, (int) bb->count);
 	}
     }
     if (bb != ENTRY_BLOCK_PTR_FOR_FN (fun))
@@ -445,30 +445,28 @@ check_bb_profile (basic_block bb, FILE * file, int indent, dump_flags_t flags)
 	sum += EDGE_FREQUENCY (e);
       if (abs (sum - bb->frequency) > 100)
 	fprintf (file,
-		 "%s%sInvalid sum of incoming frequencies %i, should be %i\n",
-		 (flags & TDF_COMMENT) ? ";; " : "", s_indent,
-		 sum, bb->frequency);
+		 ";; %sInvalid sum of incoming frequencies %i, should be %i\n",
+		 s_indent, sum, bb->frequency);
       lsum = 0;
       FOR_EACH_EDGE (e, ei, bb->preds)
 	lsum += e->count;
       if (lsum - bb->count > 100 || lsum - bb->count < -100)
-	fprintf (file, "%s%sInvalid sum of incoming counts %i, should be %i\n",
-		 (flags & TDF_COMMENT) ? ";; " : "", s_indent,
-		 (int) lsum, (int) bb->count);
+	fprintf (file, ";; %sInvalid sum of incoming counts %i, should be %i\n",
+		 s_indent, (int) lsum, (int) bb->count);
     }
   if (BB_PARTITION (bb) == BB_COLD_PARTITION)
     {
       /* Warn about inconsistencies in the partitioning that are
          currently caused by profile insanities created via optimization.  */
       if (!probably_never_executed_bb_p (fun, bb))
-        fprintf (file, "%s%sBlock in cold partition with hot count\n",
-                 (flags & TDF_COMMENT) ? ";; " : "", s_indent);
+	fprintf (file, ";; %sBlock in cold partition with hot count\n",
+		 s_indent);
       FOR_EACH_EDGE (e, ei, bb->preds)
         {
           if (!probably_never_executed_edge_p (fun, e))
             fprintf (file,
-                     "%s%sBlock in cold partition with incoming hot edge\n",
-                     (flags & TDF_COMMENT) ? ";; " : "", s_indent);
+		     ";; %sBlock in cold partition with incoming hot edge\n",
+		     s_indent);
         }
     }
 }
@@ -737,8 +735,7 @@ dump_bb_info (FILE *outf, basic_block bb, int indent, dump_flags_t flags,
     {
       unsigned i;
 
-      if (flags & TDF_COMMENT)
-	fputs (";; ", outf);
+      fputs (";; ", outf);
       fprintf (outf, "%sbasic block %d, loop depth %d",
 	       s_indent, bb->index, bb_loop_depth (bb));
       if (flags & TDF_DETAILS)
@@ -756,9 +753,8 @@ dump_bb_info (FILE *outf, basic_block bb, int indent, dump_flags_t flags,
 
       if (flags & TDF_DETAILS)
 	{
-	  check_bb_profile (bb, outf, indent, flags);
-	  if (flags & TDF_COMMENT)
-	    fputs (";; ", outf);
+	  check_bb_profile (bb, outf, indent);
+	  fputs (";; ", outf);
 	  fprintf (outf, "%s prev block ", s_indent);
 	  if (bb->prev_bb)
 	    fprintf (outf, "%d", bb->prev_bb->index);
@@ -787,16 +783,14 @@ dump_bb_info (FILE *outf, basic_block bb, int indent, dump_flags_t flags,
 	  fputc ('\n', outf);
 	}
 
-      if (flags & TDF_COMMENT)
-	fputs (";; ", outf);
+      fputs (";; ", outf);
       fprintf (outf, "%s pred:      ", s_indent);
       first = true;
       FOR_EACH_EDGE (e, ei, bb->preds)
 	{
 	  if (! first)
 	    {
-	      if (flags & TDF_COMMENT)
-		fputs (";; ", outf);
+	      fputs (";; ", outf);
 	      fprintf (outf, "%s            ", s_indent);
 	    }
 	  first = false;
@@ -809,16 +803,14 @@ dump_bb_info (FILE *outf, basic_block bb, int indent, dump_flags_t flags,
 
   if (do_footer)
     {
-      if (flags & TDF_COMMENT)
-	fputs (";; ", outf);
+      fputs (";; ", outf);
       fprintf (outf, "%s succ:      ", s_indent);
       first = true;
       FOR_EACH_EDGE (e, ei, bb->succs)
         {
 	  if (! first)
 	    {
-	      if (flags & TDF_COMMENT)
-		fputs (";; ", outf);
+	      fputs (";; ", outf);
 	      fprintf (outf, "%s            ", s_indent);
 	    }
 	  first = false;
@@ -839,9 +831,7 @@ brief_dump_cfg (FILE *file, dump_flags_t flags)
 
   FOR_EACH_BB_FN (bb, cfun)
     {
-      dump_bb_info (file, bb, 0,
-		    flags & (TDF_COMMENT | TDF_DETAILS),
-		    true, true);
+      dump_bb_info (file, bb, 0, flags & TDF_DETAILS, true, true);
     }
 }
 
diff --git a/gcc/cfgrtl.c b/gcc/cfgrtl.c
index aad02921392..fffc4b070cd 100644
--- a/gcc/cfgrtl.c
+++ b/gcc/cfgrtl.c
@@ -2207,7 +2207,7 @@ print_rtl_with_bb (FILE *outf, const rtx_insn *rtx_first, dump_flags_t flags)
 	      bb = start[INSN_UID (tmp_rtx)];
 	      if (bb != NULL)
 		{
-		  dump_bb_info (outf, bb, 0, dump_flags | TDF_COMMENT, true, false);
+		  dump_bb_info (outf, bb, 0, dump_flags, true, false);
 		  if (df && (flags & TDF_DETAILS))
 		    df_dump_top (bb, outf);
 		}
@@ -2234,7 +2234,7 @@ print_rtl_with_bb (FILE *outf, const rtx_insn *rtx_first, dump_flags_t flags)
 	      bb = end[INSN_UID (tmp_rtx)];
 	      if (bb != NULL)
 		{
-		  dump_bb_info (outf, bb, 0, dump_flags | TDF_COMMENT, false, true);
+		  dump_bb_info (outf, bb, 0, dump_flags, false, true);
 		  if (df && (flags & TDF_DETAILS))
 		    df_dump_bottom (bb, outf);
 		  putc ('\n', outf);
diff --git a/gcc/dumpfile.c b/gcc/dumpfile.c
index d5a0e70cf66..d3c64d6f64b 100644
--- a/gcc/dumpfile.c
+++ b/gcc/dumpfile.c
@@ -113,7 +113,6 @@ static const struct dump_option_value_info dump_options[] =
   {"uid", TDF_UID},
   {"stmtaddr", TDF_STMTADDR},
   {"memsyms", TDF_MEMSYMS},
-  {"verbose", TDF_VERBOSE},
   {"eh", TDF_EH},
   {"alias", TDF_ALIAS},
   {"nouid", TDF_NOUID},
@@ -124,8 +123,7 @@ static const struct dump_option_value_info dump_options[] =
   {"missed", MSG_MISSED_OPTIMIZATION},
   {"note", MSG_NOTE},
   {"optall", MSG_ALL},
-  {"all", ~(TDF_RAW | TDF_SLIM | TDF_LINENO
-	    | TDF_STMTADDR | TDF_GRAPH | TDF_DIAGNOSTIC | TDF_VERBOSE
+  {"all", ~(TDF_RAW | TDF_SLIM | TDF_LINENO | TDF_GRAPH | TDF_STMTADDR
 	    | TDF_RHS_ONLY | TDF_NOUID | TDF_ENUMERATE_LOCALS | TDF_SCEV
 	    | TDF_GIMPLE)},
   {NULL, 0}
diff --git a/gcc/dumpfile.h b/gcc/dumpfile.h
index 6edea857ba8..f7dcab0642f 100644
--- a/gcc/dumpfile.h
+++ b/gcc/dumpfile.h
@@ -72,16 +72,12 @@ enum dump_kind
 #define TDF_LINENO	(1 << 10)	/* display statement line numbers */
 #define TDF_UID		(1 << 11)	/* display decl UIDs */
 
-#define TDF_STMTADDR	(1 << 12)	/* Address of stmt.  */
+#define TDF_STMTADDR	(1 << 12)       /* Address of stmt.  */
 
 #define TDF_GRAPH	(1 << 13)	/* a graph dump is being emitted */
 #define TDF_MEMSYMS	(1 << 14)	/* display memory symbols in expr.
 					   Implies TDF_VOPS.  */
 
-#define TDF_DIAGNOSTIC	(1 << 15)	/* A dump to be put in a diagnostic
-					   message.  */
-#define TDF_VERBOSE	(1 << 16)	/* A dump that uses the full tree
-					   dumper to print stmts.  */
 #define TDF_RHS_ONLY	(1 << 17)	/* a flag to only print the RHS of
 					   a gimple stmt.  */
 #define TDF_ASMNAME	(1 << 18)	/* display asm names of decls  */
@@ -92,7 +88,6 @@ enum dump_kind
 #define TDF_ENUMERATE_LOCALS (1 << 22)	/* Enumerate locals by uid.  */
 #define TDF_CSELIB	(1 << 23)	/* Dump cselib details.  */
 #define TDF_SCEV	(1 << 24)	/* Dump SCEV details.  */
-#define TDF_COMMENT	(1 << 25)	/* Dump lines with prefix ";;"  */
 #define TDF_GIMPLE	(1 << 26)	/* Dump in GIMPLE FE syntax  */
 #define MSG_OPTIMIZED_LOCATIONS	 (1 << 27)  /* -fopt-info optimized sources */
 #define MSG_MISSED_OPTIMIZATION	 (1 << 28)  /* missed opportunities */
diff --git a/gcc/gimple-pretty-print.c b/gcc/gimple-pretty-print.c
index c99dfe1192c..5ff63a167a1 100644
--- a/gcc/gimple-pretty-print.c
+++ b/gcc/gimple-pretty-print.c
@@ -2641,8 +2641,7 @@ dump_gimple_bb_header (FILE *outf, basic_block bb, int indent,
 	{
 	  gimple_stmt_iterator gsi;
 
-	  if (flags & TDF_COMMENT)
-	    fputs (";; ", outf);
+	  fputs (";; ", outf);
 
 	  for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
 	    if (!is_gimple_debug (gsi_stmt (gsi))
diff --git a/gcc/print-tree.c b/gcc/print-tree.c
index fb58be6c073..77fcd575335 100644
--- a/gcc/print-tree.c
+++ b/gcc/print-tree.c
@@ -1036,21 +1036,6 @@ debug (const tree_node *ptr)
 }
 
 DEBUG_FUNCTION void
-debug_verbose (const tree_node &ref)
-{
-  dump_tree_via_hooks (&ref, TDF_VERBOSE);
-}
-
-DEBUG_FUNCTION void
-debug_verbose (const tree_node *ptr)
-{
-  if (ptr)
-    debug_verbose (*ptr);
-  else
-    fprintf (stderr, "<nil>\n");
-}
-
-DEBUG_FUNCTION void
 debug_head (const tree_node &ref)
 {
   debug (ref);
diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c
index b588bc03a47..3926a53ed7f 100644
--- a/gcc/tree-cfg.c
+++ b/gcc/tree-cfg.c
@@ -2393,7 +2393,7 @@ gimple_dump_cfg (FILE *file, dump_flags_t flags)
 	       n_basic_blocks_for_fn (cfun), n_edges_for_fn (cfun),
 	       last_basic_block_for_fn (cfun));
 
-      brief_dump_cfg (file, flags | TDF_COMMENT);
+      brief_dump_cfg (file, flags);
       fprintf (file, "\n");
     }
 
@@ -7583,17 +7583,12 @@ dump_function_to_file (tree fndecl, FILE *file, dump_flags_t flags)
       print_generic_expr (file, TREE_TYPE (arg), dump_flags);
       fprintf (file, " ");
       print_generic_expr (file, arg, dump_flags);
-      if (flags & TDF_VERBOSE)
-	print_node (file, "", arg, 4);
       if (DECL_CHAIN (arg))
 	fprintf (file, ", ");
       arg = DECL_CHAIN (arg);
     }
   fprintf (file, ")\n");
 
-  if (flags & TDF_VERBOSE)
-    print_node (file, "", fndecl, 2);
-
   dsf = DECL_STRUCT_FUNCTION (fndecl);
   if (dsf && (flags & TDF_EH))
     dump_eh_tree (file, dsf);
@@ -7646,8 +7641,6 @@ dump_function_to_file (tree fndecl, FILE *file, dump_flags_t flags)
 	FOR_EACH_LOCAL_DECL (fun, ix, var)
 	  {
 	    print_generic_decl (file, var, flags);
-	    if (flags & TDF_VERBOSE)
-	      print_node (file, "", var, 4);
 	    fprintf (file, "\n");
 
 	    any_var = true;
@@ -7683,7 +7676,7 @@ dump_function_to_file (tree fndecl, FILE *file, dump_flags_t flags)
 	fprintf (file, "\n");
 
       FOR_EACH_BB_FN (bb, fun)
-	dump_bb (file, bb, 2, flags | TDF_COMMENT);
+	dump_bb (file, bb, 2, flags);
 
       fprintf (file, "}\n");
     }
diff --git a/gcc/tree-diagnostic.c b/gcc/tree-diagnostic.c
index 4f211ed42b3..1009c78ab3c 100644
--- a/gcc/tree-diagnostic.c
+++ b/gcc/tree-diagnostic.c
@@ -26,7 +26,6 @@ along with GCC; see the file COPYING3.  If not see
 #include "diagnostic.h"
 #include "tree-pretty-print.h"
 #include "tree-diagnostic.h"
-#include "dumpfile.h" /* TDF_DIAGNOSTIC */
 #include "langhooks.h"
 #include "intl.h"
 
@@ -294,7 +293,7 @@ default_tree_printer (pretty_printer *pp, text_info *text, const char *spec,
       pp_string (pp, n);
     }
   else
-    dump_generic_node (pp, t, 0, TDF_DIAGNOSTIC, 0);
+    dump_generic_node (pp, t, 0, TDF_SLIM, 0);
 
   return true;
 }
-- 
2.12.2



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]