From: Martin Jambor Date: Tue, 13 Dec 2011 15:43:36 +0000 (+0100) Subject: re PR tree-optimization/51362 (ICE: SIGFPE (division by zero) in good_cloning_opportu... X-Git-Tag: releases/gcc-4.7.0~1573 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0318fc774964ac07f2bc1c9672cfa75b5355501b;p=thirdparty%2Fgcc.git re PR tree-optimization/51362 (ICE: SIGFPE (division by zero) in good_cloning_opportunity_p at ipa-cp.c:2401) 2011-12-13 Martin Jambor PR tree-optimization/51362 * ipa-cp.c (estimate_local_effects): When estimated size of a specialized clone is zero, bump it to one. * testsuite/gcc.dg/ipa/pr51362.c: New test. From-SVN: r182288 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index a7107642c75c..3b28a5d10fc2 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2011-12-13 Martin Jambor + + PR tree-optimization/51362 + * ipa-cp.c (estimate_local_effects): When estimated size of a + specialized clone is zero, bump it to one. + 2011-12-13 Richard Guenther PR lto/48354 diff --git a/gcc/ipa-cp.c b/gcc/ipa-cp.c index 1c5a58241e12..2a82df1032ff 100644 --- a/gcc/ipa-cp.c +++ b/gcc/ipa-cp.c @@ -1409,6 +1409,14 @@ estimate_local_effects (struct cgraph_node *node) + devirtualization_time_bonus (node, known_csts, known_binfos) + removable_params_cost + emc; + gcc_checking_assert (size >=0); + /* The inliner-heuristics based estimates may think that in certain + contexts some functions do not have any size at all but we want + all specializations to have at least a tiny cost, not least not to + divide by zero. */ + if (size == 0) + size = 1; + if (dump_file && (dump_flags & TDF_DETAILS)) { fprintf (dump_file, " - estimates for value "); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 35230eb5ec22..e5fa8ba4ee0e 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2011-12-13 Martin Jambor + + PR tree-optimization/51362 + * gcc.dg/ipa/pr51362.c: New test. + 2011-12-13 Uros Bizjak PR testsuite/51524 diff --git a/gcc/testsuite/gcc.dg/ipa/pr51362.c b/gcc/testsuite/gcc.dg/ipa/pr51362.c new file mode 100644 index 000000000000..e57dd565688c --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/pr51362.c @@ -0,0 +1,22 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fipa-cp -fipa-cp-clone" } */ + +int +baz (void) +{ + return 0; +} + +int make_mess; + +__attribute__ ((noinline)) +int bar (int x, int (*f) (void)) +{ + return f (); +} + +int +foo (void) +{ + return bar (1, baz); +}