OSDN Git Service

* gcc.dg/pr48235.c: Add dg-require-effective-target freorder.
[pf3gnuchains/gcc-fork.git] / gcc / profile.c
index 1049561..fd37748 100644 (file)
@@ -1,6 +1,6 @@
 /* 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, 2007, 2008, 2009
+   2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010
    Free Software Foundation, Inc.
    Contributed by James E. Wilson, UC Berkeley/Cygnus Support;
    based on some ideas from Dain Samples of UC Berkeley.
@@ -59,7 +59,8 @@ along with GCC; see the file COPYING3.  If not see
 #include "regs.h"
 #include "expr.h"
 #include "function.h"
-#include "toplev.h"
+#include "basic-block.h"
+#include "diagnostic-core.h"
 #include "coverage.h"
 #include "value-prof.h"
 #include "tree.h"
@@ -71,9 +72,6 @@ along with GCC; see the file COPYING3.  If not see
 
 #include "profile.h"
 
-/* Hooks for profiling.  */
-static struct profile_hooks* profile_hooks;
-
 struct bb_info {
   unsigned int count_valid : 1;
 
@@ -140,7 +138,7 @@ instrument_edges (struct edge_list *el)
                fprintf (dump_file, "Edge %d to %d instrumented%s\n",
                         e->src->index, e->dest->index,
                         EDGE_CRITICAL_P (e) ? " (and split)" : "");
-             (profile_hooks->gen_edge_profiler) (num_instr_edges++, e);
+             gimple_gen_edge_profiler (num_instr_edges++, e);
            }
        }
     }
@@ -201,31 +199,31 @@ instrument_values (histogram_values values)
       switch (hist->type)
        {
        case HIST_TYPE_INTERVAL:
-         (profile_hooks->gen_interval_profiler) (hist, t, 0);
+         gimple_gen_interval_profiler (hist, t, 0);
          break;
 
        case HIST_TYPE_POW2:
-         (profile_hooks->gen_pow2_profiler) (hist, t, 0);
+         gimple_gen_pow2_profiler (hist, t, 0);
          break;
 
        case HIST_TYPE_SINGLE_VALUE:
-         (profile_hooks->gen_one_value_profiler) (hist, t, 0);
+         gimple_gen_one_value_profiler (hist, t, 0);
          break;
 
        case HIST_TYPE_CONST_DELTA:
-         (profile_hooks->gen_const_delta_profiler) (hist, t, 0);
+         gimple_gen_const_delta_profiler (hist, t, 0);
          break;
 
        case HIST_TYPE_INDIR_CALL:
-         (profile_hooks->gen_ic_profiler) (hist, t, 0);
+         gimple_gen_ic_profiler (hist, t, 0);
          break;
 
        case HIST_TYPE_AVERAGE:
-         (profile_hooks->gen_average_profiler) (hist, t, 0);
+         gimple_gen_average_profiler (hist, t, 0);
          break;
 
        case HIST_TYPE_IOR:
-         (profile_hooks->gen_ior_profiler) (hist, t, 0);
+         gimple_gen_ior_profiler (hist, t, 0);
          break;
 
        default:
@@ -343,7 +341,7 @@ is_inconsistent (void)
         {
          if (dump_file)
            {
-             fprintf (dump_file, "BB %i count does not match sum of incomming edges "
+             fprintf (dump_file, "BB %i count does not match sum of incoming edges "
                       HOST_WIDEST_INT_PRINT_DEC" should be " HOST_WIDEST_INT_PRINT_DEC,
                       bb->index,
                       bb->count,
@@ -411,8 +409,17 @@ read_profile_edge_counts (gcov_type *exec_counts)
                e->count = exec_counts[exec_counts_pos++];
                if (e->count > profile_info->sum_max)
                  {
-                   error ("corrupted profile info: edge from %i to %i exceeds maximal count",
-                          bb->index, e->dest->index);
+                   if (flag_profile_correction)
+                     {
+                       static bool informed = 0;
+                       if (!informed)
+                         inform (input_location,
+                                 "corrupted profile info: edge count exceeds maximal count");
+                       informed = 1;
+                     }
+                   else
+                     error ("corrupted profile info: edge from %i to %i exceeds maximal count",
+                            bb->index, e->dest->index);
                  }
              }
            else
@@ -846,7 +853,7 @@ output_location (char const *file_name, int line,
       return;
     }
 
-  name_differs = !prev_file_name || strcmp (file_name, prev_file_name);
+  name_differs = !prev_file_name || filename_cmp (file_name, prev_file_name);
   line_differs = prev_line != line;
 
   if (name_differs || line_differs)
@@ -935,7 +942,9 @@ branch_prob (void)
          /* It may happen that there are compiler generated statements
             without a locus at all.  Go through the basic block from the
             last to the first statement looking for a locus.  */
-         for (gsi = gsi_last_bb (bb); !gsi_end_p (gsi); gsi_prev (&gsi))
+         for (gsi = gsi_last_nondebug_bb (bb);
+              !gsi_end_p (gsi);
+              gsi_prev_nondebug (&gsi))
            {
              last = gsi_stmt (gsi);
              if (gimple_has_location (last))
@@ -1114,16 +1123,13 @@ branch_prob (void)
   /* Line numbers.  */
   if (coverage_begin_output ())
     {
-      gcov_position_t offset;
-
       /* Initialize the output.  */
       output_location (NULL, 0, NULL, NULL);
 
       FOR_EACH_BB (bb)
        {
          gimple_stmt_iterator gsi;
-
-         offset = 0;
+         gcov_position_t offset = 0;
 
          if (bb == ENTRY_BLOCK_PTR->next_bb)
            {
@@ -1141,15 +1147,14 @@ branch_prob (void)
                                 &offset, bb);
            }
 
-         /* Notice GOTO expressions we eliminated while constructing the
-            CFG.  */
+         /* Notice GOTO expressions eliminated while constructing the CFG.  */
          if (single_succ_p (bb)
              && single_succ_edge (bb)->goto_locus != UNKNOWN_LOCATION)
            {
-             location_t curr_location = single_succ_edge (bb)->goto_locus;
-             /* ??? The FILE/LINE API is inconsistent for these cases.  */
-             output_location (LOCATION_FILE (curr_location),
-                              LOCATION_LINE (curr_location), &offset, bb);
+             expanded_location curr_location
+               = expand_location (single_succ_edge (bb)->goto_locus);
+             output_location (curr_location.file, curr_location.line,
+                              &offset, bb);
            }
 
          if (offset)
@@ -1167,7 +1172,7 @@ branch_prob (void)
 #undef BB_TO_GCOV_INDEX
 
   if (flag_profile_values)
-    find_values_to_profile (&values);
+    gimple_find_values_to_profile (&values);
 
   if (flag_branch_probabilities)
     {
@@ -1184,7 +1189,7 @@ branch_prob (void)
     {
       unsigned n_instrumented;
 
-      profile_hooks->init_edge_profiler ();
+      gimple_init_edge_profiler ();
 
       n_instrumented = instrument_edges (el);
 
@@ -1369,11 +1374,3 @@ end_branch_prob (void)
     }
 }
 
-/* Set up hooks to enable tree-based profiling.  */
-
-void
-tree_register_profile_hooks (void)
-{
-  gcc_assert (current_ir_type () == IR_GIMPLE);
-  profile_hooks = &tree_profile_hooks;
-}