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]

Cleanups for some cfg*.c files


This is similar to my last change to predict.c:

Sat Dec 22 08:59:50 2001  Richard Kenner  <kenner@vlsi1.ultra.nyu.edu>

	* cfg.c, cfganal.c, cfgbuild.c: Reformatting and minor cleanups.

*** cfg.c	2001/11/21 16:02:09	1.17
--- cfg.c	2001/12/22 15:10:07
*************** free_edge (e)
*** 153,157 ****
  {
    n_edges--;
!   memset (e, 0, sizeof (*e));
    e->succ_next = first_deleted_edge;
    first_deleted_edge = e;
--- 153,157 ----
  {
    n_edges--;
!   memset (e, 0, sizeof *e);
    e->succ_next = first_deleted_edge;
    first_deleted_edge = e;
*************** clear_edges ()
*** 178,181 ****
--- 178,182 ----
  	  e = next;
  	}
+ 
        bb->succ = NULL;
        bb->pred = NULL;
*************** clear_edges ()
*** 190,193 ****
--- 191,195 ----
        e = next;
      }
+ 
    EXIT_BLOCK_PTR->pred = NULL;
    ENTRY_BLOCK_PTR->succ = NULL;
*************** alloc_block ()
*** 212,217 ****
    else
      {
!       bb = (basic_block) obstack_alloc (&flow_obstack, sizeof (*bb));
!       memset (bb, 0, sizeof (*bb));
      }
    return bb;
--- 214,219 ----
    else
      {
!       bb = (basic_block) obstack_alloc (&flow_obstack, sizeof *bb);
!       memset (bb, 0, sizeof *bb);
      }
    return bb;
*************** expunge_block (b)
*** 234,238 ****
  
    /* Invalidate data to make bughunting easier.  */
!   memset (b, 0, sizeof (*b));
    b->index = -3;
    basic_block_info->num_elements--;
--- 236,240 ----
  
    /* Invalidate data to make bughunting easier.  */
!   memset (b, 0, sizeof *b);
    b->index = -3;
    basic_block_info->num_elements--;
*************** cached_make_edge (edge_cache, src, dst, 
*** 254,262 ****
    edge e;
  
!   /* Don't bother with edge cache for ENTRY or EXIT; there aren't that
!      many edges to them, and we didn't allocate memory for it.  */
    use_edge_cache = (edge_cache
! 		    && src != ENTRY_BLOCK_PTR
! 		    && dst != EXIT_BLOCK_PTR);
  
    /* Make sure we don't add duplicate edges.  */
--- 256,263 ----
    edge e;
  
!   /* Don't bother with edge cache for ENTRY or EXIT, if there aren't that
!      many edges to them, or we didn't allocate memory for it.  */
    use_edge_cache = (edge_cache
! 		    && src != ENTRY_BLOCK_PTR && dst != EXIT_BLOCK_PTR);
  
    /* Make sure we don't add duplicate edges.  */
*************** cached_make_edge (edge_cache, src, dst, 
*** 290,295 ****
    else
      {
!       e = (edge) obstack_alloc (&flow_obstack, sizeof (*e));
!       memset (e, 0, sizeof (*e));
      }
    n_edges++;
--- 291,296 ----
    else
      {
!       e = (edge) obstack_alloc (&flow_obstack, sizeof *e);
!       memset (e, 0, sizeof *e);
      }
    n_edges++;
*************** remove_edge (e)
*** 346,349 ****
--- 347,351 ----
    edge tmp;
    basic_block src, dest;
+ 
    src = e->src;
    dest = e->dest;
*************** redirect_edge_succ_nodup (e, new_succ)
*** 399,406 ****
--- 401,410 ----
  {
    edge s;
+ 
    /* Check whether the edge is already present.  */
    for (s = e->src->succ; s; s = s->succ_next)
      if (s->dest == new_succ && s != e)
        break;
+ 
    if (s)
      {
*************** redirect_edge_succ_nodup (e, new_succ)
*** 413,416 ****
--- 417,421 ----
    else
      redirect_edge_succ (e, new_succ);
+ 
    return e;
  }
*************** redirect_edge_pred (e, new_pred)
*** 428,431 ****
--- 433,437 ----
    for (pe = &e->src->succ; *pe != e; pe = &(*pe)->succ_next)
      continue;
+ 
    *pe = (*pe)->succ_next;
  
*************** dump_flow_info (file)
*** 448,451 ****
--- 454,458 ----
        {
  	enum reg_class class, altclass;
+ 
  	fprintf (file, "\nRegister %d used %d times across %d insns",
  		 i, REG_N_REFS (i), REG_LIVE_LENGTH (i));
*************** dump_flow_info (file)
*** 465,468 ****
--- 472,476 ----
  	if (PSEUDO_REGNO_BYTES (i) != UNITS_PER_WORD)
  	  fprintf (file, "; %d bytes", PSEUDO_REGNO_BYTES (i));
+ 
  	class = reg_preferred_class (i);
  	altclass = reg_alternate_class (i);
*************** dump_flow_info (file)
*** 478,481 ****
--- 486,490 ----
  		       reg_class_names[(int) altclass]);
  	  }
+ 
  	if (REG_POINTER (regno_reg_rtx[i]))
  	  fprintf (file, "; pointer");
*************** dump_flow_info (file)
*** 489,495 ****
        edge e;
  
!       fprintf (file, "\nBasic block %d: first insn %d, last %d, loop_depth %d, count ",
! 	       i, INSN_UID (bb->head), INSN_UID (bb->end), bb->loop_depth);
!       fprintf (file, HOST_WIDEST_INT_PRINT_DEC, (HOST_WIDEST_INT) bb->count);
        fprintf (file, ", freq %i.\n", bb->frequency);
  
--- 498,505 ----
        edge e;
  
!       fprintf (file, "\nBasic block %d: first insn %d, last %d, ",
! 	       i, INSN_UID (bb->head), INSN_UID (bb->end));
!       fprintf (file, "loop_depth %d, count ", bb->loop_depth);
!       fprintf (file, HOST_WIDEST_INT_PRINT_DEC, bb->count);
        fprintf (file, ", freq %i.\n", bb->frequency);
  
*************** dump_edge_info (file, e, do_succ)
*** 541,557 ****
      {
        fprintf (file, " count:");
!       fprintf (file, HOST_WIDEST_INT_PRINT_DEC, (HOST_WIDEST_INT) e->count);
      }
  
    if (e->flags)
      {
!       static const char * const bitnames[] = {
! 	"fallthru", "ab", "abcall", "eh", "fake", "dfs_back"
!       };
        int comma = 0;
        int i, flags = e->flags;
  
!       fputc (' ', file);
!       fputc ('(', file);
        for (i = 0; flags; i++)
  	if (flags & (1 << i))
--- 551,565 ----
      {
        fprintf (file, " count:");
!       fprintf (file, HOST_WIDEST_INT_PRINT_DEC, e->count);
      }
  
    if (e->flags)
      {
!       static const char * const bitnames[]
! 	= {"fallthru", "ab", "abcall", "eh", "fake", "dfs_back"};
        int comma = 0;
        int i, flags = e->flags;
  
!       fputs (" (", file);
        for (i = 0; flags; i++)
  	if (flags & (1 << i))
*************** dump_edge_info (file, e, do_succ)
*** 567,570 ****
--- 575,579 ----
  	    comma = 1;
  	  }
+ 
        fputc (')', file);
      }
*************** dump_edge_info (file, e, do_succ)
*** 572,575 ****
--- 581,585 ----
  
  /* Simple routines to easily allocate AUX fields of basic blocks.  */
+ 
  static struct obstack block_aux_obstack;
  static void *first_block_aux_obj = 0;
*************** alloc_aux_for_blocks (size)
*** 606,609 ****
--- 616,620 ----
        initialized = 1;
      }
+ 
    /* Check whether AUX data are still allocated.  */
    else if (first_block_aux_obj)
*************** alloc_aux_for_blocks (size)
*** 613,618 ****
--- 624,631 ----
      {
        int i;
+ 
        for (i = 0; i < n_basic_blocks; i++)
  	alloc_aux_for_block (BASIC_BLOCK (i), size);
+ 
        alloc_aux_for_block (ENTRY_BLOCK_PTR, size);
        alloc_aux_for_block (EXIT_BLOCK_PTR, size);
*************** clear_aux_for_blocks ()
*** 629,632 ****
--- 642,646 ----
    for (i = 0; i < n_basic_blocks; i++)
      BASIC_BLOCK (i)->aux = NULL;
+ 
    ENTRY_BLOCK_PTR->aux = NULL;
    EXIT_BLOCK_PTR->aux = NULL;
*************** alloc_aux_for_edges (size)
*** 676,682 ****
--- 690,698 ----
        initialized = 1;
      }
+ 
    /* Check whether AUX data are still allocated.  */
    else if (first_edge_aux_obj)
      abort ();
+ 
    first_edge_aux_obj = (char *) obstack_alloc (&edge_aux_obstack, 0);
    if (size)
*************** alloc_aux_for_edges (size)
*** 692,695 ****
--- 708,712 ----
  	  else
  	    bb = ENTRY_BLOCK_PTR;
+ 
  	  for (e = bb->succ; e; e = e->succ_next)
  	    alloc_aux_for_edge (e, size);
*************** clear_aux_for_edges ()
*** 714,717 ****
--- 731,735 ----
        else
  	bb = ENTRY_BLOCK_PTR;
+ 
        for (e = bb->succ; e; e = e->succ_next)
  	e->aux = NULL;
*** cfganal.c	2001/12/12 05:01:32	1.9
--- cfganal.c	2001/12/22 15:10:11
*************** static bool need_fake_edge_p		PARAMS ((r
*** 57,75 ****
  /* Return true if the block has no effect and only forwards control flow to
     its single destination.  */
  bool
  forwarder_block_p (bb)
       basic_block bb;
  {
!   rtx insn = bb->head;
    if (bb == EXIT_BLOCK_PTR || bb == ENTRY_BLOCK_PTR
        || !bb->succ || bb->succ->succ_next)
      return false;
  
!   while (insn != bb->end)
!     {
!       if (INSN_P (insn) && active_insn_p (insn))
! 	return false;
!       insn = NEXT_INSN (insn);
!     }
    return (!INSN_P (insn)
  	  || (GET_CODE (insn) == JUMP_INSN && simplejump_p (insn))
--- 57,75 ----
  /* Return true if the block has no effect and only forwards control flow to
     its single destination.  */
+ 
  bool
  forwarder_block_p (bb)
       basic_block bb;
  {
!   rtx insn;
! 
    if (bb == EXIT_BLOCK_PTR || bb == ENTRY_BLOCK_PTR
        || !bb->succ || bb->succ->succ_next)
      return false;
  
!   for (insn = bb->head; insn != bb->end; insn = NEXT_INSN (insn))
!     if (INSN_P (insn) && active_insn_p (insn))
!       return false;
! 
    return (!INSN_P (insn)
  	  || (GET_CODE (insn) == JUMP_INSN && simplejump_p (insn))
*************** forwarder_block_p (bb)
*** 78,81 ****
--- 78,82 ----
  
  /* Return nonzero if we can reach target from src by falling through.  */
+ 
  bool
  can_fallthru (src, target)
*************** can_fallthru (src, target)
*** 87,90 ****
--- 88,92 ----
    if (src->index + 1 == target->index && !active_insn_p (insn2))
      insn2 = next_active_insn (insn2);
+ 
    /* ??? Later we may add code to move jump tables offline.  */
    return next_active_insn (insn) == insn2;
*************** mark_dfs_back_edges ()
*** 149,153 ****
  
  	  pre[dest->index] = prenum++;
- 
  	  if (dest->succ)
  	    {
--- 151,154 ----
*************** flow_call_edges_add (blocks)
*** 236,250 ****
        for (i = 0; i < n_basic_blocks; i++)
  	bbs[bb_num++] = BASIC_BLOCK (i);
        check_last_block = true;
      }
    else
!     {
!       EXECUTE_IF_SET_IN_SBITMAP (blocks, 0, i,
!       {
! 	bbs[bb_num++] = BASIC_BLOCK (i);
! 	if (i == n_basic_blocks - 1)
! 	  check_last_block = true;
!       });
!     }
  
    /* In the last basic block, before epilogue generation, there will be
--- 237,251 ----
        for (i = 0; i < n_basic_blocks; i++)
  	bbs[bb_num++] = BASIC_BLOCK (i);
+ 
        check_last_block = true;
      }
+ 
    else
!     EXECUTE_IF_SET_IN_SBITMAP (blocks, 0, i,
! 			       {
! 				 bbs[bb_num++] = BASIC_BLOCK (i);
! 				 if (i == n_basic_blocks - 1)
! 				   check_last_block = true;
! 			       });
  
    /* In the last basic block, before epilogue generation, there will be
*************** flow_call_edges_add (blocks)
*** 264,275 ****
      {
         edge e;
         for (e = BASIC_BLOCK (n_basic_blocks - 1)->succ; e; e = e->succ_next)
  	 if (e->dest == EXIT_BLOCK_PTR)
  	    break;
         insert_insn_on_edge (gen_rtx_USE (VOIDmode, const0_rtx), e);
         commit_edge_insertions ();
      }
  
- 
    /* Now add fake edges to the function exit for any non constant
       calls since there is no way that we can determine if they will
--- 265,277 ----
      {
         edge e;
+ 
         for (e = BASIC_BLOCK (n_basic_blocks - 1)->succ; e; e = e->succ_next)
  	 if (e->dest == EXIT_BLOCK_PTR)
  	    break;
+ 
         insert_insn_on_edge (gen_rtx_USE (VOIDmode, const0_rtx), e);
         commit_edge_insertions ();
      }
  
    /* Now add fake edges to the function exit for any non constant
       calls since there is no way that we can determine if they will
*************** flow_call_edges_add (blocks)
*** 290,296 ****
  
  	      /* The above condition should be enough to verify that there is
! 		 no edge to the exit block in CFG already.  Calling make_edge in
! 		 such case would make us to mark that edge as fake and remove it
! 		 later.  */
  #ifdef ENABLE_CHECKING
  	      if (insn == bb->end)
--- 292,299 ----
  
  	      /* The above condition should be enough to verify that there is
! 		 no edge to the exit block in CFG already.  Calling make_edge
! 		 in such case would make us to mark that edge as fake and
! 		 remove it later.  */
! 
  #ifdef ENABLE_CHECKING
  	      if (insn == bb->end)
*************** flow_call_edges_add (blocks)
*** 308,311 ****
--- 311,315 ----
  	      make_edge (bb, EXIT_BLOCK_PTR, EDGE_FAKE);
  	    }
+ 
  	  if (insn == bb->head)
  	    break;
*************** flow_call_edges_add (blocks)
*** 319,322 ****
--- 323,327 ----
    return blocks_split;
  }
+ 
  /* Find unreachable blocks.  An unreachable block will have 0 in
     the reachable bit in block->flags.  A non-zero value indicates the
*************** create_edge_list ()
*** 402,405 ****
--- 407,411 ----
  	num_edges++;
      }
+ 
    /* Don't forget successors of the entry block.  */
    for (e = ENTRY_BLOCK_PTR->succ; e; e = e->succ_next)
*************** create_edge_list ()
*** 415,422 ****
    /* Follow successors of the entry block, and register these edges.  */
    for (e = ENTRY_BLOCK_PTR->succ; e; e = e->succ_next)
!     {
!       elist->index_to_edge[num_edges] = e;
!       num_edges++;
!     }
  
    for (x = 0; x < n_basic_blocks; x++)
--- 421,425 ----
    /* Follow successors of the entry block, and register these edges.  */
    for (e = ENTRY_BLOCK_PTR->succ; e; e = e->succ_next)
!     elist->index_to_edge[num_edges++] = e;
  
    for (x = 0; x < n_basic_blocks; x++)
*************** create_edge_list ()
*** 426,434 ****
        /* Follow all successors of blocks, and register these edges.  */
        for (e = bb->succ; e; e = e->succ_next)
! 	{
! 	  elist->index_to_edge[num_edges] = e;
! 	  num_edges++;
! 	}
      }
    return elist;
  }
--- 429,435 ----
        /* Follow all successors of blocks, and register these edges.  */
        for (e = bb->succ; e; e = e->succ_next)
! 	elist->index_to_edge[num_edges++] = e;
      }
+ 
    return elist;
  }
*************** print_edge_list (f, elist)
*** 455,458 ****
--- 456,460 ----
  {
    int x;
+ 
    fprintf (f, "Compressed edge list, %d BBs + entry & exit, and %d edges\n",
  	   elist->num_blocks - 2, elist->num_edges);
*************** verify_edge_list (f, elist)
*** 499,502 ****
--- 501,505 ----
  	      continue;
  	    }
+ 
  	  if (INDEX_EDGE_PRED_BB (elist, index)->index != pred)
  	    fprintf (f, "*p* Pred for index %d should be %d not %d\n",
*************** verify_edge_list (f, elist)
*** 507,510 ****
--- 510,514 ----
  	}
      }
+ 
    for (e = ENTRY_BLOCK_PTR->succ; e; e = e->succ_next)
      {
*************** verify_edge_list (f, elist)
*** 517,520 ****
--- 521,525 ----
  	  continue;
  	}
+ 
        if (INDEX_EDGE_PRED_BB (elist, index)->index != pred)
  	fprintf (f, "*p* Pred for index %d should be %d not %d\n",
*************** verify_edge_list (f, elist)
*** 524,527 ****
--- 529,533 ----
  		 index, succ, INDEX_EDGE_SUCC_BB (elist, index)->index);
      }
+ 
    /* We've verified that all the edges are in the list, no lets make sure
       there are no spurious edges in the list.  */
*************** verify_edge_list (f, elist)
*** 532,536 ****
  	basic_block p = BASIC_BLOCK (pred);
  	basic_block s = BASIC_BLOCK (succ);
- 
  	int found_edge = 0;
  
--- 538,541 ----
*************** verify_edge_list (f, elist)
*** 541,544 ****
--- 546,550 ----
  	      break;
  	    }
+ 
  	for (e = s->pred; e; e = e->pred_next)
  	  if (e->src == p)
*************** verify_edge_list (f, elist)
*** 547,550 ****
--- 553,557 ----
  	      break;
  	    }
+ 
  	if (EDGE_INDEX (elist, BASIC_BLOCK (pred), BASIC_BLOCK (succ))
  	    == EDGE_INDEX_NO_EDGE && found_edge != 0)
*************** verify_edge_list (f, elist)
*** 557,565 ****
  					   BASIC_BLOCK (succ)));
        }
    for (succ = 0; succ < n_basic_blocks; succ++)
      {
        basic_block p = ENTRY_BLOCK_PTR;
        basic_block s = BASIC_BLOCK (succ);
- 
        int found_edge = 0;
  
--- 564,572 ----
  					   BASIC_BLOCK (succ)));
        }
+ 
    for (succ = 0; succ < n_basic_blocks; succ++)
      {
        basic_block p = ENTRY_BLOCK_PTR;
        basic_block s = BASIC_BLOCK (succ);
        int found_edge = 0;
  
*************** verify_edge_list (f, elist)
*** 570,573 ****
--- 577,581 ----
  	    break;
  	  }
+ 
        for (e = s->pred; e; e = e->pred_next)
  	if (e->src == p)
*************** verify_edge_list (f, elist)
*** 576,579 ****
--- 584,588 ----
  	    break;
  	  }
+ 
        if (EDGE_INDEX (elist, ENTRY_BLOCK_PTR, BASIC_BLOCK (succ))
  	  == EDGE_INDEX_NO_EDGE && found_edge != 0)
*************** verify_edge_list (f, elist)
*** 586,594 ****
  				   BASIC_BLOCK (succ)));
      }
    for (pred = 0; pred < n_basic_blocks; pred++)
      {
        basic_block p = BASIC_BLOCK (pred);
        basic_block s = EXIT_BLOCK_PTR;
- 
        int found_edge = 0;
  
--- 595,603 ----
  				   BASIC_BLOCK (succ)));
      }
+ 
    for (pred = 0; pred < n_basic_blocks; pred++)
      {
        basic_block p = BASIC_BLOCK (pred);
        basic_block s = EXIT_BLOCK_PTR;
        int found_edge = 0;
  
*************** verify_edge_list (f, elist)
*** 599,602 ****
--- 608,612 ----
  	    break;
  	  }
+ 
        for (e = s->pred; e; e = e->pred_next)
  	if (e->src == p)
*************** verify_edge_list (f, elist)
*** 605,608 ****
--- 615,619 ----
  	    break;
  	  }
+ 
        if (EDGE_INDEX (elist, BASIC_BLOCK (pred), EXIT_BLOCK_PTR)
  	  == EDGE_INDEX_NO_EDGE && found_edge != 0)
*************** find_edge_index (edge_list, pred, succ)
*** 626,635 ****
  {
    int x;
    for (x = 0; x < NUM_EDGES (edge_list); x++)
!     {
!       if (INDEX_EDGE_PRED_BB (edge_list, x) == pred
! 	  && INDEX_EDGE_SUCC_BB (edge_list, x) == succ)
! 	return x;
!     }
    return (EDGE_INDEX_NO_EDGE);
  }
--- 637,646 ----
  {
    int x;
+ 
    for (x = 0; x < NUM_EDGES (edge_list); x++)
!     if (INDEX_EDGE_PRED_BB (edge_list, x) == pred
! 	&& INDEX_EDGE_SUCC_BB (edge_list, x) == succ)
!       return x;
! 
    return (EDGE_INDEX_NO_EDGE);
  }
*************** flow_edge_list_print (str, edge_list, nu
*** 671,674 ****
--- 682,686 ----
      fprintf (file, "%d->%d ", edge_list[i]->src->index,
  	     edge_list[i]->dest->index);
+ 
    fputs ("}\n", file);
  }
*************** remove_fake_successors (bb)
*** 684,690 ****
--- 696,704 ----
  {
    edge e;
+ 
    for (e = bb->succ; e;)
      {
        edge tmp = e;
+ 
        e = e->succ_next;
        if ((tmp->flags & EDGE_FAKE) == EDGE_FAKE)
*************** connect_infinite_loops_to_exit ()
*** 738,746 ****
  {
    basic_block unvisited_block;
  
    /* Perform depth-first search in the reverse graph to find nodes
       reachable from the exit block.  */
-   struct depth_first_search_dsS dfs_ds;
- 
    flow_dfs_compute_reverse_init (&dfs_ds);
    flow_dfs_compute_reverse_add_bb (&dfs_ds, EXIT_BLOCK_PTR);
--- 752,759 ----
  {
    basic_block unvisited_block;
+   struct depth_first_search_dsS dfs_ds;
  
    /* Perform depth-first search in the reverse graph to find nodes
       reachable from the exit block.  */
    flow_dfs_compute_reverse_init (&dfs_ds);
    flow_dfs_compute_reverse_add_bb (&dfs_ds, EXIT_BLOCK_PTR);
*************** connect_infinite_loops_to_exit ()
*** 752,755 ****
--- 765,769 ----
        if (!unvisited_block)
  	break;
+ 
        make_edge (unvisited_block, EXIT_BLOCK_PTR, EDGE_FAKE);
        flow_dfs_compute_reverse_add_bb (&dfs_ds, unvisited_block);
*************** connect_infinite_loops_to_exit ()
*** 757,765 ****
  
    flow_dfs_compute_reverse_finish (&dfs_ds);
- 
    return;
  }
  
  /* Compute reverse top sort order */
  void
  flow_reverse_top_sort_order_compute (rts_order)
--- 771,779 ----
  
    flow_dfs_compute_reverse_finish (&dfs_ds);
    return;
  }
  
  /* Compute reverse top sort order */
+ 
  void
  flow_reverse_top_sort_order_compute (rts_order)
*************** flow_reverse_top_sort_order_compute (rts
*** 802,810 ****
  
  	  if (dest->succ)
! 	    {
! 	      /* Since the DEST node has been visited for the first
! 		 time, check its successors.  */
! 	      stack[sp++] = dest->succ;
! 	    }
  	  else
  	    rts_order[postnum++] = dest->index;
--- 816,822 ----
  
  	  if (dest->succ)
! 	    /* Since the DEST node has been visited for the first
! 	       time, check its successors.  */
! 	    stack[sp++] = dest->succ;
  	  else
  	    rts_order[postnum++] = dest->index;
*************** flow_depth_first_order_compute (dfs_orde
*** 880,905 ****
  
  	  if (dest->succ)
! 	    {
! 	      /* Since the DEST node has been visited for the first
! 		 time, check its successors.  */
! 	      stack[sp++] = dest->succ;
! 	    }
! 	  else
! 	    {
! 	      /* There are no successors for the DEST node so assign
! 		 its reverse completion number.  */
! 	      if (rc_order)
! 		rc_order[rcnum--] = dest->index;
! 	    }
  	}
        else
  	{
! 	  if (! e->succ_next && src != ENTRY_BLOCK_PTR)
! 	    {
! 	      /* There are no more successors for the SRC node
! 		 so assign its reverse completion number.  */
! 	      if (rc_order)
! 		rc_order[rcnum--] = src->index;
! 	    }
  
  	  if (e->succ_next)
--- 892,910 ----
  
  	  if (dest->succ)
! 	    /* Since the DEST node has been visited for the first
! 	       time, check its successors.  */
! 	    stack[sp++] = dest->succ;
! 	  else if (rc_order)
! 	    /* There are no successors for the DEST node so assign
! 	       its reverse completion number.  */
! 	    rc_order[rcnum--] = dest->index;
  	}
        else
  	{
! 	  if (! e->succ_next && src != ENTRY_BLOCK_PTR
! 	      && rc_order)
! 	    /* There are no more successors for the SRC node
! 	       so assign its reverse completion number.  */
! 	    rc_order[rcnum--] = src->index;
  
  	  if (e->succ_next)
*************** flow_depth_first_order_compute (dfs_orde
*** 921,928 ****
    if (dfsnum < n_basic_blocks)
      abort ();
    return dfsnum;
  }
  
! struct dfst_node {
      unsigned nnodes;
      struct dfst_node **node;
--- 926,935 ----
    if (dfsnum < n_basic_blocks)
      abort ();
+ 
    return dfsnum;
  }
  
! struct dfst_node
! {
      unsigned nnodes;
      struct dfst_node **node;
*************** flow_preorder_transversal_compute (pot_o
*** 959,964 ****
  
    /* Allocate the tree.  */
!   dfst
!     = (struct dfst_node *) xcalloc (n_basic_blocks, sizeof (struct dfst_node));
    for (i = 0; i < n_basic_blocks; i++)
      {
--- 966,972 ----
  
    /* Allocate the tree.  */
!   dfst = (struct dfst_node *) xcalloc (n_basic_blocks,
! 				       sizeof (struct dfst_node));
! 
    for (i = 0; i < n_basic_blocks; i++)
      {
*************** flow_preorder_transversal_compute (pot_o
*** 966,973 ****
        for (e = BASIC_BLOCK (i)->succ; e; e = e->succ_next)
  	max_successors++;
!       dfst[i].node = max_successors ? (struct dfst_node **)
! 				      xcalloc (max_successors,
! 					       sizeof (struct dfst_node *))
! 			    : NULL;
      }
  
--- 974,983 ----
        for (e = BASIC_BLOCK (i)->succ; e; e = e->succ_next)
  	max_successors++;
! 
!       dfst[i].node
! 	= (max_successors
! 	   ? (struct dfst_node **) xcalloc (max_successors,
! 					    sizeof (struct dfst_node *))
! 	   : NULL);
      }
  
*************** flow_preorder_transversal_compute (pot_o
*** 1006,1022 ****
  
  	  if (dest->succ)
! 	    {
! 	      /* Since the DEST node has been visited for the first
! 		 time, check its successors.  */
! 	      stack[sp++] = dest->succ;
! 	    }
  	}
        else
! 	{
! 	  if (e->succ_next)
! 	    stack[sp - 1] = e->succ_next;
! 	  else
! 	    sp--;
! 	}
      }
  
--- 1016,1028 ----
  
  	  if (dest->succ)
! 	    /* Since the DEST node has been visited for the first
! 	       time, check its successors.  */
! 	    stack[sp++] = dest->succ;
  	}
+ 
+       else if (e->succ_next)
+ 	stack[sp - 1] = e->succ_next;
        else
! 	sp--;
      }
  
*************** flow_preorder_transversal_compute (pot_o
*** 1047,1050 ****
--- 1053,1057 ----
      if (dfst[i].node)
        free (dfst[i].node);
+ 
    free (dfst);
  }
*************** flow_dfs_compute_reverse_init (data)
*** 1085,1091 ****
  {
    /* Allocate stack for back-tracking up CFG.  */
!   data->stack =
!     (basic_block *) xmalloc ((n_basic_blocks - (INVALID_BLOCK + 1))
! 			     * sizeof (basic_block));
    data->sp = 0;
  
--- 1092,1097 ----
  {
    /* Allocate stack for back-tracking up CFG.  */
!   data->stack = (basic_block *) xmalloc ((n_basic_blocks - (INVALID_BLOCK + 1))
! 					 * sizeof (basic_block));
    data->sp = 0;
  
*************** flow_dfs_compute_reverse_add_bb (data, b
*** 1110,1120 ****
    data->stack[data->sp++] = bb;
    SET_BIT (data->visited_blocks, bb->index - (INVALID_BLOCK + 1));
-   return;
  }
  
! /* Continue the depth-first search through the reverse graph starting
!    with the block at the stack's top and ending when the stack is
!    empty.  Visited nodes are marked.  Returns an unvisited basic
!    block, or NULL if there is none available.  */
  
  static basic_block
--- 1116,1125 ----
    data->stack[data->sp++] = bb;
    SET_BIT (data->visited_blocks, bb->index - (INVALID_BLOCK + 1));
  }
  
! /* Continue the depth-first search through the reverse graph starting with the
!    block at the stack's top and ending when the stack is empty.  Visited nodes
!    are marked.  Returns an unvisited basic block, or NULL if there is none
!    available.  */
  
  static basic_block
*************** flow_dfs_compute_reverse_execute (data)
*** 1129,1132 ****
--- 1134,1138 ----
      {
        bb = data->stack[--data->sp];
+ 
        /* Perform depth-first search on adjacent vertices.  */
        for (e = bb->pred; e; e = e->pred_next)
*************** flow_dfs_compute_reverse_execute (data)
*** 1137,1143 ****
  
    /* Determine if there are unvisited basic blocks.  */
!   for (i = n_basic_blocks - (INVALID_BLOCK + 1); --i >= 0;)
      if (!TEST_BIT (data->visited_blocks, i))
        return BASIC_BLOCK (i + (INVALID_BLOCK + 1));
    return NULL;
  }
--- 1143,1150 ----
  
    /* Determine if there are unvisited basic blocks.  */
!   for (i = n_basic_blocks - (INVALID_BLOCK + 1); --i >= 0; )
      if (!TEST_BIT (data->visited_blocks, i))
        return BASIC_BLOCK (i + (INVALID_BLOCK + 1));
+ 
    return NULL;
  }
*************** flow_dfs_compute_reverse_finish (data)
*** 1152,1155 ****
    free (data->stack);
    sbitmap_free (data->visited_blocks);
-   return;
  }
--- 1159,1161 ----
*** cfgbuild.c	2001/12/09 20:13:02	1.11
--- cfgbuild.c	2001/12/22 15:10:15
*************** Software Foundation, 59 Temple Place - S
*** 31,36 ****
           find_basic_blocks
       - Local CFG construction
!          find_sub_basic_blocks
!  */
  
  #include "config.h"
--- 31,35 ----
           find_basic_blocks
       - Local CFG construction
!          find_sub_basic_blocks		 */
  
  #include "config.h"
*************** Software Foundation, 59 Temple Place - S
*** 47,52 ****
  #include "toplev.h"
  #include "timevar.h"
- 
  #include "obstack.h"
  static int count_basic_blocks		PARAMS ((rtx));
  static void find_basic_blocks_1		PARAMS ((rtx));
--- 46,51 ----
  #include "toplev.h"
  #include "timevar.h"
  #include "obstack.h"
+ 
  static int count_basic_blocks		PARAMS ((rtx));
  static void find_basic_blocks_1		PARAMS ((rtx));
*************** static void compute_outgoing_frequencies
*** 60,64 ****
  static bool inside_basic_block_p	PARAMS ((rtx));
  static bool control_flow_insn_p		PARAMS ((rtx));
! 
  /* Return true if insn is something that should be contained inside basic
     block.  */
--- 59,63 ----
  static bool inside_basic_block_p	PARAMS ((rtx));
  static bool control_flow_insn_p		PARAMS ((rtx));
! 
  /* Return true if insn is something that should be contained inside basic
     block.  */
*************** inside_basic_block_p (insn)
*** 72,87 ****
      case CODE_LABEL:
        /* Avoid creating of basic block for jumptables.  */
!       if (NEXT_INSN (insn)
! 	  && GET_CODE (NEXT_INSN (insn)) == JUMP_INSN
! 	  && (GET_CODE (PATTERN (NEXT_INSN (insn))) == ADDR_VEC
! 	      || GET_CODE (PATTERN (NEXT_INSN (insn))) == ADDR_DIFF_VEC))
! 	return false;
!       return true;
  
      case JUMP_INSN:
!       if (GET_CODE (PATTERN (insn)) == ADDR_VEC
! 	  || GET_CODE (PATTERN (insn)) == ADDR_DIFF_VEC)
! 	return false;
!       return true;
  
      case CALL_INSN:
--- 71,82 ----
      case CODE_LABEL:
        /* Avoid creating of basic block for jumptables.  */
!       return (NEXT_INSN (insn) == 0
! 	      || GET_CODE (NEXT_INSN (insn)) != JUMP_INSN
! 	      || (GET_CODE (PATTERN (NEXT_INSN (insn))) != ADDR_VEC
! 		  && GET_CODE (PATTERN (NEXT_INSN (insn))) != ADDR_DIFF_VEC));
  
      case JUMP_INSN:
!       return (GET_CODE (PATTERN (insn)) != ADDR_VEC
! 	      && GET_CODE (PATTERN (insn)) != ADDR_DIFF_VEC);
  
      case CALL_INSN:
*************** inside_basic_block_p (insn)
*** 98,103 ****
  }
  
! /* Return true if INSN may cause control flow transfer, so 
!    it should be last in the basic block.  */
  
  static bool
--- 93,98 ----
  }
  
! /* Return true if INSN may cause control flow transfer, so it should be last in
!    the basic block.  */
  
  static bool
*************** control_flow_insn_p (insn)
*** 106,109 ****
--- 101,105 ----
  {
    rtx note;
+ 
    switch (GET_CODE (insn))
      {
*************** control_flow_insn_p (insn)
*** 114,134 ****
        case JUMP_INSN:
  	/* Jump insn always causes control transfer except for tablejumps.  */
! 	if (GET_CODE (PATTERN (insn)) == ADDR_VEC
! 	    || GET_CODE (PATTERN (insn)) == ADDR_DIFF_VEC)
! 	  return false;
! 	return true;
  
        case CALL_INSN:
  	/* Call insn may return to the nonlocal goto handler.  */
! 	if (nonlocal_goto_handler_labels
! 	    && ((note = find_reg_note (insn, REG_EH_REGION, NULL_RTX)) == 0
! 		|| INTVAL (XEXP (note, 0)) >= 0))
! 	  return true;
! 	/* Or may trap.  */
! 	return can_throw_internal (insn);
  
        case INSN:
! 	return (flag_non_call_exceptions
! 		&& can_throw_internal (insn));
  
        case BARRIER:
--- 110,127 ----
        case JUMP_INSN:
  	/* Jump insn always causes control transfer except for tablejumps.  */
! 	return (GET_CODE (PATTERN (insn)) != ADDR_VEC
! 		&& GET_CODE (PATTERN (insn)) != ADDR_DIFF_VEC);
  
        case CALL_INSN:
  	/* Call insn may return to the nonlocal goto handler.  */
! 	return ((nonlocal_goto_handler_labels
! 		 && (0 == (note = find_reg_note (insn, REG_EH_REGION,
! 						 NULL_RTX))
! 		     || INTVAL (XEXP (note, 0)) >= 0))
! 		/* Or may trap.  */
! 		|| can_throw_internal (insn));
  
        case INSN:
! 	return (flag_non_call_exceptions && can_throw_internal (insn));
  
        case BARRIER:
*************** count_basic_blocks (f)
*** 157,161 ****
        /* Code labels and barriers causes curent basic block to be
           terminated at previous real insn.  */
- 
        if ((GET_CODE (insn) == CODE_LABEL || GET_CODE (insn) == BARRIER)
  	  && saw_insn)
--- 150,153 ----
*************** count_basic_blocks (f)
*** 170,173 ****
--- 162,166 ----
  	count++, saw_insn = false;
      }
+ 
    if (saw_insn)
      count++;
*************** count_basic_blocks (f)
*** 186,189 ****
--- 179,183 ----
  /* Scan a list of insns for labels referred to other than by jumps.
     This is used to scan the alternatives of a call placeholder.  */
+ 
  static rtx
  find_label_refs (f, lvl)
*************** make_eh_edge (edge_cache, src, insn)
*** 264,268 ****
       rtx insn;
  {
!   int is_call = (GET_CODE (insn) == CALL_INSN ? EDGE_ABNORMAL_CALL : 0);
    rtx handlers, i;
  
--- 258,262 ----
       rtx insn;
  {
!   int is_call = GET_CODE (insn) == CALL_INSN ? EDGE_ABNORMAL_CALL : 0;
    rtx handlers, i;
  
*************** make_eh_edge (edge_cache, src, insn)
*** 275,278 ****
--- 269,273 ----
    free_INSN_LIST_list (&handlers);
  }
+ 
  /* Identify the edges between basic blocks MIN to MAX.
  
*************** make_edges (label_value_list, min, max, 
*** 306,309 ****
--- 301,305 ----
  	  {
  	    edge e;
+ 
  	    for (e = BASIC_BLOCK (i)->succ; e ; e = e->succ_next)
  	      if (e->dest != EXIT_BLOCK_PTR)
*************** make_edges (label_value_list, min, max, 
*** 314,318 ****
    /* By nature of the way these get numbered, block 0 is always the entry.  */
    if (min == 0)
!     cached_make_edge (edge_cache, ENTRY_BLOCK_PTR, BASIC_BLOCK (0), EDGE_FALLTHRU);
  
    for (i = min; i <= max; ++i)
--- 310,315 ----
    /* By nature of the way these get numbered, block 0 is always the entry.  */
    if (min == 0)
!     cached_make_edge (edge_cache, ENTRY_BLOCK_PTR, BASIC_BLOCK (0),
! 		      EDGE_FALLTHRU);
  
    for (i = min; i <= max; ++i)
*************** make_edges (label_value_list, min, max, 
*** 323,328 ****
        int force_fallthru = 0;
  
!       if (GET_CODE (bb->head) == CODE_LABEL
! 	  && LABEL_ALTERNATE_NAME (bb->head))
  	cached_make_edge (NULL, ENTRY_BLOCK_PTR, bb, 0);
  
--- 320,324 ----
        int force_fallthru = 0;
  
!       if (GET_CODE (bb->head) == CODE_LABEL && LABEL_ALTERNATE_NAME (bb->head))
  	cached_make_edge (NULL, ENTRY_BLOCK_PTR, bb, 0);
  
*************** make_edges (label_value_list, min, max, 
*** 409,417 ****
  	}
  
!       /* If this is a sibling call insn, then this is in effect a
! 	 combined call and return, and so we need an edge to the
! 	 exit block.  No need to worry about EH edges, since we
! 	 wouldn't have created the sibling call in the first place.  */
! 
        if (code == CALL_INSN && SIBLING_CALL_P (insn))
  	cached_make_edge (edge_cache, bb, EXIT_BLOCK_PTR,
--- 405,412 ----
  	}
  
!       /* If this is a sibling call insn, then this is in effect a combined call
! 	 and return, and so we need an edge to the exit block.  No need to
! 	 worry about EH edges, since we wouldn't have created the sibling call
! 	 in the first place.  */
        if (code == CALL_INSN && SIBLING_CALL_P (insn))
  	cached_make_edge (edge_cache, bb, EXIT_BLOCK_PTR,
*************** make_edges (label_value_list, min, max, 
*** 421,427 ****
  	 handler for this CALL_INSN.  If we're handling non-call
  	 exceptions then any insn can reach any of the active handlers.
- 
  	 Also mark the CALL_INSN as reaching any nonlocal goto handler.  */
- 
        else if (code == CALL_INSN || flag_non_call_exceptions)
  	{
--- 416,420 ----
*************** make_edges (label_value_list, min, max, 
*** 433,444 ****
  	      /* ??? This could be made smarter: in some cases it's possible
  		 to tell that certain calls will not do a nonlocal goto.
- 
  		 For example, if the nested functions that do the nonlocal
  		 gotos do not have their addresses taken, then only calls to
  		 those functions or to other nested functions that use them
  		 could possibly do nonlocal gotos.  */
  	      /* We do know that a REG_EH_REGION note with a value less
  		 than 0 is guaranteed not to perform a non-local goto.  */
  	      rtx note = find_reg_note (insn, REG_EH_REGION, NULL_RTX);
  	      if (!note || INTVAL (XEXP (note, 0)) >=  0)
  		for (x = nonlocal_goto_handler_labels; x; x = XEXP (x, 1))
--- 426,438 ----
  	      /* ??? This could be made smarter: in some cases it's possible
  		 to tell that certain calls will not do a nonlocal goto.
  		 For example, if the nested functions that do the nonlocal
  		 gotos do not have their addresses taken, then only calls to
  		 those functions or to other nested functions that use them
  		 could possibly do nonlocal gotos.  */
+ 
  	      /* We do know that a REG_EH_REGION note with a value less
  		 than 0 is guaranteed not to perform a non-local goto.  */
  	      rtx note = find_reg_note (insn, REG_EH_REGION, NULL_RTX);
+ 
  	      if (!note || INTVAL (XEXP (note, 0)) >=  0)
  		for (x = nonlocal_goto_handler_labels; x; x = XEXP (x, 1))
*************** make_edges (label_value_list, min, max, 
*** 458,462 ****
  	    tmp = next_nonnote_insn (tmp);
  	  if (force_fallthru || insn == tmp)
! 	    cached_make_edge (edge_cache, bb, BASIC_BLOCK (i + 1), EDGE_FALLTHRU);
  	}
      }
--- 452,457 ----
  	    tmp = next_nonnote_insn (tmp);
  	  if (force_fallthru || insn == tmp)
! 	    cached_make_edge (edge_cache, bb, BASIC_BLOCK (i + 1),
! 			      EDGE_FALLTHRU);
  	}
      }
*************** find_basic_blocks_1 (f)
*** 502,505 ****
--- 497,501 ----
  	  bb_note = NULL_RTX;
  	}
+ 
        if (inside_basic_block_p (insn))
  	{
*************** find_basic_blocks_1 (f)
*** 508,511 ****
--- 504,508 ----
  	  end = insn;
  	}
+ 
        if (head && control_flow_insn_p (insn))
  	{
*************** find_basic_blocks (f, nregs, file)
*** 677,688 ****
  
  /* State of basic block as seen by find_sub_basic_blocks.  */
! enum state
!   {
!     BLOCK_NEW = 0,
!     BLOCK_ORIGINAL,
!     BLOCK_TO_SPLIT
!   };
! #define STATE(bb) (enum state)(size_t)(bb)->aux
! #define SET_STATE(bb, state) (bb)->aux = (void *) (size_t) (state)
  
  /* Scan basic block BB for possible BB boundaries inside the block
--- 674,681 ----
  
  /* State of basic block as seen by find_sub_basic_blocks.  */
! enum state {BLOCK_NEW = 0, BLOCK_ORIGINAL, BLOCK_TO_SPLIT};
! 
! #define STATE(BB) (enum state) ((size_t) (BB)->aux)
! #define SET_STATE(BB, STATE) ((BB)->aux = (void *) (size_t) (STATE))
  
  /* Scan basic block BB for possible BB boundaries inside the block
*************** find_bb_boundaries (bb)
*** 715,718 ****
--- 708,712 ----
  	  if (flow_transfer_insn)
  	    bb->end = flow_transfer_insn;
+ 
  	  bb = fallthru->dest;
  	  remove_edge (fallthru);
*************** find_bb_boundaries (bb)
*** 721,724 ****
--- 715,719 ----
  	    make_edge (ENTRY_BLOCK_PTR, bb, 0);
  	}
+ 
        /* In case we've previously seen an insn that effects a control
  	 flow transfer, split the block.  */
*************** find_bb_boundaries (bb)
*** 731,734 ****
--- 726,730 ----
  	  flow_transfer_insn = NULL_RTX;
  	}
+ 
        if (control_flow_insn_p (insn))
  	flow_transfer_insn = insn;
*************** compute_outgoing_frequencies (b)
*** 758,761 ****
--- 754,758 ----
  {
    edge e, f;
+ 
    if (b->succ && b->succ->succ_next && !b->succ->succ_next->succ_next)
      {
*************** compute_outgoing_frequencies (b)
*** 765,770 ****
        if (!note)
  	return;
        probability = INTVAL (XEXP (find_reg_note (b->end,
! 						 REG_BR_PROB, NULL), 0));
        e = BRANCH_EDGE (b);
        e->probability = probability;
--- 762,769 ----
        if (!note)
  	return;
+ 
        probability = INTVAL (XEXP (find_reg_note (b->end,
! 						 REG_BR_PROB, NULL),
! 				  0));
        e = BRANCH_EDGE (b);
        e->probability = probability;
*************** compute_outgoing_frequencies (b)
*** 775,778 ****
--- 774,778 ----
        f->count = b->count - e->count;
      }
+ 
    if (b->succ && !b->succ->succ_next)
      {
*************** find_many_sub_basic_blocks (blocks)
*** 798,810 ****
  
    for (i = 0; i < n_basic_blocks; i++)
!     {
!       basic_block bb = BASIC_BLOCK (i);
!       if (STATE (bb) == BLOCK_TO_SPLIT)
! 	find_bb_boundaries (bb);
!     }
  
    for (i = 0; i < n_basic_blocks; i++)
      if (STATE (BASIC_BLOCK (i)) != BLOCK_ORIGINAL)
        break;
    min = max = i;
    for (; i < n_basic_blocks; i++)
--- 798,808 ----
  
    for (i = 0; i < n_basic_blocks; i++)
!     if (STATE (BASIC_BLOCK (i)) == BLOCK_TO_SPLIT)
!       find_bb_boundaries (BASIC_BLOCK (i));
  
    for (i = 0; i < n_basic_blocks; i++)
      if (STATE (BASIC_BLOCK (i)) != BLOCK_ORIGINAL)
        break;
+ 
    min = max = i;
    for (; i < n_basic_blocks; i++)
*************** find_many_sub_basic_blocks (blocks)
*** 835,840 ****
--- 833,840 ----
  	    }
  	}
+ 
        compute_outgoing_frequencies (b);
      }
+ 
    for (i = 0; i < n_basic_blocks; i++)
      SET_STATE (BASIC_BLOCK (i), 0);
*************** find_sub_basic_blocks (bb)
*** 877,880 ****
--- 877,881 ----
  	    }
  	}
+ 
        compute_outgoing_frequencies (b);
      }


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