diff options
author | Andrew Pinski <apinski@cavium.com> | 2016-10-18 15:42:21 +0000 |
---|---|---|
committer | Andrew Pinski <pinskia@gcc.gnu.org> | 2016-10-18 08:42:21 -0700 |
commit | e25a366f6fbfec00094d243a41b0d9dacdd66575 (patch) | |
tree | 70307918b5e308ff62590061ea8e9064e63d6288 /gcc/predict.c | |
parent | 5cb96b6a87ec58038803fd093974e383483ed76e (diff) | |
download | gcc-e25a366f6fbfec00094d243a41b0d9dacdd66575.zip gcc-e25a366f6fbfec00094d243a41b0d9dacdd66575.tar.gz gcc-e25a366f6fbfec00094d243a41b0d9dacdd66575.tar.bz2 |
re PR middle-end/65950 (exit in main is causing the path to it to become unlikely.)
2016-10-18 Andrew Pinski <apinski@cavium.com>
PR tree-opt/65950
* predict.c (is_exit_with_zero_arg): New function.
(tree_bb_level_predictions): Don't consider paths leading to exit(0)
as nottaken.
From-SVN: r241309
Diffstat (limited to 'gcc/predict.c')
-rw-r--r-- | gcc/predict.c | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/gcc/predict.c b/gcc/predict.c index 9950c09..1bf04d1 100644 --- a/gcc/predict.c +++ b/gcc/predict.c @@ -2512,6 +2512,21 @@ tree_predict_by_opcode (basic_block bb) } } +/* Returns TRUE if the STMT is exit(0) like statement. */ + +static bool +is_exit_with_zero_arg (const gimple *stmt) +{ + /* This is not exit, _exit or _Exit. */ + if (!gimple_call_builtin_p (stmt, BUILT_IN_EXIT) + && !gimple_call_builtin_p (stmt, BUILT_IN__EXIT) + && !gimple_call_builtin_p (stmt, BUILT_IN__EXIT2)) + return false; + + /* Argument is an interger zero. */ + return integer_zerop (gimple_call_arg (stmt, 0)); +} + /* Try to guess whether the value of return means error code. */ static enum br_predictor @@ -2638,7 +2653,9 @@ tree_bb_level_predictions (void) if (is_gimple_call (stmt)) { - if (gimple_call_noreturn_p (stmt) && has_return_edges) + if (gimple_call_noreturn_p (stmt) + && has_return_edges + && !is_exit_with_zero_arg (stmt)) predict_paths_leading_to (bb, PRED_NORETURN, NOT_TAKEN); decl = gimple_call_fndecl (stmt); |