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: [tree-ssa] Illegible dumps with dump_cfg_function_to_file


Hello,

> You introduced dump_cfg_function_to_file recently.  The output we get
> from it is quite bad: lines are not indented and strange numbers are
> intermixed with code.

this patch should make the dumps more readable.

Zdenek

	* tree-cfg.c (tree_dump_bb): Don't check for BIND_EXPR.
	(dump_cfg_function_to_file): Use print_bb.
	* tree-flow.h (print_bb): Declare.
	* tree-pretty-print.c (dump_vops): Don't dump phi nodes when not asked
	to.
	(print_bb): New.
	(dump_generic_node): Ask for phi node dumps only with TDF_BLOCKS flag.

Index: tree-cfg.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-cfg.c,v
retrieving revision 1.1.4.198
diff -c -3 -p -r1.1.4.198 tree-cfg.c
*** tree-cfg.c	7 Nov 2003 08:36:06 -0000	1.1.4.198
--- tree-cfg.c	7 Nov 2003 10:49:04 -0000
*************** tree_dump_bb (basic_block bb, FILE *outf
*** 2019,2028 ****
    for (si = bsi_start (bb); !bsi_end_p (si); bsi_next (&si))
      {
        fprintf (outf, "%s%d  ", s_indent, get_lineno (bsi_stmt (si)));
!       print_generic_stmt (outf, bsi_stmt (si),
! 			  (TREE_CODE (bsi_stmt (si)) == BIND_EXPR
! 			   ? TDF_SLIM
! 			   : 0));
      }
  }
  
--- 2163,2169 ----
    for (si = bsi_start (bb); !bsi_end_p (si); bsi_next (&si))
      {
        fprintf (outf, "%s%d  ", s_indent, get_lineno (bsi_stmt (si)));
!       print_generic_stmt (outf, bsi_stmt (si), 0);
      }
  }
  
*************** void
*** 2097,2104 ****
  dump_cfg_function_to_file (tree fn, FILE *file, int flags)
  {
    basic_block bb;
!   tree arg, phi;
!   block_stmt_iterator si;
    edge e;
    int show_bb_headers = flags & TDF_BLOCKS;
  
--- 2238,2244 ----
  dump_cfg_function_to_file (tree fn, FILE *file, int flags)
  {
    basic_block bb;
!   tree arg;
    edge e;
    int show_bb_headers = flags & TDF_BLOCKS;
  
*************** dump_cfg_function_to_file (tree fn, FILE
*** 2140,2158 ****
  	    dump_edge_info (file, e, 0);
  	  putc ('\n', file);
  	}
-       for (phi = phi_nodes (bb); phi; phi = TREE_CHAIN (phi))
- 	{
- 	  fprintf (file, "\t# ");
- 	  print_generic_stmt (file, phi, flags);
- 	  fprintf (file, "\n");
- 	}
  
!       for (si = bsi_start (bb); !bsi_end_p (si); bsi_next (&si))
! 	{
! 	  fprintf (file, "%d\t", get_lineno (bsi_stmt (si)));
! 	  print_generic_stmt (file, bsi_stmt (si), flags);
! 	  fprintf (file, "\n");
! 	}
  
        if (show_bb_headers)
  	{
--- 2280,2287 ----
  	    dump_edge_info (file, e, 0);
  	  putc ('\n', file);
  	}
  
!       print_bb (file, bb, flags);
  
        if (show_bb_headers)
  	{
Index: tree-flow.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-flow.h,v
retrieving revision 1.1.4.141
diff -c -3 -p -r1.1.4.141 tree-flow.h
*** tree-flow.h	5 Nov 2003 13:39:23 -0000	1.1.4.141
--- tree-flow.h	7 Nov 2003 10:49:04 -0000
*************** extern bool tree_can_throw_external (tre
*** 565,570 ****
--- 566,574 ----
  
  /* In gimple-low.c  */
  void lower_function_body (tree *);
+ 
+ /* In tree-pretty-print.c  */
+ void print_bb (FILE *, basic_block, int);
  
  #include "tree-flow-inline.h"
  
Index: tree-pretty-print.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-pretty-print.c,v
retrieving revision 1.1.2.56
diff -c -3 -p -r1.1.2.56 tree-pretty-print.c
*** tree-pretty-print.c	5 Nov 2003 16:28:10 -0000	1.1.2.56
--- tree-pretty-print.c	7 Nov 2003 10:49:04 -0000
*************** static void print_declaration (pretty_pr
*** 43,49 ****
  static void print_struct_decl (pretty_printer *, tree, int);
  static void dump_block_info (pretty_printer *, basic_block, int, int);
  static void do_niy (pretty_printer *, tree);
! static void dump_vops (pretty_printer *, tree, int);
  
  #define INDENT(SPACE) do { \
    int i; for (i = 0; i<SPACE; i++) pp_space (buffer); } while (0)
--- 43,49 ----
  static void print_struct_decl (pretty_printer *, tree, int);
  static void dump_block_info (pretty_printer *, basic_block, int, int);
  static void do_niy (pretty_printer *, tree);
! static void dump_vops (pretty_printer *, tree, int, bool);
  
  #define INDENT(SPACE) do { \
    int i; for (i = 0; i<SPACE; i++) pp_space (buffer); } while (0)
*************** debug_generic_stmt (tree t)
*** 99,104 ****
--- 99,133 ----
    fprintf (stderr, "\n");
  }
  
+ /* Prints basic block BB to FILE with details specified by FLAGS.  */
+ void
+ print_bb (FILE *file, basic_block bb, int flags)
+ {
+   block_stmt_iterator si;
+   tree phi;
+ 
+   maybe_init_pretty_print (file);
+   dumping_stmts = true;
+ 
+   if (phi_nodes (bb))
+     {
+       pp_string (&buffer, "  ");
+       for (phi = phi_nodes (bb); phi; phi = TREE_CHAIN (phi))
+ 	{
+ 	  dump_generic_node (&buffer, phi, 2, flags);
+ 	  newline_and_indent (&buffer, 2);
+ 	}
+       pp_newline (&buffer);
+     }
+ 
+   for (si = bsi_start (bb); !bsi_end_p (si); bsi_next (&si))
+     {
+       dump_generic_node (&buffer, bsi_stmt (si), 2, flags);
+       newline_and_indent (&buffer, 2);
+     }
+   pp_flush (&buffer);
+ }
+ 
  /* Prints declaration DECL to the FILE with details specified by FLAGS.  */
  void
  print_generic_decl (FILE *file, tree decl, int flags)
*************** print_generic_stmt (FILE *file, tree t, 
*** 121,127 ****
    pp_flush (&buffer);
  }
  
- 
  /* Print a single expression T on file FILE.  FLAGS specifies details to show
     in the dump.  See TDF_* in tree.h.  */
  
--- 150,155 ----
*************** dump_generic_node (pretty_printer *buffe
*** 157,163 ****
  	dump_block_info (buffer, curr_bb, spc, flags);
  
        if ((flags & TDF_VOPS) && stmt_ann (node))
! 	dump_vops (buffer, node, spc);
  
        if (curr_bb && curr_bb != last_bb)
  	last_bb = curr_bb;
--- 185,191 ----
  	dump_block_info (buffer, curr_bb, spc, flags);
  
        if ((flags & TDF_VOPS) && stmt_ann (node))
! 	dump_vops (buffer, node, spc, (flags & TDF_BLOCKS) != 0);
  
        if (curr_bb && curr_bb != last_bb)
  	last_bb = curr_bb;
*************** dump_block_info (pretty_printer *buffer,
*** 2032,2038 ****
  
  
  static void
! dump_vops (pretty_printer *buffer, tree stmt, int spc)
  {
    size_t i;
    basic_block bb;
--- 2060,2066 ----
  
  
  static void
! dump_vops (pretty_printer *buffer, tree stmt, int spc, bool dump_phis)
  {
    size_t i;
    basic_block bb;
*************** dump_vops (pretty_printer *buffer, tree 
*** 2041,2047 ****
    varray_type vuses = vuse_ops (ann);
  
    bb = bb_for_stmt (stmt);
!   if (bb && bb != last_bb && bb->tree_annotations)
      {
        tree phi;
  
--- 2069,2075 ----
    varray_type vuses = vuse_ops (ann);
  
    bb = bb_for_stmt (stmt);
!   if (dump_phis && bb && bb != last_bb && bb->tree_annotations)
      {
        tree phi;
  


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