OSDN Git Service

2008-03-23 H.J. Lu <hongjiu.lu@intel.com>
[pf3gnuchains/gcc-fork.git] / gcc / profile.c
index 4e2213a..a4f46b3 100644 (file)
@@ -1,6 +1,7 @@
 /* Calculate branch probabilities, and basic block execution counts.
    Copyright (C) 1990, 1991, 1992, 1993, 1994, 1996, 1997, 1998, 1999,
-   2000, 2001, 2002, 2003, 2004, 2005  Free Software Foundation, Inc.
+   2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008
+   Free Software Foundation, Inc.
    Contributed by James E. Wilson, UC Berkeley/Cygnus Support;
    based on some ideas from Dain Samples of UC Berkeley.
    Further mangling by Bob Manson, Cygnus Support.
@@ -9,7 +10,7 @@ This file is part of GCC.
 
 GCC is free software; you can redistribute it and/or modify it under
 the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 2, or (at your option) any later
+Software Foundation; either version 3, or (at your option) any later
 version.
 
 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
@@ -18,9 +19,8 @@ FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 for more details.
 
 You should have received a copy of the GNU General Public License
-along with GCC; see the file COPYING.  If not, write to the Free
-Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301, USA.  */
+along with GCC; see the file COPYING3.  If not see
+<http://www.gnu.org/licenses/>.  */
 
 /* Generate basic block profile instrumentation and auxiliary files.
    Profile generation is optimized, so that not all arcs in the basic
@@ -192,6 +192,18 @@ instrument_values (histogram_values values)
          t = GCOV_COUNTER_V_DELTA;
          break;
 
+       case HIST_TYPE_INDIR_CALL:
+         t = GCOV_COUNTER_V_INDIR;
+         break;
+
+       case HIST_TYPE_AVERAGE:
+         t = GCOV_COUNTER_AVERAGE;
+         break;
+
+       case HIST_TYPE_IOR:
+         t = GCOV_COUNTER_IOR;
+         break;
+
        default:
          gcc_unreachable ();
        }
@@ -216,11 +228,22 @@ instrument_values (histogram_values values)
          (profile_hooks->gen_const_delta_profiler) (hist, t, 0);
          break;
 
+       case HIST_TYPE_INDIR_CALL:
+         (profile_hooks->gen_ic_profiler) (hist, t, 0);
+         break;
+
+       case HIST_TYPE_AVERAGE:
+         (profile_hooks->gen_average_profiler) (hist, t, 0);
+         break;
+
+       case HIST_TYPE_IOR:
+         (profile_hooks->gen_ior_profiler) (hist, t, 0);
+         break;
+
        default:
          gcc_unreachable ();
        }
     }
-  VEC_free (histogram_value, heap, values);
 }
 \f
 
@@ -649,15 +672,13 @@ compute_value_histograms (histogram_values values)
     {
       histogram_value hist = VEC_index (histogram_value, values, i);
       tree stmt = hist->hvalue.stmt;
-      stmt_ann_t ann = get_stmt_ann (stmt);
 
       t = (int) hist->type;
 
       aact_count = act_count[t];
       act_count[t] += hist->n_counters;
 
-      hist->hvalue.next = ann->histograms;
-      ann->histograms = hist;
+      gimple_add_histogram_value (cfun, stmt, hist);
       hist->hvalue.counters =  XNEWVEC (gcov_type, hist->n_counters);
       for (j = 0; j < hist->n_counters; j++)
        hist->hvalue.counters[j] = aact_count[j];
@@ -793,15 +814,10 @@ branch_prob (void)
          if (last && EXPR_LOCUS (last)
              && e->goto_locus
              && !single_succ_p (bb)
-#ifdef USE_MAPPED_LOCATION
              && (LOCATION_FILE (e->goto_locus)
                  != LOCATION_FILE (EXPR_LOCATION  (last))
                  || (LOCATION_LINE (e->goto_locus)
                      != LOCATION_LINE (EXPR_LOCATION  (last)))))
-#else
-             && (e->goto_locus->file != EXPR_LOCUS (last)->file
-                 || (e->goto_locus->line != EXPR_LOCUS (last)->line)))
-#endif
            {
              basic_block new = split_edge (e);
              single_succ_edge (new)->goto_locus = e->goto_locus;
@@ -984,22 +1000,25 @@ branch_prob (void)
              if (EXPR_HAS_LOCATION (stmt))
                output_location (EXPR_FILENAME (stmt), EXPR_LINENO (stmt),
                                 &offset, bb);
+             /* Take into account modify statements nested in return
+                produced by C++ NRV transformation.  */
+             if (TREE_CODE (stmt) == RETURN_EXPR
+                 && TREE_OPERAND (stmt, 0)
+                 && TREE_CODE (TREE_OPERAND (stmt, 0)) == MODIFY_EXPR
+                 && EXPR_HAS_LOCATION (TREE_OPERAND (stmt, 0)))
+               output_location (EXPR_FILENAME (TREE_OPERAND (stmt, 0)),
+                                EXPR_LINENO (TREE_OPERAND (stmt, 0)),
+                                &offset, bb);
            }
 
          /* Notice GOTO expressions we eliminated while constructing the
             CFG.  */
          if (single_succ_p (bb) && single_succ_edge (bb)->goto_locus)
            {
-             /* ??? source_locus type is marked deprecated in input.h.  */
-             source_locus curr_location = single_succ_edge (bb)->goto_locus;
+             location_t curr_location = single_succ_edge (bb)->goto_locus;
              /* ??? The FILE/LINE API is inconsistent for these cases.  */
-#ifdef USE_MAPPED_LOCATION 
              output_location (LOCATION_FILE (curr_location),
                               LOCATION_LINE (curr_location), &offset, bb);
-#else
-             output_location (curr_location->file, curr_location->line,
-                              &offset, bb);
-#endif
            }
 
          if (offset)
@@ -1049,6 +1068,7 @@ branch_prob (void)
 
   free_aux_for_edges ();
 
+  VEC_free (histogram_value, heap, values);
   free_edge_list (el);
   if (flag_branch_probabilities)
     profile_status = PROFILE_READ;
@@ -1228,7 +1248,7 @@ end_branch_prob (void)
 void
 tree_register_profile_hooks (void)
 {
-  gcc_assert (ir_type ());
+  gcc_assert (current_ir_type () == IR_GIMPLE);
   profile_hooks = &tree_profile_hooks;
 }