This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: _Cilk_spawn and _Cilk_sync for C++
- From: Jason Merrill <jason at redhat dot com>
- To: "Iyer, Balaji V" <balaji dot v dot iyer at intel dot com>, "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>
- Cc: Jeff Law <law at redhat dot com>
- Date: Thu, 21 Nov 2013 13:58:38 -0500
- Subject: Re: _Cilk_spawn and _Cilk_sync for C++
- Authentication-results: sourceware.org; auth=none
- References: <BF230D13CA30DD48930C31D4099330003A4A696B at FMSMSX101 dot amr dot corp dot intel dot com>
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_FINALLY_EXPR,
+ 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?
Jason