Re: [PATCH][cilkplus] fix c++ implicit conversions with cilk_spawn (PR/69024, PR/68997)
On 01/20/2016 10:57 AM, Ryan Burn wrote: This patch follows on from https://gcc.gnu.org/ml/gcc-patches/2015-12/msg02142.html As discussed, it creates a separate function cilk_cp_detect_spawn_and_unwrap in gcc/cp to handle processing cilk_spawn expressions for c++ and adds support for implicit constructor and type conversions. Bootstrapped and regression tested on x86_64-linux. gcc/c-family/ChangeLog: 2015-01-20 Ryan BurnPR c++/69024 PR c++/68997 * cilk.c (cilk_ignorable_spawn_rhs_op): Change to have external linkage. * cilk.c (recognize_spawn): Rename to cilk_recognize_spawn. Change to have external linkage. * cilk.c (cilk_detect_and_unwrap): Rename to recognize_spawn to cilk_recognize_spawn. * cilk.c (extract_free_variables): Don't extract free variables from AGGR_INIT_EXPR slot. gcc/cp/ChangeLog 2015-01-20 Ryan Burn PR c++/69024 PR c++/68997 * cp-gimplify.c (cp_gimplify_expr): Call cilk_cp_detect_spawn_and_unwrap instead of cilk_detect_spawn_and_unwrap. * cp-cilkplus.c (is_conversion_operator_function_decl_p): New. * cp-cilkplus.c (find_spawn): New. * cp-cilkplus.c (cilk_cp_detect_spawn_and_unwrap): New. gcc/testsuite/ChangeLog 2015-01-20 Ryan Burn PR c++/69024 PR c++/68997 * g++.dg/cilk-plus/CK/pr68001.cc: Fix to not depend on broken diagnostic. * g++.dg/cilk-plus/CK/pr69024.cc: New test. * g++.dg/cilk-plus/CK/pr68997.cc: New test. The updated patch (as expected) bootstrapped and regression tested. I fixed a few more whitespace/formatting nits, updated the ChangeLogs and committed the change. Jeff commit adc44ab035896ab23180ed4bd552226610e958ab Author: Jeff Law Date: Wed Apr 27 14:39:01 2016 -0600 PR c++/69024 PR c++/68997 * cilk.c (cilk_ignorable_spawn_rhs_op): Change to external linkage. (cilk_recognize_spawn): Renamed from recognize_spawn and change to external linkage. (cilk_detect_and_unwrap): Corresponding changes. (extract_free_variables): Don't extract free variables from AGGR_INIT_EXPR slot. * c-common.h (cilk_ignorable_spawn_rhs_op): Prototype. (cilk_recognize_spawn): Likewise. PR c++/69024 PR c++/68997 * cp-gimplify.c (cp_gimplify_expr): Call cilk_cp_detect_spawn_and_unwrap instead of cilk_detect_spawn_and_unwrap. * cp-cilkplus.c (is_conversion_operator_function_decl_p): New. (find_spawn): New. (cilk_cp_detect_spawn_and_unwrap): New. * lambda.c: Include cp-cilkplus.h. * parser.c: Include cp-cilkplus.h. * cp-tree.h (cpp_validate_cilk_plus_loop): Move prototype into... * cp-cilkpus.h: New file. PR c++/69024 PR c++/68997 * g++.dg/cilk-plus/CK/pr68001.cc: Fix to not depend on broken diagnostic. * g++.dg/cilk-plus/CK/pr69024.cc: New test. * g++.dg/cilk-plus/CK/pr68997.cc: New test. diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 1d87d9d..ac3be53 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,16 @@ +2015-04-27 Ryan Burn + + PR c++/69024 + PR c++/68997 + * cilk.c (cilk_ignorable_spawn_rhs_op): Change to external linkage. + (cilk_recognize_spawn): Renamed from recognize_spawn and change to + external linkage. + (cilk_detect_and_unwrap): Corresponding changes. + (extract_free_variables): Don't extract free variables from + AGGR_INIT_EXPR slot. + * c-common.h (cilk_ignorable_spawn_rhs_op): Prototype. + (cilk_recognize_spawn): Likewise. + 2016-04-27 Bernd Schmidt * c.opt (Wmemset-elt-size): New option. diff --git a/gcc/c-family/c-common.h b/gcc/c-family/c-common.h index b631e7d..1309549 100644 --- a/gcc/c-family/c-common.h +++ b/gcc/c-family/c-common.h @@ -1468,4 +1468,7 @@ extern bool reject_gcc_builtin (const_tree, location_t = UNKNOWN_LOCATION); extern void warn_duplicated_cond_add_or_warn (location_t, tree, vec **); extern bool valid_array_size_p (location_t, tree, tree); +extern bool cilk_ignorable_spawn_rhs_op (tree); +extern bool cilk_recognize_spawn (tree, tree *); + #endif /* ! GCC_C_COMMON_H */ diff --git a/gcc/c-family/cilk.c b/gcc/c-family/cilk.c index 0b876b9..69a79ba 100644 --- a/gcc/c-family/cilk.c +++ b/gcc/c-family/cilk.c @@ -185,7 +185,7 @@ call_graph_add_fn (tree fndecl) A comparison to constant is simple enough to allow, and is used to convert to bool. */ -static bool +bool cilk_ignorable_spawn_rhs_op (tree exp) { enum tree_code code = TREE_CODE (exp); @@ -223,8 +223,8 @@ unwrap_cilk_spawn_stmt (tree *tp, int *walk_subtrees, void *) /* Returns true when EXP is a CALL_EXPR with _Cilk_spawn in front. Unwraps CILK_SPAWN_STMT wrapper from the CALL_EXPR in *EXP0 statement. */ -static bool -recognize_spawn (tree exp, tree
Re: [PATCH][cilkplus] fix c++ implicit conversions with cilk_spawn (PR/69024, PR/68997)
On 01/20/2016 10:57 AM, Ryan Burn wrote: This patch follows on from https://gcc.gnu.org/ml/gcc-patches/2015-12/msg02142.html As discussed, it creates a separate function cilk_cp_detect_spawn_and_unwrap in gcc/cp to handle processing cilk_spawn expressions for c++ and adds support for implicit constructor and type conversions. Bootstrapped and regression tested on x86_64-linux. gcc/c-family/ChangeLog: 2015-01-20 Ryan BurnPR c++/69024 PR c++/68997 * cilk.c (cilk_ignorable_spawn_rhs_op): Change to have external linkage. * cilk.c (recognize_spawn): Rename to cilk_recognize_spawn. Change to have external linkage. * cilk.c (cilk_detect_and_unwrap): Rename to recognize_spawn to cilk_recognize_spawn. * cilk.c (extract_free_variables): Don't extract free variables from AGGR_INIT_EXPR slot. gcc/cp/ChangeLog 2015-01-20 Ryan Burn PR c++/69024 PR c++/68997 * cp-gimplify.c (cp_gimplify_expr): Call cilk_cp_detect_spawn_and_unwrap instead of cilk_detect_spawn_and_unwrap. * cp-cilkplus.c (is_conversion_operator_function_decl_p): New. * cp-cilkplus.c (find_spawn): New. * cp-cilkplus.c (cilk_cp_detect_spawn_and_unwrap): New. gcc/testsuite/ChangeLog 2015-01-20 Ryan Burn PR c++/69024 PR c++/68997 * g++.dg/cilk-plus/CK/pr68001.cc: Fix to not depend on broken diagnostic. * g++.dg/cilk-plus/CK/pr69024.cc: New test. * g++.dg/cilk-plus/CK/pr68997.cc: New test. cilk3.diff Index: gcc/cp/cp-gimplify.c === --- gcc/cp/cp-gimplify.c(revision 232444) +++ gcc/cp/cp-gimplify.c(working copy) @@ -39,6 +39,7 @@ static tree cp_fold_r (tree *, int *, void *); static void cp_genericize_tree (tree*); static tree cp_fold (tree); +bool cilk_cp_detect_spawn_and_unwrap (tree *); The right thing to do here is create cp-cilkplus.h and put the prototype in here. Along with cpp_validate_cilk_plus_loop. Index: gcc/cp/cp-cilkplus.c === --- gcc/cp/cp-cilkplus.c(revision 232444) +++ gcc/cp/cp-cilkplus.c(working copy) @@ -27,6 +27,108 @@ #include "tree-iterator.h" #include "cilk.h" +bool cilk_ignorable_spawn_rhs_op (tree); +bool cilk_recognize_spawn (tree, tree *); These should be prototyped in an appropriate .h file. c-common.h, while not ideal, would be OK. c-common seems to be a fairly bad dumping ground and we'll want to untangle separately. + +/* Return TRUE if T is a FUNCTION_DECL for a type-conversion operator. */ + +static bool +is_conversion_operator_function_decl_p (tree t) { + if (TREE_CODE (t) != FUNCTION_DECL) +return false; + + return DECL_NAME (t) && IDENTIFIER_TYPENAME_P (DECL_NAME (t)); +} Formatting. The open-curly goes on a line by itself I'm spinning up those changes for testing. Assuming they pass, I'll update the ChangeLog appropriately as well. Jeff
Re: [PATCH][cilkplus] fix c++ implicit conversions with cilk_spawn (PR/69024, PR/68997)
On 01/20/2016 12:57 PM, Ryan Burn wrote: case AGGR_INIT_EXPR: + { + int len = 0; + int ii = 0; + extract_free_variables (TREE_OPERAND (t, 1), wd, ADD_READ); + if (TREE_CODE (TREE_OPERAND (t, 0)) == INTEGER_CST) + { + len = TREE_INT_CST_LOW (TREE_OPERAND (t, 0)); + + for (ii = 3; ii < len; ii++) + extract_free_variables (TREE_OPERAND (t, ii), wd, ADD_READ); + extract_free_variables (TREE_TYPE (t), wd, ADD_READ); + } + break; + } Please add a comment about skipping operand 2 (the slot). Would it make sense to skip operand 2 (the static chain) for CALL_EXPR, too? +is_conversion_operator_function_decl_p (tree t) { Open brace gets its own line. + tree fn = AGGR_INIT_EXPR_FN (exp); + if (TREE_CODE (fn) == ADDR_EXPR + && is_conversion_operator_function_decl_p (TREE_OPERAND (fn, 0)) It would be good to have a cp_get_callee_fndecl like the normal get_callee_fndecl, but supporting AGGR_INIT_EXPR as well. That would replace the less capable get_function_named_in_call function in constexpr.c and various other places that access AGGR_INIT_EXPR_FN directly. Mind doing that, either in this patch or as a follow-up? Jason
Re: [PATCH][cilkplus] fix c++ implicit conversions with cilk_spawn (PR/69024, PR/68997)
Can we push this now that the gcc 7 branch is open? On Wed, Feb 10, 2016 at 1:00 PM, Jeff Lawwrote: > On 01/20/2016 10:57 AM, Ryan Burn wrote: >> >> This patch follows on from >> https://gcc.gnu.org/ml/gcc-patches/2015-12/msg02142.html >> >> As discussed, it creates a separate function >> cilk_cp_detect_spawn_and_unwrap in gcc/cp to handle processing >> cilk_spawn expressions for c++ and adds support for implicit >> constructor and type conversions. >> >> Bootstrapped and regression tested on x86_64-linux. > > FYI, Just saw your assignment fly by. I'll try to get a close look at this > patch shortly. > > jeff >
Re: [PATCH][cilkplus] fix c++ implicit conversions with cilk_spawn (PR/69024, PR/68997)
On 01/20/2016 10:57 AM, Ryan Burn wrote: This patch follows on from https://gcc.gnu.org/ml/gcc-patches/2015-12/msg02142.html As discussed, it creates a separate function cilk_cp_detect_spawn_and_unwrap in gcc/cp to handle processing cilk_spawn expressions for c++ and adds support for implicit constructor and type conversions. Bootstrapped and regression tested on x86_64-linux. FYI, Just saw your assignment fly by. I'll try to get a close look at this patch shortly. jeff
[PATCH][cilkplus] fix c++ implicit conversions with cilk_spawn (PR/69024, PR/68997)
This patch follows on from https://gcc.gnu.org/ml/gcc-patches/2015-12/msg02142.html As discussed, it creates a separate function cilk_cp_detect_spawn_and_unwrap in gcc/cp to handle processing cilk_spawn expressions for c++ and adds support for implicit constructor and type conversions. Bootstrapped and regression tested on x86_64-linux. gcc/c-family/ChangeLog: 2015-01-20 Ryan BurnPR c++/69024 PR c++/68997 * cilk.c (cilk_ignorable_spawn_rhs_op): Change to have external linkage. * cilk.c (recognize_spawn): Rename to cilk_recognize_spawn. Change to have external linkage. * cilk.c (cilk_detect_and_unwrap): Rename to recognize_spawn to cilk_recognize_spawn. * cilk.c (extract_free_variables): Don't extract free variables from AGGR_INIT_EXPR slot. gcc/cp/ChangeLog 2015-01-20 Ryan Burn PR c++/69024 PR c++/68997 * cp-gimplify.c (cp_gimplify_expr): Call cilk_cp_detect_spawn_and_unwrap instead of cilk_detect_spawn_and_unwrap. * cp-cilkplus.c (is_conversion_operator_function_decl_p): New. * cp-cilkplus.c (find_spawn): New. * cp-cilkplus.c (cilk_cp_detect_spawn_and_unwrap): New. gcc/testsuite/ChangeLog 2015-01-20 Ryan Burn PR c++/69024 PR c++/68997 * g++.dg/cilk-plus/CK/pr68001.cc: Fix to not depend on broken diagnostic. * g++.dg/cilk-plus/CK/pr69024.cc: New test. * g++.dg/cilk-plus/CK/pr68997.cc: New test. Index: gcc/c-family/cilk.c === --- gcc/c-family/cilk.c (revision 232444) +++ gcc/c-family/cilk.c (working copy) @@ -185,7 +185,7 @@ A comparison to constant is simple enough to allow, and is used to convert to bool. */ -static bool +bool cilk_ignorable_spawn_rhs_op (tree exp) { enum tree_code code = TREE_CODE (exp); @@ -223,8 +223,8 @@ /* Returns true when EXP is a CALL_EXPR with _Cilk_spawn in front. Unwraps CILK_SPAWN_STMT wrapper from the CALL_EXPR in *EXP0 statement. */ -static bool -recognize_spawn (tree exp, tree *exp0) +bool +cilk_recognize_spawn (tree exp, tree *exp0) { bool spawn_found = false; if (TREE_CODE (exp) == CILK_SPAWN_STMT) @@ -292,7 +292,7 @@ /* Now we should have a CALL_EXPR with a CILK_SPAWN_STMT wrapper around it, or return false. */ - if (recognize_spawn (exp, exp0)) + if (cilk_recognize_spawn (exp, exp0)) return true; return false; } @@ -1251,6 +1251,21 @@ return; case AGGR_INIT_EXPR: + { + int len = 0; + int ii = 0; + extract_free_variables (TREE_OPERAND (t, 1), wd, ADD_READ); + if (TREE_CODE (TREE_OPERAND (t, 0)) == INTEGER_CST) + { + len = TREE_INT_CST_LOW (TREE_OPERAND (t, 0)); + + for (ii = 3; ii < len; ii++) + extract_free_variables (TREE_OPERAND (t, ii), wd, ADD_READ); + extract_free_variables (TREE_TYPE (t), wd, ADD_READ); + } + break; + } + case CALL_EXPR: { int len = 0; Index: gcc/cp/cp-gimplify.c === --- gcc/cp/cp-gimplify.c(revision 232444) +++ gcc/cp/cp-gimplify.c(working copy) @@ -39,6 +39,7 @@ static tree cp_fold_r (tree *, int *, void *); static void cp_genericize_tree (tree*); static tree cp_fold (tree); +bool cilk_cp_detect_spawn_and_unwrap (tree *); /* Local declarations. */ @@ -619,7 +620,7 @@ case INIT_EXPR: if (fn_contains_cilk_spawn_p (cfun)) { - if (cilk_detect_spawn_and_unwrap (expr_p)) + if (cilk_cp_detect_spawn_and_unwrap (expr_p)) { cilk_cp_gimplify_call_params_in_spawned_fn (expr_p, pre_p, post_p); @@ -637,7 +638,7 @@ modify_expr_case: { if (fn_contains_cilk_spawn_p (cfun) - && cilk_detect_spawn_and_unwrap (expr_p) + && cilk_cp_detect_spawn_and_unwrap (expr_p) && !seen_error ()) { cilk_cp_gimplify_call_params_in_spawned_fn (expr_p, pre_p, post_p); @@ -738,7 +739,7 @@ case CILK_SPAWN_STMT: gcc_assert(fn_contains_cilk_spawn_p (cfun) -&& cilk_detect_spawn_and_unwrap (expr_p)); +&& cilk_cp_detect_spawn_and_unwrap (expr_p)); if (!seen_error ()) { @@ -749,7 +750,7 @@ case CALL_EXPR: if (fn_contains_cilk_spawn_p (cfun) - && cilk_detect_spawn_and_unwrap (expr_p) + && cilk_cp_detect_spawn_and_unwrap (expr_p) && !seen_error ()) { cilk_cp_gimplify_call_params_in_spawned_fn (expr_p, pre_p, post_p); Index: gcc/cp/cp-cilkplus.c === --- gcc/cp/cp-cilkplus.c(revision 232444) +++ gcc/cp/cp-cilkplus.c(working copy) @@ -27,6 +27,108 @@ #include "tree-iterator.h" #include "cilk.h" +bool cilk_ignorable_spawn_rhs_op (tree); +bool