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
This commit is contained in:
Richard Henderson 2006-04-13 16:44:25 -07:00 committed by Richard Henderson
parent a239aa95dc
commit 777f7f9a72
16 changed files with 685 additions and 556 deletions

View File

@ -1,3 +1,60 @@
2006-04-13 Richard Henderson <rth@redhat.com>
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.
2006-04-13 Roger Sayle <roger@eyesopen.com>
* fold-const.c (native_encode_vector, native_interpret_real):

View File

@ -1,3 +1,8 @@
2006-04-13 Richard Henderson <rth@redhat.com>
* trans-openmp.c (gfc_trans_omp_sections): Adjust for changed
number of operands to OMP_SECTIONS.
2006-04-08 Kazu Hirata <kazu@codesourcery.com>
* gfortran.texi: Fix typos. Follow spelling conventions.

View File

@ -1161,7 +1161,7 @@ gfc_trans_omp_sections (gfc_code *code, gfc_omp_clauses *clauses)
}
stmt = gfc_finish_block (&body);
stmt = build3_v (OMP_SECTIONS, stmt, omp_clauses, NULL);
stmt = build2_v (OMP_SECTIONS, stmt, omp_clauses);
gfc_add_expr_to_block (&block, stmt);
return gfc_finish_block (&block);

View File

@ -159,14 +159,10 @@ lower_stmt_body (tree expr, struct lower_data *data)
static void
lower_omp_directive (tree_stmt_iterator *tsi, struct lower_data *data)
{
tree clause, stmt;
tree stmt;
stmt = tsi_stmt (*tsi);
clause = (TREE_CODE (stmt) >= OMP_PARALLEL && TREE_CODE (stmt) <= OMP_SINGLE)
? OMP_CLAUSES (stmt)
: NULL_TREE;
lower_stmt_body (OMP_BODY (stmt), data);
tsi_link_before (tsi, stmt, TSI_SAME_STMT);
tsi_link_before (tsi, OMP_BODY (stmt), TSI_SAME_STMT);
@ -216,10 +212,6 @@ lower_stmt (tree_stmt_iterator *tsi, struct lower_data *data)
case GOTO_EXPR:
case LABEL_EXPR:
case SWITCH_EXPR:
case OMP_RETURN_EXPR:
break;
case OMP_PARALLEL:
case OMP_FOR:
case OMP_SECTIONS:
case OMP_SECTION:
@ -227,6 +219,11 @@ lower_stmt (tree_stmt_iterator *tsi, struct lower_data *data)
case OMP_MASTER:
case OMP_ORDERED:
case OMP_CRITICAL:
case OMP_RETURN:
case OMP_CONTINUE:
break;
case OMP_PARALLEL:
lower_omp_directive (tsi, data);
return;

View File

@ -5587,7 +5587,8 @@ gimplify_expr (tree *expr_p, tree *pre_p, tree *post_p,
ret = gimplify_omp_atomic (expr_p, pre_p);
break;
case OMP_RETURN_EXPR:
case OMP_RETURN:
case OMP_CONTINUE:
ret = GS_ALL_DONE;
break;

File diff suppressed because it is too large Load Diff

View File

@ -1,3 +1,7 @@
2006-04-13 Richard Henderson <rth@redhat.com>
* g++.dg/gomp/block-0.C: Update expected matches.
2006-04-13 DJ Delorie <dj@redhat.com>
* lib/target-supports.exp (check_effective_target_int32plus): New.

View File

@ -29,5 +29,5 @@ void foo()
}
}
// { dg-final { scan-tree-dump-times "terminate" 8 "omplower" } }
// { dg-final { scan-tree-dump-times "terminate" 10 "omplower" } }
// { dg-final { cleanup-tree-dump "omplower" } }

View File

@ -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,18 +523,53 @@ 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;
case OMP_SECTIONS:
cur_region = new_omp_region (bb, code, cur_region);
fallthru = false;
break;
case OMP_SECTIONS:
make_omp_sections_edges (bb);
fallthru = false;
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:
@ -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

View File

@ -469,6 +469,51 @@ extern void bsi_insert_after (block_stmt_iterator *, tree,
extern void bsi_replace (const block_stmt_iterator *, tree, bool);
/*---------------------------------------------------------------------------
OpenMP Region Tree
---------------------------------------------------------------------------*/
/* Parallel region information. Every parallel and workshare
directive is enclosed between two markers, the OMP_* directive
and a corresponding OMP_RETURN statement. */
struct omp_region
{
/* The enclosing region. */
struct omp_region *outer;
/* First child region. */
struct omp_region *inner;
/* Next peer region. */
struct omp_region *next;
/* Block containing the omp directive as its last stmt. */
basic_block entry;
/* Block containing the OMP_RETURN as its last stmt. */
basic_block exit;
/* Block containing the OMP_CONTINUE as its last stmt. */
basic_block cont;
/* If this is a combined parallel+workshare region, this is a list
of additional arguments needed by the combined parallel+workshare
library call. */
tree ws_args;
/* The code for the omp directive of this region. */
enum tree_code type;
/* True if this is a combined parallel+workshare region. */
bool is_combined_parallel;
};
extern struct omp_region *root_omp_region;
extern struct omp_region *new_omp_region (basic_block, enum tree_code,
struct omp_region *);
extern void free_omp_regions (void);
/*---------------------------------------------------------------------------
Function prototypes
---------------------------------------------------------------------------*/

View File

@ -224,7 +224,8 @@ is_gimple_stmt (tree t)
case OMP_MASTER:
case OMP_ORDERED:
case OMP_CRITICAL:
case OMP_RETURN_EXPR:
case OMP_RETURN:
case OMP_CONTINUE:
/* These are always void. */
return true;

View File

@ -1603,7 +1603,8 @@ estimate_num_insns_1 (tree *tp, int *walk_subtrees, void *data)
case PHI_NODE:
case WITH_SIZE_EXPR:
case OMP_CLAUSE:
case OMP_RETURN_EXPR:
case OMP_RETURN:
case OMP_CONTINUE:
break;
/* We don't account constants for now. Assume that the cost is amortized

View File

@ -1822,8 +1822,15 @@ dump_generic_node (pretty_printer *buffer, tree node, int spc, int flags,
dump_omp_clauses (buffer, OMP_SINGLE_CLAUSES (node), spc, flags);
goto dump_omp_body;
case OMP_RETURN_EXPR:
case OMP_RETURN:
pp_string (buffer, "OMP_RETURN");
if (OMP_RETURN_NOWAIT (node))
pp_string (buffer, " [nowait]");
is_expr = false;
break;
case OMP_CONTINUE:
pp_string (buffer, "OMP_CONTINUE");
is_expr = false;
break;

View File

@ -2096,11 +2096,12 @@ get_expr_operands (tree stmt, tree *expr_p, int flags)
case OMP_PARALLEL:
case OMP_SECTIONS:
case OMP_FOR:
case OMP_RETURN_EXPR:
case OMP_SINGLE:
case OMP_MASTER:
case OMP_ORDERED:
case OMP_CRITICAL:
case OMP_RETURN:
case OMP_CONTINUE:
/* Expressions that make no memory references. */
return;

View File

@ -987,11 +987,8 @@ DEFTREECODE (OMP_FOR, "omp_for", tcc_statement, 6)
/* OpenMP - #pragma omp sections [clause1 ... clauseN]
Operand 0: OMP_SECTIONS_BODY: Sections body.
Operand 1: OMP_SECTIONS_CLAUSES: List of clauses.
Operand 2: OMP_SECTIONS_SECTIONS: Vector of the different sections
in the body. Only valid after lowering and destroyed
after the CFG has been built. */
DEFTREECODE (OMP_SECTIONS, "omp_sections", tcc_statement, 3)
Operand 1: OMP_SECTIONS_CLAUSES: List of clauses. */
DEFTREECODE (OMP_SECTIONS, "omp_sections", tcc_statement, 2)
/* OpenMP - #pragma omp single
Operand 0: OMP_SINGLE_BODY: Single section body.
@ -1015,6 +1012,13 @@ DEFTREECODE (OMP_ORDERED, "omp_ordered", tcc_statement, 1)
Operand 1: OMP_CRITICAL_NAME: Identifier for critical section. */
DEFTREECODE (OMP_CRITICAL, "omp_critical", tcc_statement, 2)
/* Return from an OpenMP directive. */
DEFTREECODE (OMP_RETURN, "omp_return", tcc_statement, 0)
/* OpenMP - An intermediate tree code to mark the location of the
loop or sections iteration in the partially lowered code. */
DEFTREECODE (OMP_CONTINUE, "omp_continue", tcc_statement, 0)
/* OpenMP - #pragma omp atomic
Operand 0: The address at which the atomic operation is to be performed.
This address should be stabilized with save_expr.
@ -1026,9 +1030,6 @@ DEFTREECODE (OMP_ATOMIC, "omp_atomic", tcc_statement, 2)
/* OpenMP clauses. */
DEFTREECODE (OMP_CLAUSE, "omp_clause", tcc_exceptional, 0)
/* Return from an OpenMP directive. */
DEFTREECODE (OMP_RETURN_EXPR, "omp_return", tcc_statement, 0)
/* Reduction operations.
Operations that take a vector of elements and "reduce" it to a scalar
result (e.g. summing the elements of the vector, finding the minimum over

View File

@ -170,14 +170,15 @@ extern const enum tree_code_class tree_code_type[];
#define OMP_DIRECTIVE_P(NODE) \
(TREE_CODE (NODE) == OMP_PARALLEL \
|| TREE_CODE (NODE) == OMP_SECTIONS \
|| TREE_CODE (NODE) == OMP_SECTION \
|| TREE_CODE (NODE) == OMP_FOR \
|| TREE_CODE (NODE) == OMP_RETURN_EXPR \
|| TREE_CODE (NODE) == OMP_SECTIONS \
|| TREE_CODE (NODE) == OMP_SINGLE \
|| TREE_CODE (NODE) == OMP_SECTION \
|| TREE_CODE (NODE) == OMP_MASTER \
|| TREE_CODE (NODE) == OMP_ORDERED \
|| TREE_CODE (NODE) == OMP_CRITICAL)
|| TREE_CODE (NODE) == OMP_CRITICAL \
|| TREE_CODE (NODE) == OMP_RETURN \
|| TREE_CODE (NODE) == OMP_CONTINUE)
/* Number of argument-words in each kind of tree-node. */
@ -437,6 +438,10 @@ struct tree_common GTY(())
CALL_EXPR
DECL_BY_REFERENCE in
PARM_DECL, RESULT_DECL
OMP_RETURN_NOWAIT in
OMP_RETURN
OMP_SECTION_LAST in
OMP_SECTION
protected_flag:
@ -1546,7 +1551,6 @@ struct tree_constructor GTY(())
#define OMP_SECTIONS_BODY(NODE) TREE_OPERAND (OMP_SECTIONS_CHECK (NODE), 0)
#define OMP_SECTIONS_CLAUSES(NODE) TREE_OPERAND (OMP_SECTIONS_CHECK (NODE), 1)
#define OMP_SECTIONS_SECTIONS(NODE) TREE_OPERAND (OMP_SECTIONS_CHECK (NODE), 2)
#define OMP_SECTION_BODY(NODE) TREE_OPERAND (OMP_SECTION_CHECK (NODE), 0)
@ -1566,6 +1570,18 @@ struct tree_constructor GTY(())
OMP_CLAUSE_PRIVATE, \
OMP_CLAUSE_COPYPRIVATE), 0)
/* True on an OMP_SECTION statement that was the last lexical member.
This status is meaningful in the implementation of lastprivate. */
#define OMP_SECTION_LAST(NODE) \
TREE_PRIVATE (OMP_SECTION_CHECK (NODE))
/* True on an OMP_RETURN statement if the return does not require a
thread synchronization via some sort of barrier. The exact barrier
that would otherwise be emitted is dependent on the OMP statement
with which this return is associated. */
#define OMP_RETURN_NOWAIT(NODE) \
TREE_PRIVATE (OMP_RETURN_CHECK (NODE))
/* True on a PRIVATE clause if its decl is kept around for debugging
information only and its DECL_VALUE_EXPR is supposed to point
to what it has been remapped to. */