summaryrefslogtreecommitdiff
path: root/gcc/cilk-common.c
diff options
context:
space:
mode:
authorXi Ruoyao <ryxi@stu.xidian.edu.cn>2017-05-01 22:26:02 +0000
committerJeff Law <law@gcc.gnu.org>2017-05-01 16:26:02 -0600
commit815d9cc6641a3eeb6734a98f64ea8b183a495ee5 (patch)
treea8a033d722da210460642c7a397ad087d9c87d1f /gcc/cilk-common.c
parent338035aa194405df94875cebb389d593cf9ef00a (diff)
downloadgcc-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/cilk-common.c')
-rw-r--r--gcc/cilk-common.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/gcc/cilk-common.c b/gcc/cilk-common.c
index 46626b75b23..9cbe03f8e02 100644
--- a/gcc/cilk-common.c
+++ b/gcc/cilk-common.c
@@ -365,11 +365,60 @@ expand_builtin_cilk_detach (tree exp)
tree worker = cilk_dot (fptr, CILK_TI_FRAME_WORKER, 0);
tree tail = cilk_arrow (worker, CILK_TI_WORKER_TAIL, 1);
+ tree faddr = build1 (ADDR_EXPR, cilk_frame_ptr_type_decl, fptr);
+ tree enter_frame = build_call_expr (cilk_enter_fast_fndecl, 1, faddr);
+ expand_expr (enter_frame, const0_rtx, VOIDmode, EXPAND_NORMAL);
+
+ tree pedigree = cilk_dot (fptr, 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);
+
rtx wreg = expand_expr (worker, NULL_RTX, Pmode, EXPAND_NORMAL);
if (GET_CODE (wreg) != REG)
wreg = copy_to_reg (wreg);
rtx preg = expand_expr (parent, NULL_RTX, Pmode, EXPAND_NORMAL);
+ /* sf.pedigree.rank = worker->pedigree.rank. */
+ tree exp1 = build2 (MODIFY_EXPR, void_type_node, pedigree_rank,
+ w_pedigree_rank);
+ expand_expr (exp1, const0_rtx, VOIDmode, EXPAND_NORMAL);
+
+ /* sf.pedigree.parent = worker->pedigree.parent. */
+ exp1 = build2 (MODIFY_EXPR, void_type_node, parent_pedigree,
+ w_pedigree_parent);
+ expand_expr (exp1, const0_rtx, VOIDmode, EXPAND_NORMAL);
+
+ /* sf.call_parent->pedigree.rank = worker->pedigree.rank. */
+ exp1 = build2 (MODIFY_EXPR, void_type_node, pedigree_parent_rank,
+ w_pedigree_rank);
+ expand_expr (exp1, const0_rtx, VOIDmode, EXPAND_NORMAL);
+
+ /* sf.call_parent->pedigree.parent = worker->pedigree.parent. */
+ exp1 = build2 (MODIFY_EXPR, void_type_node, pedigree_parent_parent,
+ w_pedigree_parent);
+ expand_expr (exp1, const0_rtx, VOIDmode, EXPAND_NORMAL);
+
+ /* sf->worker.pedigree.rank = 0. */
+ exp1 = build2 (MODIFY_EXPR, void_type_node, w_pedigree_rank,
+ build_zero_cst (uint64_type_node));
+ expand_expr (exp1, const0_rtx, VOIDmode, EXPAND_NORMAL);
+
+ /* 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));
+ expand_expr (exp1, const0_rtx, VOIDmode, EXPAND_NORMAL);
+
/* TMP <- WORKER.TAIL
*TMP <- PARENT
TMP <- TMP + 1