diff options
author | Xi Ruoyao <ryxi@stu.xidian.edu.cn> | 2017-05-01 22:26:02 +0000 |
---|---|---|
committer | Jeff Law <law@gcc.gnu.org> | 2017-05-01 16:26:02 -0600 |
commit | 815d9cc6641a3eeb6734a98f64ea8b183a495ee5 (patch) | |
tree | a8a033d722da210460642c7a397ad087d9c87d1f /gcc/c-family | |
parent | 338035aa194405df94875cebb389d593cf9ef00a (diff) | |
download | gcc-815d9cc6641a3eeb6734a98f64ea8b183a495ee5.tar.gz |
re PR c++/80038 (Random segfault using local vectors in Cilk function)
2017-05-01 Xi Ruoyao <ryxi@stu.xidian.edu.cn>
PR c++/80038
* cilk_common.c (expand_builtin_cilk_detach): Move pedigree
operations here.
* gimplify.c (gimplify_cilk_detach): New function.
(gimplify_call_expr, gimplify_modify_expr): Call it as needed.
* tree-core.h: Document EXPR_CILK_SPAWN.
* tree.h (EXPR_CILK_SPAWN): Define.
PR c++/80038
* c-common.h (cilk_gimplify_call_params_in_spawned_fn): Remove
prototype.
(cilk_install_body_pedigree_operations): Likewise.
* cilk.c (cilk_set_spawn_marker): Mark functions that should be
detatched.
(cilk_gimplify_call_params_in_spawned_fn): Remove.
(cilk_install_body_pedigree_operations): Likewise.
(gimplify_cilk_spawn): Add EXPR_STMT and CLEANUP_POINT_EXPR
unwrapping.
PR c++/80038
* c-gimplify.c (c_gimplify_expr): Remove calls to
cilk_gimplifY_call_params_in_spawned_fn.
PR c++/80038
* cp-cilkplus.c (cilk_install_body_with_frame_cleanup): Don't
add pedigree operation and detach call here.
* cp-gimplify.c (cp_gimplify_expr): Remove the calls to
cilk_cp_gimplify_call_params_in_spawned_fn.
(cilk_cp_gimplify_call_params_in_spawned_fn): Remove function.
* semantics.c (simplify_aggr_init_expr): Copy EXPR_CILK_SPAWN.
PR c++/80038
* lto-lang.c (lto_init): Set in_lto_p earlier.
PR c++/80038
* g++.dg/cilk-plus/CK/pr80038.cc: New test.
From-SVN: r247446
Diffstat (limited to 'gcc/c-family')
-rw-r--r-- | gcc/c-family/ChangeLog | 13 | ||||
-rw-r--r-- | gcc/c-family/c-common.h | 2 | ||||
-rw-r--r-- | gcc/c-family/c-gimplify.c | 10 | ||||
-rw-r--r-- | gcc/c-family/cilk.c | 102 |
4 files changed, 25 insertions, 102 deletions
diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 8f6f55b73bf..23f52389ee0 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,16 @@ +2017-05-01 Xi Ruoyao <ryxi@stu.xidian.edu.cn> + + PR c++/80038 + * c-common.h (cilk_gimplify_call_params_in_spawned_fn): Remove + prototype. + (cilk_install_body_pedigree_operations): Likewise. + * cilk.c (cilk_set_spawn_marker): Mark functions that should be + detatched. + (cilk_gimplify_call_params_in_spawned_fn): Remove. + (cilk_install_body_pedigree_operations): Likewise. + (gimplify_cilk_spawn): Add EXPR_STMT and CLEANUP_POINT_EXPR + unwrapping. + 2017-04-27 Jakub Jelinek <jakub@redhat.com> PR c++/80534 diff --git a/gcc/c-family/c-common.h b/gcc/c-family/c-common.h index b9333420434..138a0a675ac 100644 --- a/gcc/c-family/c-common.h +++ b/gcc/c-family/c-common.h @@ -1463,7 +1463,6 @@ extern bool is_cilkplus_vector_p (tree); extern tree insert_cilk_frame (tree); extern void cilk_init_builtins (void); extern int gimplify_cilk_spawn (tree *); -extern void cilk_gimplify_call_params_in_spawned_fn (tree *, gimple_seq *); extern void cilk_install_body_with_frame_cleanup (tree, tree, void *); extern bool cilk_detect_spawn_and_unwrap (tree *); extern bool cilk_set_spawn_marker (location_t, tree); @@ -1471,7 +1470,6 @@ extern tree build_cilk_sync (void); extern tree build_cilk_spawn (location_t, tree); extern tree make_cilk_frame (tree); extern tree create_cilk_function_exit (tree, bool, bool); -extern tree cilk_install_body_pedigree_operations (tree); extern void cilk_outline (tree, tree *, void *); extern bool contains_cilk_spawn_stmt (tree); extern tree cilk_for_number_of_iterations (tree); diff --git a/gcc/c-family/c-gimplify.c b/gcc/c-family/c-gimplify.c index 57edb41af0f..1ae75d294ff 100644 --- a/gcc/c-family/c-gimplify.c +++ b/gcc/c-family/c-gimplify.c @@ -280,10 +280,7 @@ c_gimplify_expr (tree *expr_p, gimple_seq *pre_p ATTRIBUTE_UNUSED, && cilk_detect_spawn_and_unwrap (expr_p)); if (!seen_error ()) - { - cilk_gimplify_call_params_in_spawned_fn (expr_p, pre_p); - return (enum gimplify_status) gimplify_cilk_spawn (expr_p); - } + return (enum gimplify_status) gimplify_cilk_spawn (expr_p); return GS_ERROR; case MODIFY_EXPR: @@ -295,10 +292,7 @@ c_gimplify_expr (tree *expr_p, gimple_seq *pre_p ATTRIBUTE_UNUSED, original expression (MODIFY/INIT/CALL_EXPR) is processes as it is supposed to be. */ && !seen_error ()) - { - cilk_gimplify_call_params_in_spawned_fn (expr_p, pre_p); - return (enum gimplify_status) gimplify_cilk_spawn (expr_p); - } + return (enum gimplify_status) gimplify_cilk_spawn (expr_p); default:; } diff --git a/gcc/c-family/cilk.c b/gcc/c-family/cilk.c index 43478fff914..e6df498e471 100644 --- a/gcc/c-family/cilk.c +++ b/gcc/c-family/cilk.c @@ -109,6 +109,10 @@ cilk_set_spawn_marker (location_t loc, tree fcall) else { cfun->calls_cilk_spawn = true; + if (TREE_CODE (fcall) == CALL_EXPR) + EXPR_CILK_SPAWN (fcall) = 1; + else /* TREE_CODE (fcall) == TARGET_EXPR */ + EXPR_CILK_SPAWN (TREE_OPERAND (fcall, 1)) = 1; return true; } } @@ -775,37 +779,6 @@ create_cilk_wrapper (tree exp, tree *args_out) return fndecl; } -/* Gimplify all the parameters for the Spawned function. *EXPR_P can be a - CALL_EXPR, INIT_EXPR, MODIFY_EXPR or TARGET_EXPR. *PRE_P and *POST_P are - gimple sequences from the caller of gimplify_cilk_spawn. */ - -void -cilk_gimplify_call_params_in_spawned_fn (tree *expr_p, gimple_seq *pre_p) -{ - int ii = 0; - tree *fix_parm_expr = expr_p; - - /* Remove CLEANUP_POINT_EXPR and EXPR_STMT from *spawn_p. */ - while (TREE_CODE (*fix_parm_expr) == CLEANUP_POINT_EXPR - || TREE_CODE (*fix_parm_expr) == EXPR_STMT) - *fix_parm_expr = TREE_OPERAND (*fix_parm_expr, 0); - - if ((TREE_CODE (*expr_p) == INIT_EXPR) - || (TREE_CODE (*expr_p) == TARGET_EXPR) - || (TREE_CODE (*expr_p) == MODIFY_EXPR)) - fix_parm_expr = &TREE_OPERAND (*expr_p, 1); - - if (TREE_CODE (*fix_parm_expr) == CALL_EXPR) - { - /* Cilk outlining assumes GENERIC bodies, avoid leaking SSA names - via parameters. */ - for (ii = 0; ii < call_expr_nargs (*fix_parm_expr); ii++) - gimplify_arg (&CALL_EXPR_ARG (*fix_parm_expr, ii), pre_p, - EXPR_LOCATION (*fix_parm_expr), false); - } -} - - /* Transform *SPAWN_P, a spawned CALL_EXPR, to gimple. *SPAWN_P can be a CALL_EXPR, INIT_EXPR or MODIFY_EXPR. Returns GS_OK if everything is fine, and GS_UNHANDLED, otherwise. */ @@ -823,6 +796,12 @@ gimplify_cilk_spawn (tree *spawn_p) cfun->calls_cilk_spawn = 1; cfun->is_cilk_function = 1; + + /* Remove CLEANUP_POINT_EXPR and EXPR_STMT from *spawn_p. */ + while (TREE_CODE (expr) == CLEANUP_POINT_EXPR + || TREE_CODE (expr) == EXPR_STMT) + expr = TREE_OPERAND (expr, 0); + new_args = NULL; function = create_cilk_wrapper (expr, &new_args); @@ -889,67 +868,6 @@ make_cilk_frame (tree fn) return decl; } -/* Returns a STATEMENT_LIST with all the pedigree operations required for - install body with frame cleanup functions. FRAME_PTR is the pointer to - __cilkrts_stack_frame created by make_cilk_frame. */ - -tree -cilk_install_body_pedigree_operations (tree frame_ptr) -{ - tree body_list = alloc_stmt_list (); - tree enter_frame = build_call_expr (cilk_enter_fast_fndecl, 1, frame_ptr); - append_to_statement_list (enter_frame, &body_list); - - tree parent = cilk_arrow (frame_ptr, CILK_TI_FRAME_PARENT, 0); - tree worker = cilk_arrow (frame_ptr, CILK_TI_FRAME_WORKER, 0); - - tree pedigree = cilk_arrow (frame_ptr, CILK_TI_FRAME_PEDIGREE, 0); - tree pedigree_rank = cilk_dot (pedigree, CILK_TI_PEDIGREE_RANK, 0); - tree parent_pedigree = cilk_dot (pedigree, CILK_TI_PEDIGREE_PARENT, 0); - tree pedigree_parent = cilk_arrow (parent, CILK_TI_FRAME_PEDIGREE, 0); - tree pedigree_parent_rank = cilk_dot (pedigree_parent, - CILK_TI_PEDIGREE_RANK, 0); - tree pedigree_parent_parent = cilk_dot (pedigree_parent, - CILK_TI_PEDIGREE_PARENT, 0); - tree worker_pedigree = cilk_arrow (worker, CILK_TI_WORKER_PEDIGREE, 1); - tree w_pedigree_rank = cilk_dot (worker_pedigree, CILK_TI_PEDIGREE_RANK, 0); - tree w_pedigree_parent = cilk_dot (worker_pedigree, - CILK_TI_PEDIGREE_PARENT, 0); - - /* sf.pedigree.rank = worker->pedigree.rank. */ - tree exp1 = build2 (MODIFY_EXPR, void_type_node, pedigree_rank, - w_pedigree_rank); - append_to_statement_list (exp1, &body_list); - - /* sf.pedigree.parent = worker->pedigree.parent. */ - exp1 = build2 (MODIFY_EXPR, void_type_node, parent_pedigree, - w_pedigree_parent); - append_to_statement_list (exp1, &body_list); - - /* sf.call_parent->pedigree.rank = worker->pedigree.rank. */ - exp1 = build2 (MODIFY_EXPR, void_type_node, pedigree_parent_rank, - w_pedigree_rank); - append_to_statement_list (exp1, &body_list); - - /* sf.call_parent->pedigree.parent = worker->pedigree.parent. */ - exp1 = build2 (MODIFY_EXPR, void_type_node, pedigree_parent_parent, - w_pedigree_parent); - append_to_statement_list (exp1, &body_list); - - /* sf->worker.pedigree.rank = 0. */ - exp1 = build2 (MODIFY_EXPR, void_type_node, w_pedigree_rank, - build_zero_cst (uint64_type_node)); - append_to_statement_list (exp1, &body_list); - - /* sf->pedigree.parent = &sf->pedigree. */ - exp1 = build2 (MODIFY_EXPR, void_type_node, w_pedigree_parent, - build1 (ADDR_EXPR, - build_pointer_type (cilk_pedigree_type_decl), - pedigree)); - append_to_statement_list (exp1, &body_list); - return body_list; -} - /* Add a new variable, VAR to a variable list in WD->DECL_MAP. HOW indicates whether the variable is previously defined, currently defined, or a variable that is being written to. */ |