diff options
author | Thomas Koenig <tkoenig@gcc.gnu.org> | 2011-12-11 17:43:22 +0000 |
---|---|---|
committer | Thomas Koenig <tkoenig@gcc.gnu.org> | 2011-12-11 17:43:22 +0000 |
commit | e07e39f6e56373b87d59806a3cce7fc3bcd8c57e (patch) | |
tree | 351adb196039634636b2c08ffb2fd4ff7f846895 /gcc/fortran | |
parent | be0c93c5125a61fe670541d8677617a2168e796d (diff) | |
download | gcc-e07e39f6e56373b87d59806a3cce7fc3bcd8c57e.zip gcc-e07e39f6e56373b87d59806a3cce7fc3bcd8c57e.tar.gz gcc-e07e39f6e56373b87d59806a3cce7fc3bcd8c57e.tar.bz2 |
re PR fortran/50690 (ICE with front end optimization and OMP workshare)
2011-12-11 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/50690
* frontend-passes.c (in_omp_workshare): New variable.
(cfe_expr_0): Don't eliminiate common function if it would put
the variable immediately into a WORKSHARE construct.
(optimize_namespace): Set in_omp_workshare.
(gfc_code_walker): Keep track of OMP PARALLEL and OMP WORKSHARE
constructs.
2011-12-11 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/50690
* gfortran.dg/gomp/workshare2.f90: New test.
* gfortran.dg/gomp/workshare3.f90: New test.
From-SVN: r182208
Diffstat (limited to 'gcc/fortran')
-rw-r--r-- | gcc/fortran/ChangeLog | 10 | ||||
-rw-r--r-- | gcc/fortran/frontend-passes.c | 38 |
2 files changed, 46 insertions, 2 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index a1b18c0..49aacc8 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,13 @@ +2011-12-11 Thomas Koenig <tkoenig@gcc.gnu.org> + + PR fortran/50690 + * frontend-passes.c (in_omp_workshare): New variable. + (cfe_expr_0): Don't eliminiate common function if it would put + the variable immediately into a WORKSHARE construct. + (optimize_namespace): Set in_omp_workshare. + (gfc_code_walker): Keep track of OMP PARALLEL and OMP WORKSHARE + constructs. + 2011-12-10 Tobias Burnus <burnus@net-b.de> * trans-decl.c (add_argument_checking): Fix syntax. diff --git a/gcc/fortran/frontend-passes.c b/gcc/fortran/frontend-passes.c index a19f22d..ab33a2f 100644 --- a/gcc/fortran/frontend-passes.c +++ b/gcc/fortran/frontend-passes.c @@ -66,6 +66,10 @@ static gfc_namespace *current_ns; static int forall_level; +/* Keep track of whether we are within an OMP workshare. */ + +static bool in_omp_workshare; + /* Entry point - run all passes for a namespace. So far, only an optimization pass is run. */ @@ -367,6 +371,14 @@ cfe_expr_0 (gfc_expr **e, int *walk_subtrees, int i,j; gfc_expr *newvar; + /* Don't do this optimization within OMP workshare. */ + + if (in_omp_workshare) + { + *walk_subtrees = 0; + return 0; + } + expr_count = 0; gfc_expr_walker (e, cfe_register_funcs, NULL); @@ -505,6 +517,7 @@ optimize_namespace (gfc_namespace *ns) current_ns = ns; forall_level = 0; + in_omp_workshare = false; gfc_code_walker (&ns->code, convert_do_while, dummy_expr_callback, NULL); gfc_code_walker (&ns->code, cfe_code, cfe_expr_0, NULL); @@ -1150,11 +1163,13 @@ gfc_code_walker (gfc_code **c, walk_code_fn_t codefn, walk_expr_fn_t exprfn, gfc_actual_arglist *a; gfc_code *co; gfc_association_list *alist; + bool saved_in_omp_workshare; /* There might be statement insertions before the current code, which must not affect the expression walker. */ co = *c; + saved_in_omp_workshare = in_omp_workshare; switch (co->op) { @@ -1330,16 +1345,34 @@ gfc_code_walker (gfc_code **c, walk_code_fn_t codefn, walk_expr_fn_t exprfn, WALK_SUBEXPR (co->ext.dt->extra_comma); break; - case EXEC_OMP_DO: case EXEC_OMP_PARALLEL: case EXEC_OMP_PARALLEL_DO: case EXEC_OMP_PARALLEL_SECTIONS: + + in_omp_workshare = false; + + /* This goto serves as a shortcut to avoid code + duplication or a larger if or switch statement. */ + goto check_omp_clauses; + + case EXEC_OMP_WORKSHARE: case EXEC_OMP_PARALLEL_WORKSHARE: + + in_omp_workshare = true; + + /* Fall through */ + + case EXEC_OMP_DO: case EXEC_OMP_SECTIONS: case EXEC_OMP_SINGLE: - case EXEC_OMP_WORKSHARE: case EXEC_OMP_END_SINGLE: case EXEC_OMP_TASK: + + /* Come to this label only from the + EXEC_OMP_PARALLEL_* cases above. */ + + check_omp_clauses: + if (co->ext.omp_clauses) { WALK_SUBEXPR (co->ext.omp_clauses->if_expr); @@ -1366,6 +1399,7 @@ gfc_code_walker (gfc_code **c, walk_code_fn_t codefn, walk_expr_fn_t exprfn, if (co->op == EXEC_FORALL) forall_level --; + in_omp_workshare = saved_in_omp_workshare; } } return 0; |