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]

verify_flow_info improvements



Hi,
this patch adds some extra sanity checks to verify_flow_info.

bootstrapped/regtested i386; depends on previous changes.

*** cfgrtl.c.old2	Sun Mar  3 15:31:10 2002
--- cfgrtl.c	Sun Mar  3 19:07:52 2002
*************** verify_flow_info ()
*** 1649,1655 ****
    for (i = n_basic_blocks - 1; i >= 0; i--)
      {
        basic_block bb = BASIC_BLOCK (i);
!       int has_fallthru = 0;
        edge e;
  
        for (e = bb->succ; e; e = e->succ_next)
--- 1687,1693 ----
    for (i = n_basic_blocks - 1; i >= 0; i--)
      {
        basic_block bb = BASIC_BLOCK (i);
!       int n_fallthru = 0, n_eh = 0, n_call = 0, n_abnormal = 0, n_branch = 0;
        edge e;
  
        for (e = bb->succ; e; e = e->succ_next)
*************** verify_flow_info ()
*** 1664,1670 ****
  	  last_visited [e->dest->index + 2] = bb;
  
  	  if (e->flags & EDGE_FALLTHRU)
! 	    has_fallthru = 1;
  
  	  if ((e->flags & EDGE_FALLTHRU)
  	      && e->src != ENTRY_BLOCK_PTR
--- 1702,1719 ----
  	  last_visited [e->dest->index + 2] = bb;
  
  	  if (e->flags & EDGE_FALLTHRU)
! 	    n_fallthru++;
! 
! 	  if ((e->flags & ~EDGE_DFS_BACK) == 0)
! 	    n_branch++;
! 
! 	  if (e->flags & EDGE_ABNORMAL_CALL)
! 	    n_call++;
! 
! 	  if (e->flags & EDGE_EH)
! 	    n_eh++;
! 	  else if (e->flags & EDGE_ABNORMAL)
! 	    n_abnormal++;
  
  	  if ((e->flags & EDGE_FALLTHRU)
  	      && e->src != ENTRY_BLOCK_PTR
*************** verify_flow_info ()
*** 1712,1718 ****
  	  edge_checksum[e->dest->index + 2] += (size_t) e;
  	}
  
!       if (!has_fallthru)
  	{
  	  rtx insn;
  
--- 1761,1811 ----
  	  edge_checksum[e->dest->index + 2] += (size_t) e;
  	}
  
!       if (n_eh && !find_reg_note (bb->end, REG_EH_REGION, NULL_RTX))
! 	{
! 	  error ("Missing REG_EH_REGION note in the end of bb %i", bb->index);
! 	  err = 1;
! 	}
!       if (n_branch
! 	  && (GET_CODE (bb->end) != JUMP_INSN
! 	      || (n_branch > 1 && (any_uncondjump_p (bb->end)
! 				   || any_condjump_p (bb->end)))))
! 	{
! 	  error ("Too many outgoing branch edges from bb %i", bb->index);
! 	  err = 1;
! 	}
!       if (n_fallthru && any_uncondjump_p (bb->end))
! 	{
! 	  error ("Fallthru edge after unconditional jump %i", bb->index);
! 	  err = 1;
! 	}
!       if (n_branch != 1 && any_uncondjump_p (bb->end))
! 	{
! 	  error ("Wrong amount of branch edges after unconditional jump %i", bb->index);
! 	  err = 1;
! 	}
!       if (n_branch != 1 && any_condjump_p (bb->end)
! 	  && JUMP_LABEL (bb->end) != BASIC_BLOCK (bb->index + 1)->head)
! 	{
! 	  error ("Wrong amount of branch edges after conditional jump %i", bb->index);
! 	  err = 1;
! 	}
!       if (n_call && GET_CODE (bb->end) != CALL_INSN)
! 	{
! 	  error ("Call edges for non-call insn in bb %i", bb->index);
! 	  err = 1;
! 	}
!       if (n_abnormal
! 	  && (GET_CODE (bb->end) != CALL_INSN && n_call != n_abnormal)
! 	  && (GET_CODE (bb->end) != JUMP_INSN
! 	      || any_condjump_p (bb->end)
! 	      || any_uncondjump_p (bb->end)))
! 	{
! 	  error ("Abnormal edges for no purpose in bb %i", bb->index);
! 	  err = 1;
! 	}
! 	
!       if (!n_fallthru)
  	{
  	  rtx insn;
  


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