[cilkplus] Fix cilk_spawn gimplification bug (PR cilkplus/69048)

Ryan Burn rnickb731@gmail.com
Thu Jan 14 21:19:00 GMT 2016


This patch adds a missing cleanup point to cilk_spawn expressions to
prevent an ICE when calling functions that return types with
non-trivial destructors.

Bootstrapped and regression tested on x86_64-linux.

2015-01-14 Ryan Burn  <contact@rnburn.com>

     PR c++/69048
       * cilk.c (create_cilk_wrapper_body): Call
fold_build_cleanup_point_expr to add missing cleanup point.

       * gcc/testsuite/g++.dg/cilk-plus/CK/pr69048.cc: New test
-------------- next part --------------
Index: gcc/c-family/cilk.c
===================================================================
--- gcc/c-family/cilk.c	(revision 232359)
+++ gcc/c-family/cilk.c	(working copy)
@@ -592,6 +592,11 @@
   for (p = wd->parms; p; p = TREE_CHAIN (p))
     DECL_CONTEXT (p) = fndecl;
 
+  /* The statement containing the spawn expression might create temporaries with
+     destructors defined; if so we need to add a CLEANUP_POINT_EXPR to ensure
+     the expression is properly gimplified.  */
+  stmt = fold_build_cleanup_point_expr (void_type_node, stmt);
+
   gcc_assert (!DECL_SAVED_TREE (fndecl));
   cilk_install_body_with_frame_cleanup (fndecl, stmt, (void *) wd);
   gcc_assert (DECL_SAVED_TREE (fndecl));
Index: gcc/testsuite/g++.dg/cilk-plus/CK/pr69048.cc
===================================================================
--- gcc/testsuite/g++.dg/cilk-plus/CK/pr69048.cc	(revision 0)
+++ gcc/testsuite/g++.dg/cilk-plus/CK/pr69048.cc	(working copy)
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* { dg-options "-fcilkplus" } */
+
+struct A {
+  ~A () {}
+};
+
+A f () {
+  return A ();
+}
+
+void t1 () {
+  _Cilk_spawn f ();
+}


More information about the Gcc-patches mailing list