This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: _Cilk_spawn and _Cilk_sync for C++

On 11/17/2013 10:19 PM, Iyer, Balaji V wrote:
   cp/cp-cilkplus.o \
- cp/cp-gimplify.o cp/cp-array-notation.o cp/lambda.o \
+ cp/cp-gimplify.o cp/cp-array-notation.o cp/lambda.o cp/cp-cilk.o \

It seems unnecessary to have both cp-cilk.c and cp-cilkplus.c. Please combine them.

+  extern tree do_begin_catch (void);
+  extern tree do_end_catch (tree);

If you want to use these, they need to be declared in cp-tree.h, not within another function. Or better yet, factor out this code:

+      append_to_statement_list (do_begin_catch (), &catch_list);
+      append_to_statement_list (build_throw (NULL_TREE), &catch_list);
+      tree catch_tf_expr = build_stmt (EXPR_LOCATION (body), TRY_FINALLY_EXPR,
+				       catch_list, do_end_catch (NULL_TREE));
+      catch_list = build2 (CATCH_EXPR, void_type_node, NULL_TREE,
+			   catch_tf_expr);
+      tree try_catch_expr = build_stmt (EXPR_LOCATION (body), TRY_CATCH_EXPR,
+					body, catch_list);

...into a function in cp/except.c.

+      tree try_finally_expr = build_stmt (EXPR_LOCATION (body),
+				     try_catch_expr, dtor);
+      append_to_statement_list (try_finally_expr, &list);
+    }
+  else
+    append_to_statement_list (build_stmt (EXPR_LOCATION (body),
+					  TRY_FINALLY_EXPR, body, dtor), &list);

This bit could be shared between the two branches.

+  /* When Cilk Plus is enabled, the lambda function need to be stored to
+     a variable because if the function is spawned, then we need some kind
+     of a handle.  */
+  if (flag_enable_cilkplus && cxx_dialect >= cxx0x
+      && TREE_CODE (fn) != VAR_DECL && TREE_CODE (fn) != OVERLOAD
+      && TREE_CODE (fn) != FUNCTION_DECL)
+    fn = cilk_create_lambda_fn_tmp_var (fn);

I don't like making this change here. What do you need a handle for? Why can't build_cilk_spawn deal with it?

+    case CILK_SPAWN_STMT:
+      if (!potential_constant_expression_1 (CILK_SPAWN_FN (t), true, flags))
+	return false;
+      return true;

Isn't Cilk spawn itself is non-constant, so you can just return false?


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]