diff options
Diffstat (limited to 'gcc/omp-low.c')
-rw-r--r-- | gcc/omp-low.c | 141 |
1 files changed, 67 insertions, 74 deletions
diff --git a/gcc/omp-low.c b/gcc/omp-low.c index f6b6243..21a5188 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; |