re PR lto/65130 (ICE with LTO on valid code on x86_64-linux-gnu)
authorJan Hubicka <hubicka@ucw.cz>
Mon, 2 Mar 2015 20:31:21 +0000 (21:31 +0100)
committerJan Hubicka <hubicka@gcc.gnu.org>
Mon, 2 Mar 2015 20:31:21 +0000 (20:31 +0000)
PR ipa/65130
* ipa-inline.c (check_callers): Looks for recursion.
(inline_to_all_callers): Give up on uninlinable or recursive edges.
* ipa-inline-analysis.c (inline_summary_t::duplicate): Do not update
summary of inline clones.
(do_estimate_growth_1): Fix recursion check.

* gcc.dg/lto/pr65130_0.c: New testcase.
* gcc.dg/lto/pr65130_1.c: New testcase.

From-SVN: r221124

gcc/ChangeLog
gcc/ipa-inline-analysis.c
gcc/ipa-inline.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/lto/pr65130_0.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/lto/pr65130_1.c [new file with mode: 0644]

index f84b46281da02eebcfbc07a1e221053fac972e19..f9c093282b816ed8b6b175258f43df2eb9fc3dc6 100644 (file)
@@ -1,3 +1,12 @@
+2015-03-02  Jan Hubicka   <hubicka@ucw.cz>
+
+       PR ipa/65130
+       * ipa-inline.c (check_callers): Looks for recursion.
+       (inline_to_all_callers): Give up on uninlinable or recursive edges.
+       * ipa-inline-analysis.c (inline_summary_t::duplicate): Do not update
+       summary of inline clones.
+       (do_estimate_growth_1): Fix recursion check.
+
 2015-03-02  Jan Hubicka   <hubicka@ucw.cz>
 
        PR ipa/64988
index be178ad445c27ad543700409b3c288f1a17b18a5..7a9c99cc512c0cb5bc4355e6927e58ff2a471a46 100644 (file)
@@ -1291,7 +1291,8 @@ inline_summary_t::duplicate (cgraph_node *src,
          set_hint_predicate (&info->array_index, p);
        }
     }
-  inline_update_overall_summary (dst);
+  if (!dst->global.inlined_to)
+    inline_update_overall_summary (dst);
 }
 
 
@@ -3924,10 +3925,11 @@ do_estimate_growth_1 (struct cgraph_node *node, void *data)
           continue;
        }
 
-      if (e->caller == d->node
-         || (e->caller->global.inlined_to
-             && e->caller->global.inlined_to == d->node))
-       d->self_recursive = true;
+      if (e->recursive_p ())
+       {
+         d->self_recursive = true;
+         continue;
+       }
       d->growth += estimate_edge_growth (e);
     }
   return false;
index db77d12e85fe441fe74458d6ec4c368e59b9fff9..0b38b4c6225c6823b2a0f8a3176ef11dfe9292f5 100644 (file)
@@ -952,6 +952,8 @@ check_callers (struct cgraph_node *node, void *has_hot_call)
         return true;
        if (!can_inline_edge_p (e, true))
          return true;
+       if (e->recursive_p ())
+        return true;
        if (!(*(bool *)has_hot_call) && e->maybe_hot_p ())
         *(bool *)has_hot_call = true;
      }
@@ -2094,6 +2096,15 @@ inline_to_all_callers (struct cgraph_node *node, void *data)
     {
       struct cgraph_node *caller = node->callers->caller;
 
+      if (!can_inline_edge_p (node->callers, true)
+         || node->callers->recursive_p ())
+       {
+         if (dump_file)
+           fprintf (dump_file, "Uninlinable call found; giving up.\n");
+         *num_calls = 0;
+         return false;
+       }
+
       if (dump_file)
        {
          fprintf (dump_file,
index 135f73498b4f17443ee39247c9e22a77c6db7f94..4555c13782a13567a9d0550ec1459a630e8550b2 100644 (file)
@@ -1,3 +1,9 @@
+2015-03-02  Jan Hubicka   <hubicka@ucw.cz>
+
+       PR ipa/65130
+       * gcc.dg/lto/pr65130_0.c: New testcase.
+       * gcc.dg/lto/pr65130_1.c: New testcase.
+
 2015-03-02  Jan Hubicka   <hubicka@ucw.cz>
 
        PR ipa/64988
diff --git a/gcc/testsuite/gcc.dg/lto/pr65130_0.c b/gcc/testsuite/gcc.dg/lto/pr65130_0.c
new file mode 100644 (file)
index 0000000..5b68560
--- /dev/null
@@ -0,0 +1,19 @@
+/* { dg-lto-do link } */
+/* { dg-lto-options { { -flto -O1 -fdevirtualize } } } */
+extern void fn3 (void); 
+
+void fn2(void) 
+{ 
+  fn3(); 
+}
+
+void fn1(void) 
+{ 
+  fn2(); 
+}
+
+void fn4(void) 
+{ 
+  fn2(); 
+}
+
diff --git a/gcc/testsuite/gcc.dg/lto/pr65130_1.c b/gcc/testsuite/gcc.dg/lto/pr65130_1.c
new file mode 100644 (file)
index 0000000..1bfaa15
--- /dev/null
@@ -0,0 +1,17 @@
+/* { dg-options "-O2 -fdevirtualize" } */
+extern void fn1(void);
+extern void fn4 (void); 
+
+int a; 
+
+void fn3(void) 
+{
+  for (; a;)
+    fn4();
+}
+
+int main() {
+  fn1();
+  return 0;
+}
+