This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[patch] PR40119
- From: Steven Bosscher <stevenb dot gcc at gmail dot com>
- To: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Fri, 12 Feb 2010 22:33:49 +0100
- Subject: [patch] PR40119
Hi,
This fixes PR40119, which concerns a floating-point error
(divide-by-zero) when "--param hot-bb-frequency-fraction=0" is given.
Solution is simple: Catch this exceptional case early.
Bootstrapped&tested on x86_64-unknown-linux-gnu (C only). OK for trunk?
Ciao!
Steven
gcc/
* predict.c (maybe_hot_frequency_p): If a frequency of 0 is also
to be considered "hot", return true at once.
(cgraph_maybe_hot_edge_p): Likewise.
testsuite/
gcc.dg/pr40119.c: New test.
Index: predict.c
===================================================================
--- predict.c (revision 156706)
+++ predict.c (working copy)
@@ -113,6 +113,8 @@ static const struct predictor_info predi
static inline bool
maybe_hot_frequency_p (int freq)
{
+ if (PARAM_VALUE (HOT_BB_FREQUENCY_FRACTION) == 0)
+ return true;
if (!profile_info || !flag_branch_probabilities)
{
if (cfun->function_frequency == FUNCTION_FREQUENCY_UNLIKELY_EXECUTED)
@@ -157,6 +159,8 @@ maybe_hot_bb_p (const_basic_block bb)
bool
cgraph_maybe_hot_edge_p (struct cgraph_edge *edge)
{
+ if (PARAM_VALUE (HOT_BB_FREQUENCY_FRACTION) == 0)
+ return true;
if (profile_info && flag_branch_probabilities
&& (edge->count
<= profile_info->sum_max / PARAM_VALUE (HOT_BB_COUNT_FRACTION)))
Index: testsuite/gcc.dg/pr40119.c
===================================================================
--- testsuite/gcc.dg/pr40119.c (revision 0)
+++ testsuite/gcc.dg/pr40119.c (revision 0)
@@ -0,0 +1,5 @@
+/* PR middle-end/40119 */
+/* { dg-do compile } */
+/* { dg-options "-O --param hot-bb-frequency-fraction=0" } */
+void foo(void) { return; }
+