re PR middle-end/78306 ([CilkPlus] "inlining failed in call to always_inline ‘memset...
authorRichard Biener <rguenther@suse.de>
Thu, 17 Nov 2016 08:42:50 +0000 (08:42 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Thu, 17 Nov 2016 08:42:50 +0000 (08:42 +0000)
2016-11-17  Richard Biener  <rguenther@suse.de>

PR tree-optimization/78306
* ipa-inline-analysis.c (initialize_inline_failed): Do not
inhibit inlining if function calls cilk_spawn.
(can_inline_edge_p): Likewise.

* gcc.dg/cilk-plus/pr78306.c: New testcase.

From-SVN: r242537

gcc/ChangeLog
gcc/ipa-inline-analysis.c
gcc/ipa-inline.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/cilk-plus/pr78306.c [new file with mode: 0644]

index b8e527aa59a269f58000db0dffff125d096cc0b6..d70f88df81d76698f404fa54d962a9a8ebda5437 100644 (file)
@@ -1,3 +1,10 @@
+2016-11-17  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/78306
+       * ipa-inline-analysis.c (initialize_inline_failed): Do not
+       inhibit inlining if function calls cilk_spawn.
+       (can_inline_edge_p): Likewise.
+
 2016-11-17  Richard Biener  <rguenther@suse.de>
 
        PR middle-end/78305
index 8228e8ae3e8a272046a85841b49cf10b86a72f10..1b5f805d2bcc36937cd1084db3163fdd0f8b24e6 100644 (file)
@@ -1507,9 +1507,6 @@ initialize_inline_failed (struct cgraph_edge *e)
     e->inline_failed = CIF_BODY_NOT_AVAILABLE;
   else if (callee->local.redefined_extern_inline)
     e->inline_failed = CIF_REDEFINED_EXTERN_INLINE;
-  else if (cfun && fn_contains_cilk_spawn_p (cfun))
-    /* We can't inline if the function is spawing a function.  */
-    e->inline_failed = CIF_CILK_SPAWN;
   else
     e->inline_failed = CIF_FUNCTION_NOT_CONSIDERED;
   gcc_checking_assert (!e->call_stmt_cannot_inline_p
index 82bb94fa1aa230c69c210d5c5f3c24fcdbad020d..5f2371c6b2619ad4c615dea5c3e77c12c88ed4d5 100644 (file)
@@ -368,11 +368,6 @@ can_inline_edge_p (struct cgraph_edge *e, bool report,
       e->inline_failed = CIF_FUNCTION_NOT_INLINABLE;
       inlinable = false;
     }
-  else if (inline_summaries->get (caller)->contains_cilk_spawn)
-    {
-      e->inline_failed = CIF_CILK_SPAWN;
-      inlinable = false;
-    }
   /* Don't inline a function with mismatched sanitization attributes. */
   else if (!sanitize_attrs_match_for_inline_p (caller->decl, callee->decl))
     {
index c142b4b013dde77fcfe458c428124f3c7a892cf1..9545d9cce79e2c4bb3c2bd92d9a4bfb7ac89bee1 100644 (file)
@@ -1,3 +1,8 @@
+2016-11-17  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/78306
+       * gcc.dg/cilk-plus/pr78306.c: New testcase.
+
 2016-11-17  Richard Biener  <rguenther@suse.de>
 
        PR middle-end/78305
diff --git a/gcc/testsuite/gcc.dg/cilk-plus/pr78306.c b/gcc/testsuite/gcc.dg/cilk-plus/pr78306.c
new file mode 100644 (file)
index 0000000..4604271
--- /dev/null
@@ -0,0 +1,30 @@
+/* { dg-do run } */
+/* { dg-options "-O2 -fcilkplus" } */
+
+#define _FORTIFY_SOURCE 2
+#include <string.h>
+
+int sum(int low, int high)
+{
+  if(low == high) {
+    return low;
+  }
+
+  int mid = low + (high-low)/2;
+  int a = _Cilk_spawn sum(low, mid);
+  int b = sum(mid+1, high);
+
+  // Some very expensive computation here
+  int foo[64];
+  memset(foo, 0, 64*sizeof(int)); // <--- Fails
+
+  _Cilk_sync;
+
+  return a+b;
+}
+
+int main(void) {
+  if (sum(0, 100) != 5050)
+    __builtin_abort ();
+  return 0;
+}