aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorBin Cheng <bin.cheng@linux.alibaba.com>2018-12-19 02:25:48 +0000
committerBin Cheng <amker@gcc.gnu.org>2018-12-19 02:25:48 +0000
commit4469188ce7f228902629595941e1c2ff24b9c4d6 (patch)
treeaa059a871483743547d34a928ed13ef753272f28 /gcc
parent0fb778bcdac1f7c012215971d65edd91d02f606e (diff)
downloadgcc-4469188ce7f228902629595941e1c2ff24b9c4d6.zip
gcc-4469188ce7f228902629595941e1c2ff24b9c4d6.tar.gz
gcc-4469188ce7f228902629595941e1c2ff24b9c4d6.tar.bz2
auto-profile.c (afdo_indirect_call): Skip generating histogram value if we can't find cgraph_node for then...
* auto-profile.c (afdo_indirect_call): Skip generating histogram value if we can't find cgraph_node for then indirected callee. Save profile_id of the cgraph_node in histogram value's first counter. * value-prof.c (gimple_value_profile_transformations): Don't skip for flag_auto_profile. From-SVN: r267249
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog8
-rw-r--r--gcc/auto-profile.c25
-rw-r--r--gcc/value-prof.c5
3 files changed, 21 insertions, 17 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index e9f5baa..12e8f05 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,11 @@
+2018-12-19 Bin Cheng <bin.cheng@linux.alibaba.com>
+
+ * auto-profile.c (afdo_indirect_call): Skip generating histogram
+ value if we can't find cgraph_node for then indirected callee. Save
+ profile_id of the cgraph_node in histogram value's first counter.
+ * value-prof.c (gimple_value_profile_transformations): Don't skip
+ for flag_auto_profile.
+
2018-12-18 Vladimir Makarov <vmakarov@redhat.com>
PR rtl-optimization/87759
diff --git a/gcc/auto-profile.c b/gcc/auto-profile.c
index d337cbc..f22395e 100644
--- a/gcc/auto-profile.c
+++ b/gcc/auto-profile.c
@@ -992,14 +992,6 @@ afdo_indirect_call (gimple_stmt_iterator *gsi, const icall_target_map &map,
|| gimple_call_fndecl (stmt) != NULL_TREE)
return;
- callee = gimple_call_fn (stmt);
-
- histogram_value hist = gimple_alloc_histogram_value (
- cfun, HIST_TYPE_INDIR_CALL, stmt, callee);
- hist->n_counters = 3;
- hist->hvalue.counters = XNEWVEC (gcov_type, hist->n_counters);
- gimple_add_histogram_value (cfun, stmt, hist);
-
gcov_type total = 0;
icall_target_map::const_iterator max_iter = map.end ();
@@ -1010,9 +1002,20 @@ afdo_indirect_call (gimple_stmt_iterator *gsi, const icall_target_map &map,
if (max_iter == map.end () || max_iter->second < iter->second)
max_iter = iter;
}
+ struct cgraph_node *direct_call = cgraph_node::get_for_asmname (
+ get_identifier (afdo_string_table->get_name (max_iter->first)));
+ if (direct_call == NULL || !direct_call->profile_id)
+ return;
- hist->hvalue.counters[0]
- = (unsigned long long)afdo_string_table->get_name (max_iter->first);
+ callee = gimple_call_fn (stmt);
+
+ histogram_value hist = gimple_alloc_histogram_value (
+ cfun, HIST_TYPE_INDIR_CALL, stmt, callee);
+ hist->n_counters = 3;
+ hist->hvalue.counters = XNEWVEC (gcov_type, hist->n_counters);
+ gimple_add_histogram_value (cfun, stmt, hist);
+
+ hist->hvalue.counters[0] = direct_call->profile_id;
hist->hvalue.counters[1] = max_iter->second;
hist->hvalue.counters[2] = total;
@@ -1021,8 +1024,6 @@ afdo_indirect_call (gimple_stmt_iterator *gsi, const icall_target_map &map,
struct cgraph_edge *indirect_edge
= cgraph_node::get (current_function_decl)->get_edge (stmt);
- struct cgraph_node *direct_call = cgraph_node::get_for_asmname (
- get_identifier ((const char *) hist->hvalue.counters[0]));
if (dump_file)
{
diff --git a/gcc/value-prof.c b/gcc/value-prof.c
index f3be9ff..2f39ede 100644
--- a/gcc/value-prof.c
+++ b/gcc/value-prof.c
@@ -627,11 +627,6 @@ gimple_value_profile_transformations (void)
gimple_stmt_iterator gsi;
bool changed = false;
- /* Autofdo does its own transformations for indirect calls,
- and otherwise does not support value profiling. */
- if (flag_auto_profile)
- return false;
-
FOR_EACH_BB_FN (bb, cfun)
{
for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))