]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR tree-optimization/51362 (ICE: SIGFPE (division by zero) in good_cloning_opportu...
authorMartin Jambor <mjambor@suse.cz>
Tue, 13 Dec 2011 15:43:36 +0000 (16:43 +0100)
committerMartin Jambor <jamborm@gcc.gnu.org>
Tue, 13 Dec 2011 15:43:36 +0000 (16:43 +0100)
2011-12-13  Martin Jambor  <mjambor@suse.cz>

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

gcc/ChangeLog
gcc/ipa-cp.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/ipa/pr51362.c [new file with mode: 0644]

index a7107642c75c961d3f51289e6e4c6cd48389ad32..3b28a5d10fc273d743145ee1244feda20ced0b09 100644 (file)
@@ -1,3 +1,9 @@
+2011-12-13  Martin Jambor  <mjambor@suse.cz>
+
+       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  <rguenther@suse.de>
 
        PR lto/48354
index 1c5a58241e12afdf64e8acefbe1389480aa5d8d4..2a82df1032ff277d8efb6a5a83c204273cd9a8d9 100644 (file)
@@ -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 ");
index 35230eb5ec22fb48afcc036b98e01c6af7681fe4..e5fa8ba4ee0e6d30c2719ff524c66497fc7d9e7b 100644 (file)
@@ -1,3 +1,8 @@
+2011-12-13  Martin Jambor  <mjambor@suse.cz>
+
+       PR tree-optimization/51362
+       * gcc.dg/ipa/pr51362.c: New test.
+
 2011-12-13  Uros Bizjak  <ubizjak@gmail.com>
 
        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 (file)
index 0000000..e57dd56
--- /dev/null
@@ -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);
+}