[tree-ssa] Illegible dumps with dump_cfg_function_to_file

Zdenek Dvorak rakdver@atrey.karlin.mff.cuni.cz
Sat Nov 8 14:05:00 GMT 2003


Hello,

> > I have sent a fix for this together with the cfg-aware
> > remove_useless_... patch (I may send it as a separate patch if you
> > prefer).
> > 
> Yes, please.  One functionality change per-patch.  It's easier to review
> that way.

here is the patch that makes the ordering of blocks and the code the
same, and adds a check to verify_flow_info to ensure this.

Zdenek

	* basic-block.h (create_bb): Declaration changed.
	* tree-cfg.c (create_bb): Enable creating a block on specified place.
	(make_blocks, tree_split_edge, tree_make_forwarder_block): Use it.
	(tree_verify_flow_info): Check bbs are in the correct order.

Index: basic-block.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/basic-block.h,v
retrieving revision 1.153.2.32
diff -c -3 -p -r1.153.2.32 basic-block.h
*** basic-block.h	1 Nov 2003 20:27:15 -0000	1.153.2.32
--- basic-block.h	6 Nov 2003 17:21:39 -0000
*************** extern void dump_edge_info (FILE *, edge
*** 384,390 ****
  extern void clear_edges (void);
  extern void mark_critical_edges (void);
  extern rtx first_insn_after_basic_block_note (basic_block);
! extern basic_block create_bb (void);
  
  /* Dominator information for basic blocks.  */
  
--- 384,390 ----
  extern void clear_edges (void);
  extern void mark_critical_edges (void);
  extern rtx first_insn_after_basic_block_note (basic_block);
! extern basic_block create_bb (basic_block);
  
  /* Dominator information for basic blocks.  */
  
Index: tree-cfg.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-cfg.c,v
retrieving revision 1.1.4.196
diff -c -3 -p -r1.1.4.196 tree-cfg.c
*** tree-cfg.c	6 Nov 2003 15:32:41 -0000	1.1.4.196
--- tree-cfg.c	6 Nov 2003 17:21:40 -0000
*************** make_blocks (tree *first_p, basic_block 
*** 431,437 ****
  	 so now.  */
        if (start_new_block || stmt_starts_bb_p (stmt, prev_stmt))
  	{
! 	  bb = create_bb ();
  	  start_new_block = false;
  	}
  
--- 431,437 ----
  	 so now.  */
        if (start_new_block || stmt_starts_bb_p (stmt, prev_stmt))
  	{
! 	  bb = create_bb (NULL);
  	  start_new_block = false;
  	}
  
*************** prepend_stmt_to_bb (tree *stmt_p, basic_
*** 493,502 ****
  }
  
  
! /* Create and return a new basic block.  */
  
  basic_block
! create_bb (void)
  {
    basic_block bb;
  
--- 493,502 ----
  }
  
  
! /* Create and return a new basic block after bb AFTER.  */
  
  basic_block
! create_bb (basic_block after)
  {
    basic_block bb;
  
*************** create_bb (void)
*** 508,517 ****
    bb->flags = BB_NEW;
  
    /* Add the new block to the linked list of blocks.  */
!   if (n_basic_blocks > 0)
!     link_block (bb, BASIC_BLOCK (n_basic_blocks - 1));
!   else
!     link_block (bb, ENTRY_BLOCK_PTR);
  
    /* Grow the basic block array if needed.  */
    if ((size_t) n_basic_blocks == VARRAY_SIZE (basic_block_info))
--- 508,516 ----
    bb->flags = BB_NEW;
  
    /* Add the new block to the linked list of blocks.  */
!   if (!after)
!     after = EXIT_BLOCK_PTR->prev_bb;
!   link_block (bb, after);
  
    /* Grow the basic block array if needed.  */
    if ((size_t) n_basic_blocks == VARRAY_SIZE (basic_block_info))
*************** tree_split_edge (edge edge_in)
*** 3454,3460 ****
      abort ();
  
    dest = edge_in->dest;
!   new_bb = create_bb ();
    create_block_annotation (new_bb);
    redirect_edge_succ  (edge_in, new_bb);
    new_edge = make_edge (new_bb, dest, 0);
--- 3598,3604 ----
      abort ();
  
    dest = edge_in->dest;
!   new_bb = create_bb (edge_in->src);
    create_block_annotation (new_bb);
    redirect_edge_succ  (edge_in, new_bb);
    new_edge = make_edge (new_bb, dest, 0);
*************** static int
*** 3482,3490 ****
  tree_verify_flow_info (void)
  {
    int err = 0;
!   basic_block bb;
    block_stmt_iterator bsi;
    tree stmt;
  
    FOR_EACH_BB (bb)
      {
--- 3626,3635 ----
  tree_verify_flow_info (void)
  {
    int err = 0;
!   basic_block bb, abb;
    block_stmt_iterator bsi;
    tree stmt;
+   tree_stmt_iterator tsi;
  
    FOR_EACH_BB (bb)
      {
*************** tree_verify_flow_info (void)
*** 3508,3513 ****
--- 3653,3686 ----
  	}
      }
  
+   /* Check that order of basic blocks is the same as the order of code.  */
+   bb = ENTRY_BLOCK_PTR->next_bb;
+   if (bb == EXIT_BLOCK_PTR
+       || !bb->head_tree_p)
+     return err;
+ 
+   for (tsi = tsi_start (bb->head_tree_p); !tsi_end_p (tsi); tsi_next (&tsi))
+     {
+       if (IS_EMPTY_STMT (tsi_stmt (tsi)))
+ 	continue;
+  
+       abb = bb_for_stmt (tsi_stmt (tsi));
+       if (!abb)
+ 	continue;
+ 
+       if (abb != bb)
+ 	{
+ 	  if (abb != bb->next_bb)
+ 	    {
+ 	      fprintf (stderr, "Block missordering after bb %d\n",
+ 		       bb->index);
+ 	      err = 1;
+ 	    }
+ 
+ 	  bb = abb;
+ 	}
+     }
+ 
    return err;
  }
  
*************** tree_make_forwarder_block (basic_block b
*** 3526,3532 ****
    basic_block dummy;
  
    /* Create the new basic block.  */
!   dummy = create_bb ();
    create_block_annotation (dummy);
    dummy->count = bb->count;
    dummy->frequency = bb->frequency;
--- 3699,3705 ----
    basic_block dummy;
  
    /* Create the new basic block.  */
!   dummy = create_bb (NULL);
    create_block_annotation (dummy);
    dummy->count = bb->count;
    dummy->frequency = bb->frequency;



More information about the Gcc-patches mailing list