aboutsummaryrefslogtreecommitdiff
path: root/gcc/predict.c
diff options
context:
space:
mode:
authorMartin Jambor <mjambor@suse.cz>2012-08-24 12:57:24 +0000
committerMartin Jambor <mjambor@suse.cz>2012-08-24 12:57:24 +0000
commitad820100fd978e72fc043f4f031533baaad6ef15 (patch)
treeb1213a8631b75e45f38fd88f7776c25b9fafe3b3 /gcc/predict.c
parentf88026d9383e1e0eeadd3ff32cafcde7242e058e (diff)
2012-08-24 Martin Jambor <mjambor@suse.cz>
* predict.c (maybe_hot_frequency_p): New parameter fun. Use its decl instead of current_function_decl, use profile_status_for_function and ENTRY_BLOCK_PTR_FOR_FUNCTION with fun instead of their cfun variants. (maybe_hot_count_p): New parameter fun, use profile_status_for_function instead of its cfun_variant. (maybe_hot_bb_p): New parameter fun, checking-assert it, pass it to all callees. (maybe_hot_edge_p): Pass cfun to maybe_hot_count_p and maybe_hot_frequency_p. (probably_never_executed_bb_p): New parameter fun, use its decl instead of current_function_decl. (optimize_bb_for_size_p): Pass cfun to maybe_hot_bb_p. (rtl_profile_for_bb): Likewise. (compute_function_frequency): Pass cfun to maybe_hot_bb_p and probably_never_executed_bb_p. * tree-ssa-operands.c (ssa_operands_active): New operator fun. Use it instead of cfun. (update_stmt_operands): Pass cfun as an argument of ssa_operands_active. (swap_tree_operands): Likewise. * gimple-iterator.c (update_modified_stmt): Likewise. (update_modified_stmts): Likewise. * tree-flow-inline.h (delink_stmt_imm_use): Likewise. * tree-ssa.c (delete_tree_ssa): Likewise. * bb-reorder.c (bb_to_key): Pass cfun to probably_never_executed_bb_p. (push_to_next_round_p): Likewise. (find_rarely_executed_basic_blocks_and_crossing_edges ): Likewise. * cfg.c: Inlude tree.h. (check_bb_profile): Use profile_status_for_function, EXIT_BLOCK_PTR_FOR_FUNCTION and ENTRY_BLOCK_PTR_FOR_FUNCTION with DECL_STRUCT_FUNCTION (current_function_decl) instead of their cfun variants. (dump_bb_info): Pass DECL_STRUCT_FUNCTION (current_function_decl) to maybe_hot_bb_p and probably_never_executed_bb_p. * gimple-pretty-print.c (gimple_dump_bb_buff): Checking-assert that DECL_STRUCT_FUNCTION (current_function_decl) is not NULL. Pass it to dump_histograms_for_stmt. (dump_gimple_mem_ops): Pass DECL_STRUCT_FUNCTION (current_function_decl) as an argument to dump_gimple_mem_ops. * tree-cfg.c (dump_function_to_file): Rename parameter fn to fndecl. Do not change cfun. Change and restore current_function_decl. * Makefile.in (cfg.o): Include TREE_H in dependencies. git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@190645 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/predict.c')
-rw-r--r--gcc/predict.c45
1 files changed, 22 insertions, 23 deletions
diff --git a/gcc/predict.c b/gcc/predict.c
index e1a064d6cde..f0db9f40330 100644
--- a/gcc/predict.c
+++ b/gcc/predict.c
@@ -108,9 +108,9 @@ static const struct predictor_info predictor_info[]= {
/* Return TRUE if frequency FREQ is considered to be hot. */
static inline bool
-maybe_hot_frequency_p (int freq)
+maybe_hot_frequency_p (struct function *fun, int freq)
{
- struct cgraph_node *node = cgraph_get_node (current_function_decl);
+ struct cgraph_node *node = cgraph_get_node (fun->decl);
if (!profile_info || !flag_branch_probabilities)
{
if (node->frequency == NODE_FREQUENCY_UNLIKELY_EXECUTED)
@@ -118,12 +118,13 @@ maybe_hot_frequency_p (int freq)
if (node->frequency == NODE_FREQUENCY_HOT)
return true;
}
- if (profile_status == PROFILE_ABSENT)
+ if (profile_status_for_function (fun) == PROFILE_ABSENT)
return true;
if (node->frequency == NODE_FREQUENCY_EXECUTED_ONCE
- && freq < (ENTRY_BLOCK_PTR->frequency * 2 / 3))
+ && freq < (ENTRY_BLOCK_PTR_FOR_FUNCTION (fun)->frequency * 2 / 3))
return false;
- if (freq < ENTRY_BLOCK_PTR->frequency / PARAM_VALUE (HOT_BB_FREQUENCY_FRACTION))
+ if (freq < (ENTRY_BLOCK_PTR_FOR_FUNCTION (fun)->frequency
+ / PARAM_VALUE (HOT_BB_FREQUENCY_FRACTION)))
return false;
return true;
}
@@ -131,9 +132,9 @@ maybe_hot_frequency_p (int freq)
/* Return TRUE if frequency FREQ is considered to be hot. */
static inline bool
-maybe_hot_count_p (gcov_type count)
+maybe_hot_count_p (struct function *fun, gcov_type count)
{
- if (profile_status != PROFILE_READ)
+ if (profile_status_for_function (fun) != PROFILE_READ)
return true;
/* Code executed at most once is not hot. */
if (profile_info->runs >= count)
@@ -146,13 +147,12 @@ maybe_hot_count_p (gcov_type count)
for maximal performance. */
bool
-maybe_hot_bb_p (const_basic_block bb)
+maybe_hot_bb_p (struct function *fun, const_basic_block bb)
{
- /* Make sure CFUN exists, for dump_bb_info. */
- gcc_assert (cfun);
- if (profile_status == PROFILE_READ)
- return maybe_hot_count_p (bb->count);
- return maybe_hot_frequency_p (bb->frequency);
+ gcc_checking_assert (fun);
+ if (profile_status_for_function (fun) == PROFILE_READ)
+ return maybe_hot_count_p (fun, bb->count);
+ return maybe_hot_frequency_p (fun, bb->frequency);
}
/* Return true if the call can be hot. */
@@ -193,22 +193,21 @@ bool
maybe_hot_edge_p (edge e)
{
if (profile_status == PROFILE_READ)
- return maybe_hot_count_p (e->count);
- return maybe_hot_frequency_p (EDGE_FREQUENCY (e));
+ return maybe_hot_count_p (cfun, e->count);
+ return maybe_hot_frequency_p (cfun, EDGE_FREQUENCY (e));
}
/* Return true in case BB is probably never executed. */
bool
-probably_never_executed_bb_p (const_basic_block bb)
+probably_never_executed_bb_p (struct function *fun, const_basic_block bb)
{
- /* Make sure CFUN exists, for dump_bb_info. */
- gcc_assert (cfun);
+ gcc_checking_assert (fun);
if (profile_info && flag_branch_probabilities)
return ((bb->count + profile_info->runs / 2) / profile_info->runs) == 0;
if ((!profile_info || !flag_branch_probabilities)
- && (cgraph_get_node (current_function_decl)->frequency
+ && (cgraph_get_node (fun->decl)->frequency
== NODE_FREQUENCY_UNLIKELY_EXECUTED))
return true;
return false;
@@ -252,7 +251,7 @@ optimize_function_for_speed_p (struct function *fun)
bool
optimize_bb_for_size_p (const_basic_block bb)
{
- return optimize_function_for_size_p (cfun) || !maybe_hot_bb_p (bb);
+ return optimize_function_for_size_p (cfun) || !maybe_hot_bb_p (cfun, bb);
}
/* Return TRUE when BB should be optimized for speed. */
@@ -369,7 +368,7 @@ predictable_edge_p (edge e)
void
rtl_profile_for_bb (basic_block bb)
{
- crtl->maybe_hot_insn_p = maybe_hot_bb_p (bb);
+ crtl->maybe_hot_insn_p = maybe_hot_bb_p (cfun, bb);
}
/* Set RTL expansion for edge profile. */
@@ -2705,12 +2704,12 @@ compute_function_frequency (void)
node->frequency = NODE_FREQUENCY_UNLIKELY_EXECUTED;
FOR_EACH_BB (bb)
{
- if (maybe_hot_bb_p (bb))
+ if (maybe_hot_bb_p (cfun, bb))
{
node->frequency = NODE_FREQUENCY_HOT;
return;
}
- if (!probably_never_executed_bb_p (bb))
+ if (!probably_never_executed_bb_p (cfun, bb))
node->frequency = NODE_FREQUENCY_NORMAL;
}
}