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]

Use alloc_aux* functions



Hi,
this patch modifies bb reordering, estimate_probability, profiling and reg-stack
to use alloc_aux* functions.

Honza

Sat Sep 22 18:39:50 CEST 2001  Jan Hubicka  <jh@suse.cz>
	* bb-reorder.c (fixup_reorder_chain): Use alloc_aux_for_block.
	(reroder_basic_block): Use alloc_aux_for_blocks.
	* predict.c (estimate_bb_frequencies): Likewise; use
	alloc_aux_for_edges.
	* profile.c (compute_branch_probabilities): Likewise.
	(branch_prob): Likewise.
	* reg-stack.c (reg_to_stack): Likewise.

diff -Nrc3p /home/hubicka/egcs/gcc/bb-reorder.c gcc/bb-reorder.c
*** /home/hubicka/egcs/gcc/bb-reorder.c	Thu Sep 20 12:14:51 2001
--- gcc/bb-reorder.c	Thu Sep 20 19:51:39 2001
*************** fixup_reorder_chain ()
*** 660,666 ****
  
        if (nb)
  	{
! 	  nb->aux = xmalloc (sizeof (struct reorder_block_def));
  	  RBI (nb)->eff_head = nb->head;
  	  RBI (nb)->eff_end = NEXT_INSN (nb->end);
  	  RBI (nb)->scope = RBI (bb)->scope;
--- 660,666 ----
  
        if (nb)
  	{
! 	  alloc_aux_for_block (nb, sizeof (struct reorder_block_def));
  	  RBI (nb)->eff_head = nb->head;
  	  RBI (nb)->eff_end = NEXT_INSN (nb->end);
  	  RBI (nb)->scope = RBI (bb)->scope;
*************** void
*** 1327,1341 ****
  reorder_basic_blocks ()
  {
    scope_forest_info forest;
-   int i;
  
    if (n_basic_blocks <= 1)
      return;
  
!   for (i = 0; i < n_basic_blocks; i++)
!     BASIC_BLOCK (i)->aux = xcalloc (1, sizeof (struct reorder_block_def));
! 
!   EXIT_BLOCK_PTR->aux = xcalloc (1, sizeof (struct reorder_block_def));
  
    build_scope_forest (&forest);
    remove_scope_notes ();
--- 1327,1337 ----
  reorder_basic_blocks ()
  {
    scope_forest_info forest;
  
    if (n_basic_blocks <= 1)
      return;
  
!   alloc_aux_for_blocks (sizeof (struct reorder_block_def));
  
    build_scope_forest (&forest);
    remove_scope_notes ();
*************** reorder_basic_blocks ()
*** 1356,1365 ****
    free_scope_forest (&forest);
    reorder_blocks ();
  
!   for (i = 0; i < n_basic_blocks; i++)
!     free (BASIC_BLOCK (i)->aux);
! 
!   free (EXIT_BLOCK_PTR->aux);
  
  #ifdef ENABLE_CHECKING
    verify_flow_info ();
--- 1352,1358 ----
    free_scope_forest (&forest);
    reorder_blocks ();
  
!   free_aux_for_blocks ();
  
  #ifdef ENABLE_CHECKING
    verify_flow_info ();
diff -Nrc3p /home/hubicka/egcs/gcc/predict.c gcc/predict.c
*** /home/hubicka/egcs/gcc/predict.c	Mon Sep 10 12:55:19 2001
--- gcc/predict.c	Thu Sep 20 20:27:51 2001
*************** static void
*** 832,840 ****
  estimate_bb_frequencies (loops)
       struct loops *loops;
  {
-   block_info bi;
-   edge_info ei;
-   int edgenum = 0;
    int i;
    double freq_max = 0;
  
--- 834,839 ----
*************** estimate_bb_frequencies (loops)
*** 891,898 ****
    ENTRY_BLOCK_PTR->succ->probability = REG_BR_PROB_BASE;
  
    /* Set up block info for each basic block.  */
!   bi = (block_info) xcalloc ((n_basic_blocks + 2), sizeof (*bi));
!   ei = (edge_info) xcalloc ((n_edges), sizeof (*ei));
    for (i = -2; i < n_basic_blocks; i++)
      {
        edge e;
--- 890,897 ----
    ENTRY_BLOCK_PTR->succ->probability = REG_BR_PROB_BASE;
  
    /* Set up block info for each basic block.  */
!   alloc_aux_for_blocks (sizeof (struct block_info_def));
!   alloc_aux_for_edges (sizeof (struct edge_info_def));
    for (i = -2; i < n_basic_blocks; i++)
      {
        edge e;
*************** estimate_bb_frequencies (loops)
*** 904,917 ****
  	bb = EXIT_BLOCK_PTR;
        else
  	bb = BASIC_BLOCK (i);
-       bb->aux = bi + i + 2;
        BLOCK_INFO (bb)->tovisit = 0;
        for (e = bb->succ; e; e = e->succ_next)
! 	{
! 	  e->aux = ei + edgenum, edgenum++;
! 	  EDGE_INFO (e)->back_edge_prob = ((double) e->probability
! 					   / REG_BR_PROB_BASE);
! 	}
      }
    /* First compute probabilities locally for each loop from innermost
       to outermost to examine probabilities for back edges.  */
--- 903,912 ----
  	bb = EXIT_BLOCK_PTR;
        else
  	bb = BASIC_BLOCK (i);
        BLOCK_INFO (bb)->tovisit = 0;
        for (e = bb->succ; e; e = e->succ_next)
! 	EDGE_INFO (e)->back_edge_prob = ((double) e->probability
! 					 / REG_BR_PROB_BASE);
      }
    /* First compute probabilities locally for each loop from innermost
       to outermost to examine probabilities for back edges.  */
*************** estimate_bb_frequencies (loops)
*** 940,945 ****
  		       + 0.5);
      }
  
!   free (ei);
!   free (bi);
  }
--- 935,940 ----
  		       + 0.5);
      }
  
!   free_aux_for_blocks ();
!   free_aux_for_edges ();
  }
diff -Nrc3p /home/hubicka/egcs/gcc/profile.c gcc/profile.c
*** /home/hubicka/egcs/gcc/profile.c	Tue Sep 11 18:58:57 2001
--- gcc/profile.c	Thu Sep 20 19:27:49 2001
*************** compute_branch_probabilities ()
*** 217,234 ****
    int hist_br_prob[20];
    int num_never_executed;
    int num_branches;
-   struct bb_info *bb_infos;
  
    /* Attach extra info block to each bb.  */
  
!   bb_infos = (struct bb_info *)
!     xcalloc (n_basic_blocks + 2, sizeof (struct bb_info));
    for (i = 0; i < n_basic_blocks + 2; i++)
      {
        basic_block bb = GCOV_INDEX_TO_BB (i);
        edge e;
  
-       bb->aux = &bb_infos[i];
        for (e = bb->succ; e; e = e->succ_next)
  	if (!EDGE_INFO (e)->ignore)
  	  BB_INFO (bb)->succ_count++;
--- 217,231 ----
    int hist_br_prob[20];
    int num_never_executed;
    int num_branches;
  
    /* Attach extra info block to each bb.  */
  
!   alloc_aux_for_blocks (sizeof (struct bb_info));
    for (i = 0; i < n_basic_blocks + 2; i++)
      {
        basic_block bb = GCOV_INDEX_TO_BB (i);
        edge e;
  
        for (e = bb->succ; e; e = e->succ_next)
  	if (!EDGE_INFO (e)->ignore)
  	  BB_INFO (bb)->succ_count++;
*************** compute_branch_probabilities ()
*** 496,502 ****
        fputc ('\n', rtl_dump_file);
      }
  
!   free (bb_infos);
  }
  
  /* Instrument and/or analyze program behavior based on program flow graph.
--- 493,499 ----
        fputc ('\n', rtl_dump_file);
      }
  
!   free_aux_for_blocks ();
  }
  
  /* Instrument and/or analyze program behavior based on program flow graph.
*************** branch_prob ()
*** 520,526 ****
  {
    int i;
    int num_edges, ignored_edges;
-   struct edge_info *edge_infos;
    struct edge_list *el;
  
    /* Start of a function.  */
--- 517,522 ----
*************** branch_prob ()
*** 612,626 ****
  
    el = create_edge_list ();
    num_edges = NUM_EDGES (el);
!   edge_infos = (struct edge_info *)
!     xcalloc (num_edges, sizeof (struct edge_info));
  
    ignored_edges = 0;
    for (i = 0 ; i < num_edges ; i++)
      {
        edge e = INDEX_EDGE (el, i);
        e->count = 0;
-       e->aux = &edge_infos[i];
  
        /* Mark edges we've replaced by fake edges above as ignored.  */
        if ((e->flags & (EDGE_ABNORMAL | EDGE_ABNORMAL_CALL))
--- 608,620 ----
  
    el = create_edge_list ();
    num_edges = NUM_EDGES (el);
!   alloc_aux_for_edges (sizeof (struct edge_info));
  
    ignored_edges = 0;
    for (i = 0 ; i < num_edges ; i++)
      {
        edge e = INDEX_EDGE (el, i);
        e->count = 0;
  
        /* Mark edges we've replaced by fake edges above as ignored.  */
        if ((e->flags & (EDGE_ABNORMAL | EDGE_ABNORMAL_CALL))
*************** branch_prob ()
*** 803,809 ****
    if (rtl_dump_file)
      dump_flow_info (rtl_dump_file);
  
!   free (edge_infos);
    free_edge_list (el);
  }
  
--- 797,803 ----
    if (rtl_dump_file)
      dump_flow_info (rtl_dump_file);
  
!   free_aux_for_edges ();
    free_edge_list (el);
  }
  
diff -Nrc3p /home/hubicka/egcs/gcc/reg-stack.c gcc/reg-stack.c
*** /home/hubicka/egcs/gcc/reg-stack.c	Fri Sep 21 14:04:33 2001
--- gcc/reg-stack.c	Thu Sep 20 19:49:03 2001
*************** reg_to_stack (first, file)
*** 420,426 ****
  {
    int i;
    int max_uid;
-   block_info bi;
  
    /* Clean up previous run.  */
    if (stack_regs_mentioned_data)
--- 420,425 ----
*************** reg_to_stack (first, file)
*** 449,466 ****
    mark_dfs_back_edges ();
  
    /* Set up block info for each basic block.  */
!   bi = (block_info) xcalloc ((n_basic_blocks + 1), sizeof (*bi));
    for (i = n_basic_blocks - 1; i >= 0; --i)
      {
        edge e;
        basic_block bb = BASIC_BLOCK (i);
-       bb->aux = bi + i;
        for (e = bb->pred; e; e=e->pred_next)
  	if (!(e->flags & EDGE_DFS_BACK)
  	    && e->src != ENTRY_BLOCK_PTR)
  	  BLOCK_INFO (bb)->predecesors++;
      }
-   EXIT_BLOCK_PTR->aux = bi + n_basic_blocks;
  
    /* Create the replacement registers up front.  */
    for (i = FIRST_STACK_REG; i <= LAST_STACK_REG; i++)
--- 448,463 ----
    mark_dfs_back_edges ();
  
    /* Set up block info for each basic block.  */
!   alloc_aux_for_blocks (sizeof (struct block_info_def));
    for (i = n_basic_blocks - 1; i >= 0; --i)
      {
        edge e;
        basic_block bb = BASIC_BLOCK (i);
        for (e = bb->pred; e; e=e->pred_next)
  	if (!(e->flags & EDGE_DFS_BACK)
  	    && e->src != ENTRY_BLOCK_PTR)
  	  BLOCK_INFO (bb)->predecesors++;
      }
  
    /* Create the replacement registers up front.  */
    for (i = FIRST_STACK_REG; i <= LAST_STACK_REG; i++)
*************** reg_to_stack (first, file)
*** 500,506 ****
  
    convert_regs (file);
  
!   free (bi);
  }
  
  /* Check PAT, which is in INSN, for LABEL_REFs.  Add INSN to the
--- 497,503 ----
  
    convert_regs (file);
  
!   free_aux_for_blocks ();
  }
  
  /* Check PAT, which is in INSN, for LABEL_REFs.  Add INSN to the


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