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] Fix dominator bug


Hello,

this patch adds a test whether we do not forget to remove the basic
blocks from the dominance forest.  The Steven's patch (or at least
its subset included in the patch, since I don't really care about
updating postdominators) is of course neccesary to make it bootstrap.

Zdenek

	* dominance.c (n_bbs_in_dom_tree): New static variable.
	(calculate_dominance_info, free_dominance_info): Add tests using
	n_bbs_in_dom_tree.
	(add_to_dominance_info, delete_from_dominance_info): Update
	n_bbs_in_dom_tree.
	* tree-cfg.c (remove_bb): Remove the basic block from dominance
	forest.

Index: dominance.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/dominance.c,v
retrieving revision 1.10.2.12
diff -c -3 -p -r1.10.2.12 dominance.c
*** dominance.c	5 Jan 2004 08:00:14 -0000	1.10.2.12
--- dominance.c	8 Jan 2004 02:22:22 -0000
*************** static void link_roots (struct dom_info 
*** 118,123 ****
--- 118,126 ----
  static void calc_idoms (struct dom_info *, enum cdi_direction);
  void debug_dominance_info (enum cdi_direction);
  
+ /* Keeps track of the number of nodes in the dominance trees.  */
+ static unsigned n_bbs_in_dom_tree[2];
+ 
  /* Helper macro for allocating and initializing an array,
     for aesthetic reasons.  */
  #define init_ar(var, type, num, content)			\
*************** calculate_dominance_info (enum cdi_direc
*** 578,587 ****
--- 581,594 ----
        if (dom_computed[dir] != DOM_NONE)
  	free_dominance_info (dir);
  
+       if (n_bbs_in_dom_tree[dir])
+ 	abort ();
+ 
        FOR_ALL_BB (b)
  	{
  	  b->dom[dir] = et_new_tree (b);
  	}
+       n_bbs_in_dom_tree[dir] = n_basic_blocks + 2;
  
        init_dom_info (&di);
        calc_dfs_tree (&di, dir);
*************** free_dominance_info (enum cdi_direction 
*** 615,621 ****
      {
        delete_from_dominance_info (dir, bb);
      }
!   
    dom_computed[dir] = DOM_NONE;
  }
  
--- 622,632 ----
      {
        delete_from_dominance_info (dir, bb);
      }
! 
!   /* If there are any nodes left, something is wrong.  */
!   if (n_bbs_in_dom_tree[dir])
!     abort ();
! 
    dom_computed[dir] = DOM_NONE;
  }
  
*************** add_to_dominance_info (enum cdi_directio
*** 823,828 ****
--- 834,841 ----
  
    if (bb->dom[dir])
      abort ();
+ 
+   n_bbs_in_dom_tree[dir]++;
    
    bb->dom[dir] = et_new_tree (bb);
  
*************** delete_from_dominance_info (enum cdi_dir
*** 838,843 ****
--- 851,857 ----
  
    et_free_tree (bb->dom[dir]);
    bb->dom[dir] = NULL;
+   n_bbs_in_dom_tree[dir]--;
  
    if (dom_computed[dir] == DOM_OK)
      dom_computed[dir] = DOM_NO_FAST_QUERY;
Index: tree-cfg.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-cfg.c,v
retrieving revision 1.1.4.246
diff -c -3 -p -r1.1.4.246 tree-cfg.c
*** tree-cfg.c	6 Jan 2004 23:27:49 -0000	1.1.4.246
--- tree-cfg.c	8 Jan 2004 02:22:22 -0000
*************** remove_bb (basic_block bb)
*** 1433,1438 ****
--- 1433,1441 ----
  
    remove_phi_nodes_and_edges_for_unreachable_block (bb);
  
+   if (dom_computed[CDI_DOMINATORS])
+     delete_from_dominance_info (CDI_DOMINATORS, bb);
+ 
    /* Remove the basic block from the array.  */
    expunge_block (bb);
  }


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