diff options
author | hubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-03-06 18:57:27 +0000 |
---|---|---|
committer | hubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-03-06 18:57:27 +0000 |
commit | 5de92639376d02c091b93418f3d4a0b25b92c26f (patch) | |
tree | 6db0f16a08d3e0f5d8feea8a59bd2d27420fa52d /gcc/predict.c | |
parent | 4ea69e9efb4ab33b0ce910662afedbc496d319fa (diff) | |
download | gcc-5de92639376d02c091b93418f3d4a0b25b92c26f.tar.gz |
* errors.h (warning, error, fatal, internal_error): Mark as cold.
* predict.c (maybe_hot_bb): Cold functions are never hot; hot functions
are hot.
(probably_cold_bb_p): Cold functions are cold.
(probably_never_executed_bb_p): Cold functions are cold.
(tree_bb_level_predictions): Predict calls to cold functions as not
taken.
(compute_function_frequency): Check hot/cold attributes.
* function.h (function_frequency): Update comments.
* predict.def (PRED_COLD_FUNCTION): Predict cold function.
* c-common.c (handle_hot_attribute, handle_cold_attribute): New.
(c_common_att): Add cold and hot.
* doc/extend.texi (hot,cold attributes): Document.
* ansidecl.h (ATTRIBUTE_COLD, ATTRIBUTE_HOT): New.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@122632 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/predict.c')
-rw-r--r-- | gcc/predict.c | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/gcc/predict.c b/gcc/predict.c index 349ab739140..f8a6a1175f2 100644 --- a/gcc/predict.c +++ b/gcc/predict.c @@ -117,6 +117,13 @@ maybe_hot_bb_p (basic_block bb) && (bb->count < profile_info->sum_max / PARAM_VALUE (HOT_BB_COUNT_FRACTION))) return false; + if (!profile_info || !flag_branch_probabilities) + { + if (cfun->function_frequency == FUNCTION_FREQUENCY_UNLIKELY_EXECUTED) + return false; + if (cfun->function_frequency == FUNCTION_FREQUENCY_HOT) + return true; + } if (bb->frequency < BB_FREQ_MAX / PARAM_VALUE (HOT_BB_FREQUENCY_FRACTION)) return false; return true; @@ -131,6 +138,9 @@ probably_cold_bb_p (basic_block bb) && (bb->count < profile_info->sum_max / PARAM_VALUE (HOT_BB_COUNT_FRACTION))) return true; + if ((!profile_info || !flag_branch_probabilities) + && cfun->function_frequency == FUNCTION_FREQUENCY_UNLIKELY_EXECUTED) + return true; if (bb->frequency < BB_FREQ_MAX / PARAM_VALUE (HOT_BB_FREQUENCY_FRACTION)) return true; return false; @@ -142,6 +152,9 @@ probably_never_executed_bb_p (basic_block bb) { if (profile_info && flag_branch_probabilities) return ((bb->count + profile_info->runs / 2) / profile_info->runs) == 0; + if ((!profile_info || !flag_branch_probabilities) + && cfun->function_frequency == FUNCTION_FREQUENCY_UNLIKELY_EXECUTED) + return true; return false; } @@ -1234,6 +1247,7 @@ tree_bb_level_predictions (void) for (bsi = bsi_start (bb); !bsi_end_p (bsi); bsi_next (&bsi)) { tree stmt = bsi_stmt (bsi); + tree decl; switch (TREE_CODE (stmt)) { case GIMPLE_MODIFY_STMT: @@ -1248,6 +1262,12 @@ call_expr:; if (call_expr_flags (stmt) & ECF_NORETURN) predict_paths_leading_to (bb, heads, PRED_NORETURN, NOT_TAKEN); + decl = get_callee_fndecl (stmt); + if (decl + && lookup_attribute ("cold", + DECL_ATTRIBUTES (decl))) + predict_paths_leading_to (bb, heads, PRED_COLD_FUNCTION, + NOT_TAKEN); break; default: break; @@ -1785,7 +1805,15 @@ compute_function_frequency (void) basic_block bb; if (!profile_info || !flag_branch_probabilities) - return; + { + if (lookup_attribute ("cold", DECL_ATTRIBUTES (current_function_decl)) + != NULL) + cfun->function_frequency = FUNCTION_FREQUENCY_UNLIKELY_EXECUTED; + else if (lookup_attribute ("hot", DECL_ATTRIBUTES (current_function_decl)) + != NULL) + cfun->function_frequency = FUNCTION_FREQUENCY_HOT; + return; + } cfun->function_frequency = FUNCTION_FREQUENCY_UNLIKELY_EXECUTED; FOR_EACH_BB (bb) { |