I noticed that the output of -fdump-tree-walloca (and probably all
passes that call gimple_ranger::export_global_ranges()) includes
the following two lines for all functions, even when there's
nothing else of relevance after them:

Exported global range table
===========================

I was a bit puzzled by it at first, wondering if it was leftover
debugging output, until I checked the code and realized it's
a header that may be (but isn't always) followed by the contents
of the table.

To reduce clutter in the dump the attached patch changes the function
to print the header only when it is followed by at least one line of
output.  (Another tweak to reduce even further the amount of output
printed by default that might be worth considering is to print
the table only when TDF_DETAILS is set.)

Martin
Avoid printing range table header alone.

gcc/ChangeLog:
	* gimple-range.cc (gimple_ranger::export_global_ranges):

diff --git a/gcc/gimple-range.cc b/gcc/gimple-range.cc
index ef3afeacc90..521d7cee5f0 100644
--- a/gcc/gimple-range.cc
+++ b/gcc/gimple-range.cc
@@ -259,16 +259,9 @@ gimple_ranger::range_of_stmt (irange &r, gimple *s, tree name)
 void
 gimple_ranger::export_global_ranges ()
 {
-  unsigned x;
-  int_range_max r;
-  if (dump_file)
-    {
-      fprintf (dump_file, "Exported global range table\n");
-      fprintf (dump_file, "===========================\n");
-    }
-
-  for ( x = 1; x < num_ssa_names; x++)
+  for (unsigned x = 1; x < num_ssa_names; x++)
     {
+      int_range_max r;
       tree name = ssa_name (x);
       if (name && !SSA_NAME_IN_FREE_LIST (name)
 	  && gimple_range_ssa_p (name)
@@ -276,21 +269,28 @@ gimple_ranger::export_global_ranges ()
 	  && !r.varying_p())
 	{
 	  bool updated = update_global_range (r, name);
+	  if (!updated || !dump_file)
+	    continue;
 
-	  if (updated && dump_file)
+	  if (x == 1)
 	    {
-	      value_range vr = r;
-	      print_generic_expr (dump_file, name , TDF_SLIM);
-	      fprintf (dump_file, " --> ");
-	      vr.dump (dump_file);
+	      /* Print the header only when there's something else
+		 to print below.  */
+	      fprintf (dump_file, "Exported global range table\n");
+	      fprintf (dump_file, "===========================\n");
+	    }
+
+	  value_range vr = r;
+	  print_generic_expr (dump_file, name , TDF_SLIM);
+	  fprintf (dump_file, " --> ");
+	  vr.dump (dump_file);
+	  fprintf (dump_file, "\n");
+	  int_range_max same = vr;
+	  if (same != r)
+	    {
+	      fprintf (dump_file, "         irange : ");
+	      r.dump (dump_file);
 	      fprintf (dump_file, "\n");
-	      int_range_max same = vr;
-	      if (same != r)
-		{
-		  fprintf (dump_file, "         irange : ");
-		  r.dump (dump_file);
-		  fprintf (dump_file, "\n");
-		}
 	    }
 	}
     }

Reply via email to