[patch] for PR 26570

Zdenek Dvorak rakdver@atrey.karlin.mff.cuni.cz
Sat Aug 12 12:44:00 GMT 2006


Hello,

in this PR, we manage to free "values" array two times (one of them using
really ugly trick); however, there is no reason for that -- the "values"
array is used only in the branch_prob function, so we can simply free it
there.

Bootstrapped & regtested on x86_64 and ppc.

Zdenek

Index: value-prof.c
===================================================================
*** value-prof.c	(revision 116087)
--- value-prof.c	(working copy)
*************** Software Foundation, 51 Franklin Street,
*** 46,57 ****
  
  static struct value_prof_hooks *value_prof_hooks;
  
- /* This is the vector of histograms.  Created in find_values_to_profile.
-    During profile generation, freed by instrument_values.
-    During profile use, freed by value_profile_transformations.  */
- 
- static histogram_values static_values = NULL;
- 
  /* In this file value profile based optimizations are placed.  Currently the
     following optimizations are implemented (for more detailed descriptions
     see comments at value_profile_transformations):
--- 46,51 ----
*************** tree_find_values_to_profile (histogram_v
*** 797,803 ****
    FOR_EACH_BB (bb)
      for (bsi = bsi_start (bb); !bsi_end_p (bsi); bsi_next (&bsi))
        tree_values_to_profile (bsi_stmt (bsi), values);
-   static_values = *values;
    
    for (i = 0; VEC_iterate (histogram_value, *values, i, hist); i++)
      {
--- 791,796 ----
*************** find_values_to_profile (histogram_values
*** 875,883 ****
  bool
  value_profile_transformations (void)
  {
!   bool retval = (value_prof_hooks->value_profile_transformations) ();
!   VEC_free (histogram_value, heap, static_values);
!   return retval;
  }
  
  
--- 868,874 ----
  bool
  value_profile_transformations (void)
  {
!   return (value_prof_hooks->value_profile_transformations) ();
  }
  
  
Index: profile.c
===================================================================
*** profile.c	(revision 116087)
--- profile.c	(working copy)
*************** instrument_values (histogram_values valu
*** 220,226 ****
  	  gcc_unreachable ();
  	}
      }
-   VEC_free (histogram_value, heap, values);
  }
  
  
--- 220,225 ----
*************** branch_prob (void)
*** 1049,1054 ****
--- 1048,1054 ----
  
    free_aux_for_edges ();
  
+   VEC_free (histogram_value, heap, values);
    free_edge_list (el);
    if (flag_branch_probabilities)
      profile_status = PROFILE_READ;



More information about the Gcc-patches mailing list