aboutsummaryrefslogtreecommitdiff
path: root/gcc/omp-low.c
diff options
context:
space:
mode:
authorMichael Matz <matz@suse.de>2012-05-02 16:41:48 +0000
committerMichael Matz <matz@suse.de>2012-05-02 16:41:48 +0000
commit2a0302a24d4e8862920bcec8df35403be32e8652 (patch)
treea909112c3b26051d56924ebe9435b84f207b2091 /gcc/omp-low.c
parentbb2ec41b8ba2eb88effa3d864d5d87a9eae40ed7 (diff)
* coretypes.h (gimple_seq, const_gimple_seq): Typedef as gimple.
* gimple.h (struct gimple_seq_node_d, struct gimple_seq_d): Remove. (const_gimple_seq_node): Remove. (gimple_seq_node): Typedef as gimple. (struct gimple_statement_base): Add next and prev members, adjust all WORD markers in using structs. (union gimple_statement_d): Link via gsbase.next field for GC and PCH. (gimple_seq_first, gimple_seq_first_stmt, gimple_seq_last, gimple_seq_last_stmt): Adjust as gimple_seq, gimple_seq_node and gimple are the same. (gimple_seq_set_last, gimple_seq_set_first): Don't allocate gimple_seq, adjust. (gimple_init_singleton): New function. (gsi_start_1, gsi_last_1, gsi_end_p, gsi_one_before_end_p): Adjust. (gsi_next, gsi_prev): Adjust, handle prev cyclic list correctly. (gsi_stmt): Adjust. (gsi_stmt_ptr): Remove. (enum gimple_alloc_kind): Remove gimple_alloc_kind_seq member. * gimple-iterator.c (update_bb_for_stmts): Take last parameter again, adjust for above changes. (update_call_edge_frequencies): Adjust for above changes. (gsi_insert_seq_nodes_before): Rewrite for new data structure. (gsi_insert_seq_nodes_after): Ditto. (gsi_split_seq_after): Ditto. (gsi_set_stmt): Ditto. (gsi_split_seq_before): Ditto. (gsi_remove): Ditto. (gsi_insert_seq_before_without_update): Don't free sequence. (gsi_insert_seq_after_without_update): Ditto. (gsi_replace): Assert some more invariants. (gsi_insert_before_without_update, gsi_insert_after_without_update): Tidy. (gsi_for_stmt): Don't search for stmt. (gsi_insert_on_edge_immediate): Tidy. * gimple.c (gimple_alloc_k): Remove "sequences". (gimple_seq_cache): Remove. (gimple_alloc_stat): Make stmt a singleton sequence. (gimple_seq_alloc, gimple_seq_free): Remove. (gimple_assign_set_rhs_with_ops_1): Ensure new stmt is a singleton. (gimple_copy): Ditto. * gimplify.c (gimplify_cleanup_point_expr): Use gsi_set_stmt, create iterator from correct sequence. * tree-phinodes.c (make_phi_node): Make stmt a singleton. * gimple.h (gimple_stmt_iterator <seq>): Make it be pointer to gimple_seq. (gimple_seq_set_last, gimple_seq_set_first): Take pointer to sequence, lazily allocate it. (bb_seq_addr): New function. (gsi_start_1): Rename from gsi_start, but take pointer to sequence. (gsi_start): Macro to wrap gsi_start_1 taking pointer of argument. (gsi_none): New function. (gsi_start_bb): Adjust. (gsi_last_1): Rename from gsi_last, but take pointer to sequence. (gsi_last): Macro to wrap gsi_last_1 taking pointer of argument. (gsi_last_bb): Adjust. (gsi_seq): Adjust. * tree-flow-inline.h (phi_nodes_ptr): New function. * gimple-iterator.c (gsi_insert_seq_nodes_before): Adjust to datastructure and interface change. (gsi_insert_seq_before_without_update): Ditto. (gsi_insert_seq_nodes_after): Ditto. (gsi_insert_seq_after_without_update): Ditto. (gsi_split_seq_after): Ditto, don't use gimple_seq_alloc. (gsi_split_seq_before): Ditto. (gsi_start_phis): Adjust. * tree-vect-loop.c (vect_determine_vectorization_factor): Use gsi_none. (vect_transform_loop): Ditto. * gimple.c (gimple_seq_add_stmt, gimple_seq_add_seq, gimple_seq_copy): Don't use gimple_seq_alloc. * gimplify.c (gimple_seq_add_stmt_without_update): Ditto. (gimplify_seq_add_seq): Ditto. * lto-streamer-in.c (make_new_block): Ditto. * tree-cfg.c (create_bb): Ditto. * tree-sra.c (initialize_parameter_reductions): Ditto. * gimple.h (gimple_seq_first, gimple_seq_first_stmt, gimple_seq_last, gimple_seq_last_stmt, gimple_seq_set_last, gimple_seq_set_first, gimple_seq_empty_p, gimple_seq_alloc_with_stmt, bb_seq, set_bb_seq): Move down to after gimple_statement_d definition. * gimple-fold.c (gimplify_and_update_call_from_tree): Use gsi_replace_with_seq, instead of inserting itself. * gimple-iterator.c (gsi_replace_with_seq): New function. * tree-ssa-forwprop.c (forward_propagate_comparison): Take iterator instead of statement, advance it. (ssa_forward_propagate_and_combine): Adjust call to above. * tree-phinodes.c (add_phi_node_to_bb): Tidy, don't use gimple_seq_alloc. * omp-low.c (finalize_task_copyfn): Don't use gimple_seq_alloc. * tree-nested.c (walk_gimple_omp_for): Ditto. * trans-mem.c (lower_transaction): Ditto. * tree-eh.c (do_return_redirection): Ditto. (do_goto_redirection): Ditto. (lower_try_finally_switch): Ditto. * gimplify.c (gimplify_stmt): Ditto. (gimplify_scan_omp_clauses): Ditto. (gimplify_omp_for): Ditto. (gimplify_function_tree): Ditto. * gimple-fold.c (gimplify_and_update_call_from_tree): Ditto. * tree-mudflap.c (mf_decl_cache_locals): Ditto. (mf_build_check_statement_for): Ditto. (mx_register_decls): Ditto. * graphite-sese-to-poly.c (remove_invariant_phi): Ditto, and don't use itertors to append. (insert_stmts): Ditto. (insert_out_of_ssa_copy): Ditto. (insert_out_of_ssa_copy_on_edge): Ditto. * gimple.h (gimple_bind_body_ptr): New function. (gimple_bind_body): Use it. (gimple_catch_handler): Use gimple_catch_handler_ptr. (gimple_eh_filter_failure_ptr): New function. (gimple_eh_filter_failure): Use it. (gimple_eh_else_n_body_ptr): New function. (gimple_eh_else_n_body): Use it. (gimple_eh_else_e_body_ptr): New function. (gimple_eh_else_e_body): Use it. (gimple_try_eval_ptr): New function. (gimple_try_eval): Use it. (gimple_try_cleanup_ptr): New function. (gimple_try_cleanup): Use it. (gimple_wce_cleanup_ptr): New function. (gimple_wce_cleanup): Use it. (gimple_omp_body_ptr): New function. (gimple_omp_body): Use it. (gimple_omp_for_pre_body_ptr): New function. (gimple_omp_for_pre_body): Use it. (gimple_transaction_body_ptr): New function. (gimple_transaction_body): Use it. (gsi_split_seq_before): Adjust to return nothing and take pointer to sequence. (gsi_set_stmt): Declare. (gsi_replace_with_seq): Declare. (walk_gimple_seq_mod): Declare. * function.h (struct function <gimple_body>): Use typedef gimple_seq. * gimple-iterator.c (gsi_set_stmt): New function. (gsi_split_seq_before): Return new sequence via pointer argument. (gsi_replace): Use gsi_set_stmt. * tree-ssa-loop-im.c (move_computations_stmt): First remove then insert stmt. * tree-complex.c (update_complex_components_on_edge): Don't copy gsi. * tree-phinodes.c (resize_phi_node): Don't resize stmt in-place, return new stmt. (reserve_phi_args_for_new_edge): Change call to above, use gsi_set_stmt. * omp-low.c (lower_omp): Change prototype to take pointer to sequence. (lower_rec_input_clauses): Use gimple_seq_add_seq instead of iterators. Adjust call to lower_omp. (lower_lastprivate_clauses): Adjust call to lower_omp. (lower_reduction_clauses): Ditto. (expand_omp_taskreg): Nullify non-cfg body of child_fn. (lower_omp_sections): Don't explicitely count sequence length, nullify lowered bodies earlier, ensure stmts are part of only one sequence, adjust call to lower_omp. (lower_omp_single): Ensure stmts are part of only one sequence, adjust call to lower_omp. (lower_omp_master): Ditto. (lower_omp_ordered): Ditto. (lower_omp_critical): Ditto. (lower_omp_for): Ditto. (lower_omp_taskreg): Ditto, tidy. (lower_omp_1): Adjust calls to lower_omp. (execute_lower_omp): Ditto. (lower_omp): Adjust to take pointer to sequence. (diagnose_sb_2): Use walk_gimple_seq_mod. (diagnose_omp_structured_block_errors): Ditto and set possibly changed function body. * gimple-low.c (lower_function_body): Set function body after it stabilizes. (lower_sequence): Adjust to take pointer to sequence. (lower_omp_directive): Ensure stmt isn't put twice into the sequence, adjust call to lower_sequence. (lower_stmt): Adjust calls to lower_sequence. (lower_gimple_bind): Ditto. (gimple_try_catch_may_fallthru): Call gsi_start with lvalue. * tree-nested.c (walk_body): Take pointer to sequence, use walk_gimple_seq_mod. (walk_function): Adjust call to walk_body, set possibly changed body. (walk_gimple_omp_for): Adjust calls to walk_body. (convert_nonlocal_omp_clauses): Ditto. (convert_nonlocal_reference_stmt): Ditto. (convert_local_omp_clauses): Ditto. (convert_local_reference_stmt): Ditto. (convert_tramp_reference_stmt): Ditto. (convert_gimple_call): Ditto. (convert_nl_goto_reference): Use local iterator copy. * gimple.c (walk_gimple_seq_mod): Renamed from walk_gimple_seq, but taking pointer to sequence, ensure gsi_start is called with callers lvalue. (walk_gimple_seq): New wrapper around walk_gimple_seq_mod, asserting that the sequence head didn't change. (walk_gimple_stmt): Replace all calls to walk_gimple_seq with walk_gimple_seq_mod. * trans-mem.c (lower_transaction): Use walk_gimple_seq_mod. (execute_lower_tm): Ditto, and set possibly changed body. * tree-eh.c (lower_eh_constructs_1): Take pointer to sequence, call gsi_start with that lvalue. (replace_goto_queue_stmt_list): Ditto. (replace_goto_queue_1): Adjust calls to replace_goto_queue_stmt_list. (replace_goto_queue): Ditto. (lower_try_finally_nofallthru): Adjust calls to lower_eh_constructs_1. (lower_try_finally_onedest): Ditto. (lower_try_finally_copy): Ditto. (lower_try_finally_switch): Ditto. (lower_try_finally): Ditto. (lower_eh_filter): Ditto. (lower_eh_must_not_throw): Ditto. (lower_cleanup): Ditto. (lower_eh_constructs_2): Ditto. (lower_catch): Ditto, and ensure gsi_start is called with lvalue. (lower_eh_constructs): Adjust calls to lower_eh_constructs_1, and set possibly changed body. (optimize_double_finally): Call gsi_start with lvalue. * tree-cfg.c (make_blocks): Adjust call to gsi_split_seq_before. (gimple_split_block): Ditto. (gimple_merge_blocks): Use gsi_start_phis. (move_stmt_r): Use walk_gimple_seq_mod. * tree-ssa-dse.c (dse_enter_block): Use gsi_last_bb. * cgraphbuild.c (build_cgraph_edges): Use gsi_start_phis. (rebuild_cgraph_edges): Ditto. (cgraph_rebuild_references): Ditto. * ipa-prop.c (ipa_analyze_params_uses): Ditto. * tree-inline.c (copy_phis_for_bb): Ditto. * tree-ssa-dce.c: Ditto. * cgraphunit.c (cgraph_analyze_function): Use gimple_has_body_p. git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@187053 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/omp-low.c')
-rw-r--r--gcc/omp-low.c141
1 files changed, 67 insertions, 74 deletions
diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index f6b62438dce..21a5188d214 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -158,7 +158,7 @@ scan_omp_op (tree *tp, omp_context *ctx)
return walk_tree (tp, scan_omp_1_op, &wi, NULL);
}
-static void lower_omp (gimple_seq, omp_context *);
+static void lower_omp (gimple_seq *, omp_context *);
static tree lookup_decl_in_outer_ctx (tree, omp_context *);
static tree maybe_lookup_decl_in_outer_ctx (tree, omp_context *);
@@ -1233,7 +1233,7 @@ finalize_task_copyfn (gimple task_stmt)
{
struct function *child_cfun;
tree child_fn, old_fn;
- gimple_seq seq, new_seq;
+ gimple_seq seq = NULL, new_seq;
gimple bind;
child_fn = gimple_omp_task_copy_fn (task_stmt);
@@ -1250,13 +1250,12 @@ finalize_task_copyfn (gimple task_stmt)
push_cfun (child_cfun);
current_function_decl = child_fn;
bind = gimplify_body (child_fn, false);
- seq = gimple_seq_alloc ();
gimple_seq_add_stmt (&seq, bind);
new_seq = maybe_catch_exception (seq);
if (new_seq != seq)
{
bind = gimple_build_bind (NULL, new_seq, NULL);
- seq = gimple_seq_alloc ();
+ seq = NULL;
gimple_seq_add_stmt (&seq, bind);
}
gimple_set_body (child_fn, seq);
@@ -2231,14 +2230,11 @@ static void
lower_rec_input_clauses (tree clauses, gimple_seq *ilist, gimple_seq *dlist,
omp_context *ctx)
{
- gimple_stmt_iterator diter;
tree c, dtor, copyin_seq, x, ptr;
bool copyin_by_ref = false;
bool lastprivate_firstprivate = false;
int pass;
- *dlist = gimple_seq_alloc ();
- diter = gsi_start (*dlist);
copyin_seq = NULL;
/* Do all the fixed sized types in the first pass, and the variable sized
@@ -2427,7 +2423,7 @@ lower_rec_input_clauses (tree clauses, gimple_seq *ilist, gimple_seq *dlist,
dtor = x;
gimplify_stmt (&dtor, &tseq);
- gsi_insert_seq_before (&diter, tseq, GSI_SAME_STMT);
+ gimple_seq_add_seq (dlist, tseq);
}
break;
@@ -2470,7 +2466,7 @@ lower_rec_input_clauses (tree clauses, gimple_seq *ilist, gimple_seq *dlist,
x = build_fold_addr_expr_loc (clause_loc, x);
SET_DECL_VALUE_EXPR (placeholder, x);
DECL_HAS_VALUE_EXPR_P (placeholder) = 1;
- lower_omp (OMP_CLAUSE_REDUCTION_GIMPLE_INIT (c), ctx);
+ lower_omp (&OMP_CLAUSE_REDUCTION_GIMPLE_INIT (c), ctx);
gimple_seq_add_seq (ilist,
OMP_CLAUSE_REDUCTION_GIMPLE_INIT (c));
OMP_CLAUSE_REDUCTION_GIMPLE_INIT (c) = NULL;
@@ -2574,7 +2570,7 @@ lower_lastprivate_clauses (tree clauses, tree predicate, gimple_seq *stmt_list,
if (OMP_CLAUSE_LASTPRIVATE_GIMPLE_SEQ (c))
{
- lower_omp (OMP_CLAUSE_LASTPRIVATE_GIMPLE_SEQ (c), ctx);
+ lower_omp (&OMP_CLAUSE_LASTPRIVATE_GIMPLE_SEQ (c), ctx);
gimple_seq_add_seq (stmt_list,
OMP_CLAUSE_LASTPRIVATE_GIMPLE_SEQ (c));
}
@@ -2678,7 +2674,7 @@ lower_reduction_clauses (tree clauses, gimple_seq *stmt_seqp, omp_context *ctx)
ref = build_fold_addr_expr_loc (clause_loc, ref);
SET_DECL_VALUE_EXPR (placeholder, ref);
DECL_HAS_VALUE_EXPR_P (placeholder) = 1;
- lower_omp (OMP_CLAUSE_REDUCTION_GIMPLE_MERGE (c), ctx);
+ lower_omp (&OMP_CLAUSE_REDUCTION_GIMPLE_MERGE (c), ctx);
gimple_seq_add_seq (&sub_seq, OMP_CLAUSE_REDUCTION_GIMPLE_MERGE (c));
OMP_CLAUSE_REDUCTION_GIMPLE_MERGE (c) = NULL;
OMP_CLAUSE_REDUCTION_PLACEHOLDER (c) = NULL;
@@ -3501,7 +3497,8 @@ expand_omp_taskreg (struct omp_region *region)
&& !DECL_EXTERNAL (t))
varpool_finalize_decl (t);
DECL_SAVED_TREE (child_fn) = NULL;
- gimple_set_body (child_fn, bb_seq (single_succ (entry_bb)));
+ /* We'll create a CFG for child_fn, so no gimple body is needed. */
+ gimple_set_body (child_fn, NULL);
TREE_USED (block) = 1;
/* Reset DECL_CONTEXT on function arguments. */
@@ -5789,9 +5786,8 @@ lower_omp_sections (gimple_stmt_iterator *gsi_p, omp_context *ctx)
{
tree block, control;
gimple_stmt_iterator tgsi;
- unsigned i, len;
gimple stmt, new_stmt, bind, t;
- gimple_seq ilist, dlist, olist, new_body, body;
+ gimple_seq ilist, dlist, olist, new_body;
struct gimplify_ctx gctx;
stmt = gsi_stmt (*gsi_p);
@@ -5803,13 +5799,10 @@ lower_omp_sections (gimple_stmt_iterator *gsi_p, omp_context *ctx)
lower_rec_input_clauses (gimple_omp_sections_clauses (stmt),
&ilist, &dlist, ctx);
- tgsi = gsi_start (gimple_omp_body (stmt));
- for (len = 0; !gsi_end_p (tgsi); len++, gsi_next (&tgsi))
- continue;
-
- tgsi = gsi_start (gimple_omp_body (stmt));
- body = NULL;
- for (i = 0; i < len; i++, gsi_next (&tgsi))
+ new_body = gimple_omp_body (stmt);
+ gimple_omp_set_body (stmt, NULL);
+ tgsi = gsi_start (new_body);
+ for (; !gsi_end_p (tgsi); gsi_next (&tgsi))
{
omp_context *sctx;
gimple sec_start;
@@ -5818,32 +5811,33 @@ lower_omp_sections (gimple_stmt_iterator *gsi_p, omp_context *ctx)
sctx = maybe_lookup_ctx (sec_start);
gcc_assert (sctx);
- gimple_seq_add_stmt (&body, sec_start);
-
- lower_omp (gimple_omp_body (sec_start), sctx);
- gimple_seq_add_seq (&body, gimple_omp_body (sec_start));
+ lower_omp (gimple_omp_body_ptr (sec_start), sctx);
+ gsi_insert_seq_after (&tgsi, gimple_omp_body (sec_start),
+ GSI_CONTINUE_LINKING);
gimple_omp_set_body (sec_start, NULL);
- if (i == len - 1)
+ if (gsi_one_before_end_p (tgsi))
{
gimple_seq l = NULL;
lower_lastprivate_clauses (gimple_omp_sections_clauses (stmt), NULL,
&l, ctx);
- gimple_seq_add_seq (&body, l);
+ gsi_insert_seq_after (&tgsi, l, GSI_CONTINUE_LINKING);
gimple_omp_section_set_last (sec_start);
}
- gimple_seq_add_stmt (&body, gimple_build_omp_return (false));
+ gsi_insert_after (&tgsi, gimple_build_omp_return (false),
+ GSI_CONTINUE_LINKING);
}
block = make_node (BLOCK);
- bind = gimple_build_bind (NULL, body, block);
+ bind = gimple_build_bind (NULL, new_body, block);
olist = NULL;
lower_reduction_clauses (gimple_omp_sections_clauses (stmt), &olist, ctx);
block = make_node (BLOCK);
new_stmt = gimple_build_bind (NULL, NULL, block);
+ gsi_replace (gsi_p, new_stmt, true);
pop_gimplify_context (new_stmt);
gimple_bind_append_vars (new_stmt, ctx->block_vars);
@@ -5873,9 +5867,6 @@ lower_omp_sections (gimple_stmt_iterator *gsi_p, omp_context *ctx)
gimple_seq_add_stmt (&new_body, t);
gimple_bind_set_body (new_stmt, new_body);
- gimple_omp_set_body (stmt, NULL);
-
- gsi_replace (gsi_p, new_stmt, true);
}
@@ -6008,10 +5999,14 @@ lower_omp_single (gimple_stmt_iterator *gsi_p, omp_context *ctx)
push_gimplify_context (&gctx);
+ block = make_node (BLOCK);
+ bind = gimple_build_bind (NULL, NULL, block);
+ gsi_replace (gsi_p, bind, true);
bind_body = NULL;
+ dlist = NULL;
lower_rec_input_clauses (gimple_omp_single_clauses (single_stmt),
&bind_body, &dlist, ctx);
- lower_omp (gimple_omp_body (single_stmt), ctx);
+ lower_omp (gimple_omp_body_ptr (single_stmt), ctx);
gimple_seq_add_stmt (&bind_body, single_stmt);
@@ -6030,15 +6025,12 @@ lower_omp_single (gimple_stmt_iterator *gsi_p, omp_context *ctx)
(!!find_omp_clause (gimple_omp_single_clauses (single_stmt),
OMP_CLAUSE_NOWAIT));
gimple_seq_add_stmt (&bind_body, t);
-
- block = make_node (BLOCK);
- bind = gimple_build_bind (NULL, bind_body, block);
+ gimple_bind_set_body (bind, bind_body);
pop_gimplify_context (bind);
gimple_bind_append_vars (bind, ctx->block_vars);
BLOCK_VARS (block) = ctx->block_vars;
- gsi_replace (gsi_p, bind, true);
if (BLOCK_VARS (block))
TREE_USED (block) = 1;
}
@@ -6058,8 +6050,9 @@ lower_omp_master (gimple_stmt_iterator *gsi_p, omp_context *ctx)
push_gimplify_context (&gctx);
block = make_node (BLOCK);
- bind = gimple_build_bind (NULL, gimple_seq_alloc_with_stmt (stmt),
- block);
+ bind = gimple_build_bind (NULL, NULL, block);
+ gsi_replace (gsi_p, bind, true);
+ gimple_bind_add_stmt (bind, stmt);
bfn_decl = builtin_decl_explicit (BUILT_IN_OMP_GET_THREAD_NUM);
x = build_call_expr_loc (loc, bfn_decl, 0);
@@ -6069,7 +6062,7 @@ lower_omp_master (gimple_stmt_iterator *gsi_p, omp_context *ctx)
gimplify_and_add (x, &tseq);
gimple_bind_add_seq (bind, tseq);
- lower_omp (gimple_omp_body (stmt), ctx);
+ lower_omp (gimple_omp_body_ptr (stmt), ctx);
gimple_omp_set_body (stmt, maybe_catch_exception (gimple_omp_body (stmt)));
gimple_bind_add_seq (bind, gimple_omp_body (stmt));
gimple_omp_set_body (stmt, NULL);
@@ -6082,7 +6075,6 @@ lower_omp_master (gimple_stmt_iterator *gsi_p, omp_context *ctx)
gimple_bind_append_vars (bind, ctx->block_vars);
BLOCK_VARS (block) = ctx->block_vars;
- gsi_replace (gsi_p, bind, true);
}
@@ -6098,14 +6090,15 @@ lower_omp_ordered (gimple_stmt_iterator *gsi_p, omp_context *ctx)
push_gimplify_context (&gctx);
block = make_node (BLOCK);
- bind = gimple_build_bind (NULL, gimple_seq_alloc_with_stmt (stmt),
- block);
+ bind = gimple_build_bind (NULL, NULL, block);
+ gsi_replace (gsi_p, bind, true);
+ gimple_bind_add_stmt (bind, stmt);
x = gimple_build_call (builtin_decl_explicit (BUILT_IN_GOMP_ORDERED_START),
0);
gimple_bind_add_stmt (bind, x);
- lower_omp (gimple_omp_body (stmt), ctx);
+ lower_omp (gimple_omp_body_ptr (stmt), ctx);
gimple_omp_set_body (stmt, maybe_catch_exception (gimple_omp_body (stmt)));
gimple_bind_add_seq (bind, gimple_omp_body (stmt));
gimple_omp_set_body (stmt, NULL);
@@ -6119,7 +6112,6 @@ lower_omp_ordered (gimple_stmt_iterator *gsi_p, omp_context *ctx)
gimple_bind_append_vars (bind, ctx->block_vars);
BLOCK_VARS (block) = gimple_bind_vars (bind);
- gsi_replace (gsi_p, bind, true);
}
@@ -6195,13 +6187,15 @@ lower_omp_critical (gimple_stmt_iterator *gsi_p, omp_context *ctx)
push_gimplify_context (&gctx);
block = make_node (BLOCK);
- bind = gimple_build_bind (NULL, gimple_seq_alloc_with_stmt (stmt), block);
+ bind = gimple_build_bind (NULL, NULL, block);
+ gsi_replace (gsi_p, bind, true);
+ gimple_bind_add_stmt (bind, stmt);
tbody = gimple_bind_body (bind);
gimplify_and_add (lock, &tbody);
gimple_bind_set_body (bind, tbody);
- lower_omp (gimple_omp_body (stmt), ctx);
+ lower_omp (gimple_omp_body_ptr (stmt), ctx);
gimple_omp_set_body (stmt, maybe_catch_exception (gimple_omp_body (stmt)));
gimple_bind_add_seq (bind, gimple_omp_body (stmt));
gimple_omp_set_body (stmt, NULL);
@@ -6215,7 +6209,6 @@ lower_omp_critical (gimple_stmt_iterator *gsi_p, omp_context *ctx)
pop_gimplify_context (bind);
gimple_bind_append_vars (bind, ctx->block_vars);
BLOCK_VARS (block) = gimple_bind_vars (bind);
- gsi_replace (gsi_p, bind, true);
}
@@ -6283,11 +6276,15 @@ lower_omp_for (gimple_stmt_iterator *gsi_p, omp_context *ctx)
push_gimplify_context (&gctx);
- lower_omp (gimple_omp_for_pre_body (stmt), ctx);
- lower_omp (gimple_omp_body (stmt), ctx);
+ lower_omp (gimple_omp_for_pre_body_ptr (stmt), ctx);
+ lower_omp (gimple_omp_body_ptr (stmt), ctx);
block = make_node (BLOCK);
new_stmt = gimple_build_bind (NULL, NULL, block);
+ /* Replace at gsi right away, so that 'stmt' is no member
+ of a sequence anymore as we're going to add to to a different
+ one below. */
+ gsi_replace (gsi_p, new_stmt, true);
/* Move declaration of temporaries in the loop body before we make
it go away. */
@@ -6357,7 +6354,6 @@ lower_omp_for (gimple_stmt_iterator *gsi_p, omp_context *ctx)
gimple_bind_set_body (new_stmt, body);
gimple_omp_set_body (stmt, NULL);
gimple_omp_for_set_pre_body (stmt, NULL);
- gsi_replace (gsi_p, new_stmt, true);
}
/* Callback for walk_stmts. Check if the current statement only contains
@@ -6710,7 +6706,7 @@ lower_omp_taskreg (gimple_stmt_iterator *gsi_p, omp_context *ctx)
par_olist = NULL;
par_ilist = NULL;
lower_rec_input_clauses (clauses, &par_ilist, &par_olist, ctx);
- lower_omp (par_body, ctx);
+ lower_omp (&par_body, ctx);
if (gimple_code (stmt) == GIMPLE_OMP_PARALLEL)
lower_reduction_clauses (clauses, &par_olist, ctx);
@@ -6756,15 +6752,10 @@ lower_omp_taskreg (gimple_stmt_iterator *gsi_p, omp_context *ctx)
gimple_omp_set_body (stmt, new_body);
bind = gimple_build_bind (NULL, NULL, gimple_bind_block (par_bind));
- gimple_bind_add_stmt (bind, stmt);
- if (ilist || olist)
- {
- gimple_seq_add_stmt (&ilist, bind);
- gimple_seq_add_seq (&ilist, olist);
- bind = gimple_build_bind (NULL, ilist, NULL);
- }
-
gsi_replace (gsi_p, bind, true);
+ gimple_bind_add_seq (bind, ilist);
+ gimple_bind_add_stmt (bind, stmt);
+ gimple_bind_add_seq (bind, olist);
pop_gimplify_context (NULL);
}
@@ -6829,17 +6820,17 @@ lower_omp_1 (gimple_stmt_iterator *gsi_p, omp_context *ctx)
gimple_regimplify_operands (stmt, gsi_p);
break;
case GIMPLE_CATCH:
- lower_omp (gimple_catch_handler (stmt), ctx);
+ lower_omp (gimple_catch_handler_ptr (stmt), ctx);
break;
case GIMPLE_EH_FILTER:
- lower_omp (gimple_eh_filter_failure (stmt), ctx);
+ lower_omp (gimple_eh_filter_failure_ptr (stmt), ctx);
break;
case GIMPLE_TRY:
- lower_omp (gimple_try_eval (stmt), ctx);
- lower_omp (gimple_try_cleanup (stmt), ctx);
+ lower_omp (gimple_try_eval_ptr (stmt), ctx);
+ lower_omp (gimple_try_cleanup_ptr (stmt), ctx);
break;
case GIMPLE_BIND:
- lower_omp (gimple_bind_body (stmt), ctx);
+ lower_omp (gimple_bind_body_ptr (stmt), ctx);
break;
case GIMPLE_OMP_PARALLEL:
case GIMPLE_OMP_TASK:
@@ -6892,11 +6883,11 @@ lower_omp_1 (gimple_stmt_iterator *gsi_p, omp_context *ctx)
}
static void
-lower_omp (gimple_seq body, omp_context *ctx)
+lower_omp (gimple_seq *body, omp_context *ctx)
{
location_t saved_location = input_location;
- gimple_stmt_iterator gsi = gsi_start (body);
- for (gsi = gsi_start (body); !gsi_end_p (gsi); gsi_next (&gsi))
+ gimple_stmt_iterator gsi;
+ for (gsi = gsi_start (*body); !gsi_end_p (gsi); gsi_next (&gsi))
lower_omp_1 (&gsi, ctx);
input_location = saved_location;
}
@@ -6926,7 +6917,7 @@ execute_lower_omp (void)
if (task_shared_vars)
push_gimplify_context (&gctx);
- lower_omp (body, NULL);
+ lower_omp (&body, NULL);
if (task_shared_vars)
pop_gimplify_context (NULL);
}
@@ -7104,7 +7095,7 @@ diagnose_sb_2 (gimple_stmt_iterator *gsi_p, bool *handled_ops_p,
case GIMPLE_OMP_ORDERED:
case GIMPLE_OMP_CRITICAL:
wi->info = stmt;
- walk_gimple_seq (gimple_omp_body (stmt), diagnose_sb_2, NULL, wi);
+ walk_gimple_seq_mod (gimple_omp_body_ptr (stmt), diagnose_sb_2, NULL, wi);
wi->info = context;
break;
@@ -7112,9 +7103,9 @@ diagnose_sb_2 (gimple_stmt_iterator *gsi_p, bool *handled_ops_p,
wi->info = stmt;
/* gimple_omp_for_{index,initial,final} are all DECLs; no need to
walk them. */
- walk_gimple_seq (gimple_omp_for_pre_body (stmt),
- diagnose_sb_2, NULL, wi);
- walk_gimple_seq (gimple_omp_body (stmt), diagnose_sb_2, NULL, wi);
+ walk_gimple_seq_mod (gimple_omp_for_pre_body_ptr (stmt),
+ diagnose_sb_2, NULL, wi);
+ walk_gimple_seq_mod (gimple_omp_body_ptr (stmt), diagnose_sb_2, NULL, wi);
wi->info = context;
break;
@@ -7187,7 +7178,9 @@ diagnose_omp_structured_block_errors (void)
memset (&wi, 0, sizeof (wi));
wi.want_locations = true;
- walk_gimple_seq (body, diagnose_sb_2, NULL, &wi);
+ walk_gimple_seq_mod (&body, diagnose_sb_2, NULL, &wi);
+
+ gimple_set_body (current_function_decl, body);
splay_tree_delete (all_labels);
all_labels = NULL;