[Bug middle-end/65950] exit in main is causing the path to it to become unlikely.
pinskia at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Tue Aug 2 05:37:00 GMT 2016
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65950
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |pinskia at gcc dot gnu.org
--- Comment #10 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Something like:
diff --git a/gcc/predict.c b/gcc/predict.c
index f2b50be..0a571c5 100644
--- a/gcc/predict.c
+++ b/gcc/predict.c
@@ -2081,6 +2081,19 @@ tree_predict_by_opcode (basic_block bb)
}
}
+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
@@ -2208,7 +2221,8 @@ tree_bb_level_predictions (void)
if (is_gimple_call (stmt))
{
if ((gimple_call_flags (stmt) & ECF_NORETURN)
- && has_return_edges)
+ && has_return_edges
+ && !is_exit_with_zero_arg (stmt))
predict_paths_leading_to (bb, PRED_NORETURN,
NOT_TAKEN);
decl = gimple_call_fndecl (stmt);
------ CUT ---
I am testing it right now.
More information about the Gcc-bugs
mailing list