[Bug tree-optimization/40570] [4.5 Regression] ICE with recursion at -O3

jamborm at gcc dot gnu dot org gcc-bugzilla@gcc.gnu.org
Tue Jul 28 20:59:00 GMT 2009



------- Comment #7 from jamborm at gcc dot gnu dot org  2009-07-28 20:59 -------
Ha, please disregard the previous message, obviously I had to make a
fool out of myself before realizing that loops in the inlining plan
are the bug, not how we handle them.

The reason there are such loops is that ipa-cp has made a portion of
the graph effectively dead but strongly connected via single uses
which ipa-inline handles specially and wants to inline them whenever
it seems possible.  But it sis not check for loops.

So, I belive the patch below fixes this issue and I am going to
bootstrap it overnight.  Honza, can you please confirm this is indeed
a correct fix?  Thanks.


2009-07-28  Martin Jambor  <mjambor@suse.cz>

        * ipa-inline.c (cgraph_decide_inlining): Watch out for dead single
        use inlining loops.

        * testsuite/gcc.c-torture/compile/pr40570.c: New test.


Index: icln/gcc/ipa-inline.c
===================================================================
--- icln.orig/gcc/ipa-inline.c
+++ icln/gcc/ipa-inline.c
@@ -1227,6 +1227,7 @@ cgraph_decide_inlining (void)
              && !node->needed
              && node->local.inlinable
              && node->callers->inline_failed
+             && node->callers->caller->global.inlined_to != node
              && !gimple_call_cannot_inline_p (node->callers->call_stmt)
              && !DECL_EXTERNAL (node->decl)
              && !DECL_COMDAT (node->decl))
Index: icln/gcc/testsuite/gcc.c-torture/compile/pr40570.c
===================================================================
--- /dev/null
+++ icln/gcc/testsuite/gcc.c-torture/compile/pr40570.c
@@ -0,0 +1,19 @@
+static int foo(int i);
+
+static int bar(int i) { foo(i); }
+
+static int foo(int i)
+{
+  int j;
+  if (j)
+    FOO(j);
+  return bar(i);
+}
+
+int baz()
+{
+  foo(0);
+  if (baz())
+    return 1;
+  return 0;
+}


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40570



More information about the Gcc-bugs mailing list