[PATCH] Fix -dv (take 2)

Jakub Jelinek jakub@redhat.com
Thu Aug 11 10:16:00 GMT 2005


On Thu, Aug 11, 2005 at 11:28:12AM +0200, Paolo Bonzini wrote:
> >There is another problem, with GCC 4+ print_rtl_graph_with_bb
> >is never called when -dv is requested, so all the vcg files contain just:
> >graph: {
> >port_sharing: no
> >}
> 
> Hum, this worked after my patch at 
> http://gcc.gnu.org/ml/gcc-patches/2004-08/msg00853.html that unified the 
> handling of dump files for trees and RTL; however, the relevant hunk 
> went away with revision 2.56 of tree-optimize.c.
> 
> The following patch fixes it.  I only tested by bubblestrap, because VCG 
> printing is not covered by the testsuite.
> 
> Ok for mainline?

This is not enough, on HEAD you end up with *.vcg files only containing
} and newline.

But if print_rtl_with_bb should be run from execute_todo rather than
execute_one_pass, here is the patch that does the job for me.
I have noticed GCC 4.0 code being pretty different, so I have prepared
a separate 4.0 version as well.

On 4.0 branch, clean_graph_dump_file is called by close_dump_file,
so it is both superfluous to call it also in execute_one_pass and
additionally calling it there also introduces the ICE.

	Jakub
-------------- next part --------------
2005-08-11  Jakub Jelinek  <jakub@redhat.com>

	* tree-pass.h (TDF_GRAPH): Define.
	* tree-dump.c (dump_options): Don't set TDF_GRAPH in "all".
	* passes.c (finish_optimization_passes): Only call
	finish_graph_dump_file if TDF_GRAPH is set.
	(execute_one_pass): Only call clean_graph_dump_file if dump_file !=
	NULL.  Set TDF_GRAPH bit.
	(execute_todo): Call print_rtl_graph_with_bb if TDF_GRAPH is set.

--- gcc/tree-pass.h.jj	2005-08-06 10:40:01.000000000 +0200
+++ gcc/tree-pass.h	2005-08-11 11:10:30.000000000 +0200
@@ -67,6 +67,8 @@ enum tree_dump_index
 #define TDF_IPA		(1 << 11)	/* is an IPA dump */
 #define TDF_STMTADDR	(1 << 12)	/* Address of stmt.  */
 
+#define TDF_GRAPH	(1 << 13)	/* a graph dump is being emitted */
+
 extern char *get_dump_file_name (enum tree_dump_index);
 extern int dump_enabled_p (enum tree_dump_index);
 extern int dump_initialized_p (enum tree_dump_index);
--- gcc/tree-dump.c.jj	2005-08-06 10:40:00.000000000 +0200
+++ gcc/tree-dump.c	2005-08-11 11:11:35.000000000 +0200
@@ -752,7 +752,7 @@ static const struct dump_option_value_in
   {"uid", TDF_UID},
   {"stmtaddr", TDF_STMTADDR},
   {"all", ~(TDF_RAW | TDF_SLIM | TDF_LINENO | TDF_TREE | TDF_RTL | TDF_IPA 
-	    | TDF_STMTADDR)},
+	    | TDF_STMTADDR | TDF_GRAPH)},
   {NULL, 0}
 };
 
--- gcc/passes.c.jj	2005-08-06 10:39:59.000000000 +0200
+++ gcc/passes.c	2005-08-11 11:39:02.000000000 +0200
@@ -237,12 +237,12 @@ finish_optimization_passes (void)
   if (graph_dump_format != no_graph)
     for (i = TDI_end; (dfi = get_dump_file_info (i)) != NULL; ++i)
       if (dump_initialized_p (i)
-	  && (dfi->flags & TDF_RTL) != 0
+	  && (dfi->flags & TDF_GRAPH) != 0
 	  && (name = get_dump_file_name (i)) != NULL)
-        {
-          finish_graph_dump_file (name);
-          free (name);
-        }
+	{
+	  finish_graph_dump_file (name);
+	  free (name);
+	}
 
   timevar_pop (TV_DUMP);
 }
@@ -708,7 +708,13 @@ execute_todo (struct tree_opt_pass *pass
         dump_function_to_file (current_function_decl,
                                dump_file, dump_flags);
       else if (properties & PROP_cfg)
-        print_rtl_with_bb (dump_file, get_insns ());
+	{
+	  print_rtl_with_bb (dump_file, get_insns ());
+
+	  if (graph_dump_format != no_graph
+	      && (dump_flags & TDF_GRAPH))
+	    print_rtl_graph_with_bb (dump_file_name, get_insns ());
+	}
       else
         print_rtl (dump_file, get_insns ());
 
@@ -782,10 +788,15 @@ execute_one_pass (struct tree_opt_pass *
 	}
 
       if (initializing_dump
-          && graph_dump_format != no_graph
+	  && dump_file
+	  && graph_dump_format != no_graph
 	  && (pass->properties_provided & (PROP_cfg | PROP_rtl))
 	      == (PROP_cfg | PROP_rtl))
-        clean_graph_dump_file (dump_file_name);
+	{
+	  get_dump_file_info (pass->static_pass_number)->flags |= TDF_GRAPH;
+	  dump_flags |= TDF_GRAPH;
+	  clean_graph_dump_file (dump_file_name);
+	}
     }
 
   /* If a timevar is present, start it.  */
-------------- next part --------------
2005-08-11  Jakub Jelinek  <jakub@redhat.com>

	* tree-pass.h (TDF_GRAPH): Define.
	* tree-dump.c (dump_options): Don't set TDF_GRAPH in "all".
	* passes.c (finish_optimization_passes): Only call
	finish_graph_dump_file if TDF_GRAPH is set.
	(execute_one_pass): Only call clean_graph_dump_file if dump_file !=
	NULL.  Set TDF_GRAPH bit.
	(execute_todo): Call print_rtl_graph_with_bb if TDF_GRAPH is set.

--- gcc/tree.h.jj	2005-03-21 13:00:38.000000000 +0100
+++ gcc/tree.h	2005-03-21 13:00:38.000000000 +0100
@@ -3893,6 +3893,8 @@ enum tree_dump_index
 #define TDF_RTL		(1 << 10)	/* is a RTL dump */
 #define TDF_IPA		(1 << 11)	/* is an IPA dump */
 
+#define TDF_GRAPH	(1 << 12)	/* a graph dump is being emitted */
+
 typedef struct dump_info *dump_info_p;
 
 extern char *get_dump_file_name (enum tree_dump_index);
--- gcc/tree-dump.c.jj	2005-02-15 16:53:47.000000000 +0100
+++ gcc/tree-dump.c	2005-08-11 12:01:13.000000000 +0200
@@ -745,7 +745,8 @@ static const struct dump_option_value_in
   {"vops", TDF_VOPS},
   {"lineno", TDF_LINENO},
   {"uid", TDF_UID},
-  {"all", ~(TDF_RAW | TDF_SLIM | TDF_LINENO | TDF_TREE | TDF_RTL | TDF_IPA)},
+  {"all", ~(TDF_RAW | TDF_SLIM | TDF_LINENO | TDF_TREE | TDF_RTL | TDF_IPA
+	    | TDF_GRAPH)},
   {NULL, 0}
 };
 
--- gcc/passes.c.jj	2005-04-03 11:12:23.000000000 +0200
+++ gcc/passes.c	2005-08-11 12:04:03.000000000 +0200
@@ -159,7 +159,10 @@ close_dump_file (enum tree_dump_index in
     {
       /* If we've not initialized the files, do so now.  */
       if (initializing_dump)
-	clean_graph_dump_file (dump_file_name);
+	{
+	  clean_graph_dump_file (dump_file_name);
+	  get_dump_file_info (index)->flags |= TDF_GRAPH;
+	}
 
       print_rtl_graph_with_bb (dump_file_name, insns);
     }
@@ -1782,7 +1785,7 @@ finish_optimization_passes (void)
   if (graph_dump_format != no_graph)
     for (i = DFI_MIN; (dfi = get_dump_file_info (i)) != NULL; ++i)
       if (dump_initialized_p (i)
-	  && (dfi->flags & TDF_RTL) != 0
+	  && (dfi->flags & TDF_GRAPH) != 0
 	  && (name = get_dump_file_name (i)) != NULL)
         {
           finish_graph_dump_file (name);
--- gcc/tree-optimize.c.jj	2005-03-03 12:31:04.000000000 +0100
+++ gcc/tree-optimize.c	2005-08-11 11:47:02.000000000 +0200
@@ -502,7 +502,6 @@ execute_one_pass (struct tree_opt_pass *
   /* If a dump file name is present, open it if enabled.  */
   if (pass->static_pass_number != -1)
     {
-      bool initializing_dump = !dump_initialized_p (pass->static_pass_number);
       dump_file_name = get_dump_file_name (pass->static_pass_number);
       dump_file = dump_begin (pass->static_pass_number, &dump_flags);
       if (dump_file)
@@ -518,12 +517,6 @@ execute_one_pass (struct tree_opt_pass *
              ? " (unlikely executed)"
              : "");
 	}
-
-      if (initializing_dump
-          && graph_dump_format != no_graph
-	  && (pass->properties_provided & (PROP_cfg | PROP_rtl))
-	      == (PROP_cfg | PROP_rtl))
-        clean_graph_dump_file (dump_file_name);
     }
 
   /* If a timevar is present, start it.  */


More information about the Gcc-patches mailing list