aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-cfg.c
diff options
context:
space:
mode:
authorRichard Henderson <rth@redhat.com>2006-04-13 16:44:25 -0700
committerRichard Henderson <rth@gcc.gnu.org>2006-04-13 16:44:25 -0700
commit777f7f9a72532980c1b5cfa05a7a1f032807f10f (patch)
treebb861aba6cb32495b9e9f3ecc9c7b1dab32bf035 /gcc/tree-cfg.c
parenta239aa95dc5271ebabed7a98e026b69bc16d9b85 (diff)
downloadgcc-777f7f9a72532980c1b5cfa05a7a1f032807f10f.zip
gcc-777f7f9a72532980c1b5cfa05a7a1f032807f10f.tar.gz
gcc-777f7f9a72532980c1b5cfa05a7a1f032807f10f.tar.bz2
re PR libgomp/26651 ([gomp] #omp for ordered leaks memory)
PR 26651 * gimple-low.c (lower_omp_directive): Remove dead code. (lower_stmt): Do nothing except for openmp, except for OMP_PARALLEL. * gimplify.c (gimplify_expr): Update for OMP_RETURN, OMP_CONTINUE. * omp-low.c (struct omp_region): Move to tree-flow.h. (root_omp_region): Export. (omp_regions, lookup_omp_region): Remove. (determine_parallel_type): Update for struct omp_region changes. (dump_omp_region): Dump regions with block numbers. (new_omp_region): Take type and block instead of stmt; malloc instead of ggc. (free_omp_region_1, free_omp_regions): New. (expand_parallel_call): Take entry_stmt as argument; update for changes to omp_region. (remove_exit_barrier): Rewrite to update OMP_RETURN_NOWAIT. (remove_exit_barriers): New. (expand_omp_parallel): Update for struct omp_region changes. (expand_omp_synch): Likewise. (expand_omp): Likewise. (expand_omp_for_static_nochunk): Likewise; update for OMP_CONTINUE. (expand_omp_for_static_chunk): Likewise. (expand_omp_for): Likewise. (expand_omp_for_generic): Likewise; emit the proper GOMP_loop_end call. (expand_omp_sections): Similarly, with GOMP_sections_end. (expand_omp_single): New. (build_omp_regions_1): Update for OMP_CONTINUE. (execute_expand_omp): Call remove_exit_barriers, free_omp_regions. (lower_omp_sections): Expand with OMP_CONTINUE, do not collect OMP_SECTIONS_SECTIONS. (lower_omp_single_simple): Don't emit barrier here. (lower_omp_single_copy): Likewise. (lower_omp_single): Fix bindings, and lower to straightline now. (lower_omp_master, lower_omp_ordered): Likewise. (lower_omp_critical): Likewise. (lower_omp_for): Likewise. Emit OMP_CONTINUE. * tree-cfg.c (make_edges): Collect an omp_region tree, use it for omp edges, free it afterward. (make_omp_sections_edges): Remove. (is_ctrl_altering_stmt): Don't bother checking flag_openmp. (move_stmt_r): Handle OMP_CONTINUE. * tree-flow.h (struct omp_region): Move from omp-low.c. Switch statement pointers to basic blocks. Add type member. (root_omp_region, new_omp_region, free_omp_regions): Declare. * tree-gimple.c (is_gimple_stmt): Handle OMP_RETURN, OMP_CONTINUE. * tree-inline.c (estimate_num_insns_1): Likewise. * tree-pretty-print.c (dump_generic_node): Likewise. * tree-ssa-operands.c (get_expr_operands): Likewise. * tree.def (OMP_SECTIONS): Remove OMP_SECTIONS_SECTIONS operand. (OMP_RETURN): Rename from OMP_RETURN_EXPR. (OMP_CONTINUE): New. * tree.h (OMP_DIRECTIVE_P): Add OMP_CONTINUE. (OMP_SECTIONS_SECTIONS): Remove. (OMP_SECTION_LAST): New. (OMP_RETURN_NOWAIT): New. fortran/ * trans-openmp.c (gfc_trans_omp_sections): Adjust for changed number of operands to OMP_SECTIONS. testsuite/ * g++.dg/gomp/block-0.C: Update expected matches. From-SVN: r112935
Diffstat (limited to 'gcc/tree-cfg.c')
-rw-r--r--gcc/tree-cfg.c92
1 files changed, 52 insertions, 40 deletions
diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c
index a62331b..7fa936e 100644
--- a/gcc/tree-cfg.c
+++ b/gcc/tree-cfg.c
@@ -103,7 +103,6 @@ static void make_edges (void);
static void make_cond_expr_edges (basic_block);
static void make_switch_expr_edges (basic_block);
static void make_goto_expr_edges (basic_block);
-static void make_omp_sections_edges (basic_block);
static edge tree_redirect_edge_and_branch (edge, basic_block);
static edge tree_try_redirect_by_replacing_jump (edge, basic_block);
static unsigned int split_critical_edges (void);
@@ -447,6 +446,7 @@ static void
make_edges (void)
{
basic_block bb;
+ struct omp_region *cur_region = NULL;
/* Create an edge from entry to the first block with executable
statements in it. */
@@ -460,7 +460,8 @@ make_edges (void)
if (last)
{
- switch (TREE_CODE (last))
+ enum tree_code code = TREE_CODE (last);
+ switch (code)
{
case GOTO_EXPR:
make_goto_expr_edges (bb);
@@ -522,20 +523,55 @@ make_edges (void)
case OMP_ORDERED:
case OMP_CRITICAL:
case OMP_SECTION:
+ cur_region = new_omp_region (bb, code, cur_region);
fallthru = true;
break;
- case OMP_RETURN_EXPR:
- /* In the case of an OMP_SECTION, we may have already made
- an edge in make_omp_sections_edges. */
- fallthru = EDGE_COUNT (bb->succs) == 0;
- break;
-
case OMP_SECTIONS:
- make_omp_sections_edges (bb);
+ cur_region = new_omp_region (bb, code, cur_region);
fallthru = false;
break;
+ case OMP_RETURN:
+ /* In the case of an OMP_SECTION, the edge will go somewhere
+ other than the next block. This will be created later. */
+ cur_region->exit = bb;
+ fallthru = cur_region->type != OMP_SECTION;
+ cur_region = cur_region->outer;
+ break;
+
+ case OMP_CONTINUE:
+ cur_region->cont = bb;
+ switch (cur_region->type)
+ {
+ case OMP_FOR:
+ /* ??? Technically there should be a some sort of loopback
+ edge here, but it goes to a block that doesn't exist yet,
+ and without it, updating the ssa form would be a real
+ bear. Fortunately, we don't yet do ssa before expanding
+ these nodes. */
+ break;
+
+ case OMP_SECTIONS:
+ /* Wire up the edges into and out of the nested sections. */
+ /* ??? Similarly wrt loopback. */
+ {
+ struct omp_region *i;
+ for (i = cur_region->inner; i ; i = i->next)
+ {
+ gcc_assert (i->type == OMP_SECTION);
+ make_edge (cur_region->entry, i->entry, 0);
+ make_edge (i->exit, bb, EDGE_FALLTHRU);
+ }
+ }
+ break;
+
+ default:
+ gcc_unreachable ();
+ }
+ fallthru = true;
+ break;
+
default:
gcc_assert (!stmt_ends_bb_p (last));
fallthru = true;
@@ -548,6 +584,9 @@ make_edges (void)
make_edge (bb, bb->next_bb, EDGE_FALLTHRU);
}
+ if (root_omp_region)
+ free_omp_regions ();
+
/* Fold COND_EXPR_COND of each COND_EXPR. */
fold_cond_expr_cond ();
@@ -556,35 +595,6 @@ make_edges (void)
}
-/* Link an OMP_SECTIONS block to all the OMP_SECTION blocks in its body. */
-
-static void
-make_omp_sections_edges (basic_block bb)
-{
- basic_block exit_bb;
- size_t i, n;
- tree vec, stmt;
-
- stmt = last_stmt (bb);
- vec = OMP_SECTIONS_SECTIONS (stmt);
- n = TREE_VEC_LENGTH (vec);
- exit_bb = bb_for_stmt (TREE_VEC_ELT (vec, n - 1));
-
- for (i = 0; i < n - 1; i += 2)
- {
- basic_block start_bb = bb_for_stmt (TREE_VEC_ELT (vec, i));
- basic_block end_bb = bb_for_stmt (TREE_VEC_ELT (vec, i + 1));
- make_edge (bb, start_bb, 0);
- make_edge (end_bb, exit_bb, EDGE_FALLTHRU);
- }
-
- /* Once the CFG has been built, the vector of sections is no longer
- useful. The region can be easily obtained with build_omp_regions.
- Furthermore, this sharing of tree expressions is not allowed by the
- statement verifier. */
- OMP_SECTIONS_SECTIONS (stmt) = NULL_TREE;
-}
-
/* Create the edges for a COND_EXPR starting at block BB.
At this point, both clauses must contain only simple gotos. */
@@ -2498,7 +2508,7 @@ is_ctrl_altering_stmt (tree t)
}
/* OpenMP directives alter control flow. */
- if (flag_openmp && OMP_DIRECTIVE_P (t))
+ if (OMP_DIRECTIVE_P (t))
return true;
/* If a statement can throw, it alters control flow. */
@@ -4549,7 +4559,9 @@ move_stmt_r (tree *tp, int *walk_subtrees, void *data)
if (p->block && IS_EXPR_CODE_CLASS (TREE_CODE_CLASS (TREE_CODE (t))))
TREE_BLOCK (t) = p->block;
- if (OMP_DIRECTIVE_P (t) && TREE_CODE (t) != OMP_RETURN_EXPR)
+ if (OMP_DIRECTIVE_P (t)
+ && TREE_CODE (t) != OMP_RETURN
+ && TREE_CODE (t) != OMP_CONTINUE)
{
/* Do not remap variables inside OMP directives. Variables
referenced in clauses and directive header belong to the