aboutsummaryrefslogtreecommitdiff
path: root/gcc/value-prof.c
diff options
context:
space:
mode:
authorRong Xu <xur@gcc.gnu.org>2014-10-07 04:06:12 +0000
committerRong Xu <xur@gcc.gnu.org>2014-10-07 04:06:12 +0000
commit0a7501658c43bba75e8130f250ae6445eab0ea9f (patch)
tree3f660889ad3bf100d6e658c24a2f620b8f2c0414 /gcc/value-prof.c
parentafe0c5ee91ab504daf13f1c07ee5559b2ba5b6e4 (diff)
downloadgcc-0a7501658c43bba75e8130f250ae6445eab0ea9f.zip
gcc-0a7501658c43bba75e8130f250ae6445eab0ea9f.tar.gz
gcc-0a7501658c43bba75e8130f250ae6445eab0ea9f.tar.bz2
params.def (PARAM_INDIR_CALL_TOPN_PROFILE): New param.
2014-10-06 Rong Xu <xur@google.com> * gcc/params.def (PARAM_INDIR_CALL_TOPN_PROFILE): New param. * gcc/tree-profile.c: (params.h): New include. (init_ic_make_global_vars): Make __gcov_indirect_call_topn_callee and __gcov_indirect_call_topn_counters for indirect_call_topn_profile. (gimple_init_edge_profiler): New decls for __gcov_indirect_call_topn_profiler. (gimple_gen_ic_profiler): Generate the correct profiler call. (gimple_gen_ic_func_profiler): Fix format. * gcc/value-prof.c (params.h): New include. (dump_histogram_value): Hanlde indirect_call_topn counters. (stream_in_histogram_value): Ditto. (gimple_indirect_call_to_profile): Use indirect_call_topn profile when PARAM_INDIR_CALL_TOPN_PROFILE is set. (gimple_find_values_to_profile): Hanlde indirect_call_topn counters. * gcc/value-prof.h (enum hist_type): Histrogram type for indirect_call_topn counters. * gcc/profile.c (instrument_values): Instrument indirect_call_topn counters. From-SVN: r215963
Diffstat (limited to 'gcc/value-prof.c')
-rw-r--r--gcc/value-prof.c42
1 files changed, 36 insertions, 6 deletions
diff --git a/gcc/value-prof.c b/gcc/value-prof.c
index e357967..37710ca 100644
--- a/gcc/value-prof.c
+++ b/gcc/value-prof.c
@@ -60,6 +60,7 @@ along with GCC; see the file COPYING3. If not see
#include "builtins.h"
#include "tree-nested.h"
#include "hash-set.h"
+#include "params.h"
/* In this file value profile based optimizations are placed. Currently the
following optimizations are implemented (for more detailed descriptions
@@ -359,6 +360,22 @@ dump_histogram_value (FILE *dump_file, histogram_value hist)
}
fprintf (dump_file, ".\n");
break;
+ case HIST_TYPE_INDIR_CALL_TOPN:
+ fprintf (dump_file, "Indirect call topn ");
+ if (hist->hvalue.counters)
+ {
+ int i;
+
+ fprintf (dump_file, "accu:%"PRId64, hist->hvalue.counters[0]);
+ for (i = 1; i < (GCOV_ICALL_TOPN_VAL << 2); i += 2)
+ {
+ fprintf (dump_file, " target:%"PRId64 " value:%"PRId64,
+ (int64_t) hist->hvalue.counters[i],
+ (int64_t) hist->hvalue.counters[i+1]);
+ }
+ }
+ fprintf (dump_file, ".\n");
+ break;
case HIST_TYPE_MAX:
gcc_unreachable ();
}
@@ -432,9 +449,14 @@ stream_in_histogram_value (struct lto_input_block *ib, gimple stmt)
break;
case HIST_TYPE_IOR:
- case HIST_TYPE_TIME_PROFILE:
+ case HIST_TYPE_TIME_PROFILE:
ncounters = 1;
break;
+
+ case HIST_TYPE_INDIR_CALL_TOPN:
+ ncounters = (GCOV_ICALL_TOPN_VAL << 2) + 1;
+ break;
+
case HIST_TYPE_MAX:
gcc_unreachable ();
}
@@ -1920,8 +1942,12 @@ gimple_indirect_call_to_profile (gimple stmt, histogram_values *values)
values->reserve (3);
- values->quick_push (gimple_alloc_histogram_value (cfun, HIST_TYPE_INDIR_CALL,
- stmt, callee));
+ values->quick_push (gimple_alloc_histogram_value (
+ cfun,
+ PARAM_VALUE (PARAM_INDIR_CALL_TOPN_PROFILE) ?
+ HIST_TYPE_INDIR_CALL_TOPN :
+ HIST_TYPE_INDIR_CALL,
+ stmt, callee));
return;
}
@@ -2011,9 +2037,9 @@ gimple_find_values_to_profile (histogram_values *values)
hist->n_counters = 3;
break;
- case HIST_TYPE_TIME_PROFILE:
- hist->n_counters = 1;
- break;
+ case HIST_TYPE_TIME_PROFILE:
+ hist->n_counters = 1;
+ break;
case HIST_TYPE_AVERAGE:
hist->n_counters = 2;
@@ -2023,6 +2049,10 @@ gimple_find_values_to_profile (histogram_values *values)
hist->n_counters = 1;
break;
+ case HIST_TYPE_INDIR_CALL_TOPN:
+ hist->n_counters = GCOV_ICALL_TOPN_NCOUNTS;
+ break;
+
default:
gcc_unreachable ();
}