diff options
Diffstat (limited to 'gcc-4.9/gcc/profile.c')
-rw-r--r-- | gcc-4.9/gcc/profile.c | 45 |
1 files changed, 44 insertions, 1 deletions
diff --git a/gcc-4.9/gcc/profile.c b/gcc-4.9/gcc/profile.c index 83cbc0796..7c59c4393 100644 --- a/gcc-4.9/gcc/profile.c +++ b/gcc-4.9/gcc/profile.c @@ -70,6 +70,7 @@ along with GCC; see the file COPYING3. If not see #include "tree-cfg.h" #include "cfgloop.h" #include "dumpfile.h" +#include "params.h" #include "cgraph.h" #include "profile.h" @@ -106,6 +107,12 @@ static int total_num_times_called; static int total_hist_br_prob[20]; static int total_num_branches; +void add_working_set (gcov_working_set_t *set) { + int i = 0; + for (; i < NUM_GCOV_WORKING_SETS; i++) + gcov_working_sets[i] = set[i]; +} + /* Forward declarations. */ static void find_spanning_tree (struct edge_list *); @@ -161,6 +168,14 @@ instrument_values (histogram_values values) histogram_value hist = values[i]; unsigned t = COUNTER_FOR_HIST_TYPE (hist->type); + /* See condition in gimple_gen_ic_func_topn_profiler */ + if (t == GCOV_COUNTER_ICALL_TOPNV + && (DECL_STATIC_CONSTRUCTOR (current_function_decl) + || DECL_STATIC_CONSTRUCTOR (current_function_decl) + || DECL_NO_INSTRUMENT_FUNCTION_ENTRY_EXIT ( + current_function_decl))) + continue; + if (!coverage_counter_alloc (t, hist->n_counters)) continue; @@ -183,6 +198,7 @@ instrument_values (histogram_values values) break; case HIST_TYPE_INDIR_CALL: + case HIST_TYPE_INDIR_CALL_TOPN: gimple_gen_ic_profiler (hist, t, 0); break; @@ -313,6 +329,7 @@ is_edge_inconsistent (vec<edge, va_gc> *edges) { if (e->count < 0 && (!(e->flags & EDGE_FAKE) + || e->src == ENTRY_BLOCK_PTR_FOR_FN (cfun) || !block_ends_with_call_p (e->src))) { if (dump_file) @@ -862,10 +879,19 @@ compute_value_histograms (histogram_values values, unsigned cfg_checksum, gcov_type *histogram_counts[GCOV_N_VALUE_COUNTERS]; gcov_type *act_count[GCOV_N_VALUE_COUNTERS]; gcov_type *aact_count; + bool warned[GCOV_N_VALUE_COUNTERS]; +#define DEF_GCOV_COUNTER(COUNTER, NAME, FN_TYPE) NAME, + const char *const ctr_names[GCOV_COUNTERS] = { +#include "gcov-counter.def" +}; +#undef DEF_GCOV_COUNTER struct cgraph_node *node; for (t = 0; t < GCOV_N_VALUE_COUNTERS; t++) - n_histogram_counters[t] = 0; + { + n_histogram_counters[t] = 0; + warned[t] = 0; + } for (i = 0; i < values.length (); i++) { @@ -901,6 +927,19 @@ compute_value_histograms (histogram_values values, unsigned cfg_checksum, t = (int) hist->type; aact_count = act_count[t]; + /* If the counter cannot be found in gcda file, skip this + histogram and give a warning. */ + if (aact_count == 0) + { + if (!warned[t]) + warning (0, "cannot find %s counters in function %s.", + ctr_names[COUNTER_FOR_HIST_TYPE(t)], + IDENTIFIER_POINTER ( + DECL_ASSEMBLER_NAME (current_function_decl))); + hist->n_counters = 0; + warned[t] = true; + continue; + } if (act_count[t]) act_count[t] += hist->n_counters; @@ -1322,6 +1361,10 @@ branch_prob (void) /* Commit changes done by instrumentation. */ gsi_commit_edge_inserts (); + + if (flag_profile_generate_sampling + || PARAM_VALUE (PARAM_COVERAGE_EXEC_ONCE)) + add_sampling_to_edge_counters (); } free_aux_for_edges (); |