Duplicated edges again

Jan Hubicka jh@suse.cz
Tue Jul 24 14:00:00 GMT 2001


Hi,
I've added code to check for duplicated edges in verify_flow_info and found
another place we create them - try_simplify_condjump.  This also didn't
trigger previously, as the degenerated condjumps has been removed by
try_forward_edges, but still we need to handle them properly for machines
with condjumps with sideeffects.

Bootstrapping of i686 finished/regtesting in progress.  OK assuming it passes?
Honza

Út čec 24 22:35:47 CEST 2001  Jan Hubicka  <jh@suse.cz>

	* flow.c (try_simplify_condjump): Avoid duplicated edges.
	(verify_flow_info): Check for duplicated edges; clarify
	error reporting.

*** flow.c.cfg	Tue Jul 24 21:30:47 2001
--- flow.c	Tue Jul 24 22:34:05 2001
*************** try_simplify_condjump (cbranch_block)
*** 3059,3065 ****
  
    /* Success.  Update the CFG to match.  */
!   redirect_edge_succ (cbranch_jump_edge, cbranch_dest_block);
!   redirect_edge_succ (cbranch_fallthru_edge, jump_dest_block);
    cbranch_jump_edge->flags |= EDGE_FALLTHRU;
    cbranch_fallthru_edge->flags &= ~EDGE_FALLTHRU;
    
--- 3059,3065 ----
  
    /* Success.  Update the CFG to match.  */
!   redirect_edge_succ_nodup (cbranch_jump_edge, cbranch_dest_block);
!   redirect_edge_succ_nodup (cbranch_fallthru_edge, jump_dest_block);
    cbranch_jump_edge->flags |= EDGE_FALLTHRU;
    cbranch_fallthru_edge->flags &= ~EDGE_FALLTHRU;
    
*************** verify_flow_info ()
*** 7954,7964 ****
    const int max_uid = get_max_uid ();
    const rtx rtx_first = get_insns ();
    rtx last_head = get_last_insn ();
!   basic_block *bb_info;
    rtx x;
    int i, last_bb_num_seen, num_bb_notes, err = 0;
  
    bb_info = (basic_block *) xcalloc (max_uid, sizeof (basic_block));
  
    for (i = n_basic_blocks - 1; i >= 0; i--)
      {
--- 7954,7966 ----
    const int max_uid = get_max_uid ();
    const rtx rtx_first = get_insns ();
    rtx last_head = get_last_insn ();
!   basic_block *bb_info, *last_visited;
    rtx x;
    int i, last_bb_num_seen, num_bb_notes, err = 0;
  
    bb_info = (basic_block *) xcalloc (max_uid, sizeof (basic_block));
+   last_visited = (basic_block *) xcalloc (n_basic_blocks + 2,
+ 					  sizeof (basic_block));
  
    for (i = n_basic_blocks - 1; i >= 0; i--)
      {
*************** verify_flow_info ()
*** 8015,8020 ****
--- 8017,8030 ----
        e = bb->succ;
        while (e)
  	{
+ 	  if (last_visited [e->dest->index + 2] == bb)
+ 	    {
+ 	      error ("verify_flow_info: Duplicate edge %i->%i",
+ 		     e->src->index, e->dest->index);
+ 	      err = 1;
+ 	    }
+ 	  last_visited [e->dest->index + 2] = bb;
+ 
  	  if ((e->flags & EDGE_FALLTHRU)
  	      && e->src != ENTRY_BLOCK_PTR
  	      && e->dest != EXIT_BLOCK_PTR
*************** verify_flow_info ()
*** 8141,8148 ****
  	  basic_block bb = NOTE_BASIC_BLOCK (x);
  	  num_bb_notes++;
  	  if (bb->index != last_bb_num_seen + 1)
! 	    /* Basic blocks not numbered consecutively.  */
! 	    abort ();
  	       
  	  last_bb_num_seen = bb->index;
  	}
--- 8151,8157 ----
  	  basic_block bb = NOTE_BASIC_BLOCK (x);
  	  num_bb_notes++;
  	  if (bb->index != last_bb_num_seen + 1)
! 	    internal_error ("Basic blocks not numbered consecutively.");
  	       
  	  last_bb_num_seen = bb->index;
  	}
*************** verify_flow_info ()
*** 8188,8197 ****
         num_bb_notes, n_basic_blocks);
  
    if (err)
!     abort ();
  
    /* Clean up.  */
    free (bb_info);
  }
  
  /* Functions to access an edge list with a vector representation.
--- 8197,8207 ----
         num_bb_notes, n_basic_blocks);
  
    if (err)
!     internal_error ("verify_flow_info failed.");
  
    /* Clean up.  */
    free (bb_info);
+   free (last_visited);
  }
  
  /* Functions to access an edge list with a vector representation.



More information about the Gcc-patches mailing list