From 3b4218cc9f243cfe796dd933e8d0abd9c610503e Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Thu, 24 Jan 2019 20:17:13 +0100 Subject: [PATCH] re PR middle-end/89015 (ICE in lookup_decl_in_outer_ctx, at omp-low.c:3480) PR middle-end/89015 * tree-nested.c (convert_nonlocal_reference_stmt, convert_local_reference_stmt, convert_tramp_reference_stmt, convert_gimple_call) : Treat gimple_omp_teams_host teams stmts like GIMPLE_OMP_PARALLEL or GIMPLE_OMP_TASK. * gcc.dg/gomp/pr89015.c: New test. From-SVN: r268246 --- gcc/ChangeLog | 7 ++++ gcc/testsuite/ChangeLog | 3 ++ gcc/testsuite/gcc.dg/gomp/pr89015.c | 25 ++++++++++++ gcc/tree-nested.c | 61 +++++++++++++++++++++-------- 4 files changed, 79 insertions(+), 17 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/gomp/pr89015.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index efb20f77dee..7087ef1a4f5 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,12 @@ 2019-01-24 Jakub Jelinek + PR middle-end/89015 + * tree-nested.c (convert_nonlocal_reference_stmt, + convert_local_reference_stmt, convert_tramp_reference_stmt, + convert_gimple_call) : Treat + gimple_omp_teams_host teams stmts like GIMPLE_OMP_PARALLEL + or GIMPLE_OMP_TASK. + PR tree-optimization/89027 * tree-inline.c (add_clobbers_to_eh_landing_pad): Don't add clobbers for "omp simd array" variables. diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 809c952e30a..f7423fe9b38 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2019-01-24 Jakub Jelinek + PR middle-end/89015 + * gcc.dg/gomp/pr89015.c: New test. + PR c++/88976 * c-c++-common/gomp/cancel-2.c: New test. * gcc.dg/gomp/cancel-1.c: New test. diff --git a/gcc/testsuite/gcc.dg/gomp/pr89015.c b/gcc/testsuite/gcc.dg/gomp/pr89015.c new file mode 100644 index 00000000000..90363517172 --- /dev/null +++ b/gcc/testsuite/gcc.dg/gomp/pr89015.c @@ -0,0 +1,25 @@ +/* PR middle-end/89015 */ +/* { dg-do compile } */ + +int +foo (int n, float *x, float *y) +{ + int i; + int bar (void) { return i; } +#pragma omp teams distribute parallel for simd + for (i = 0; i < n; i++) + y[i] = x[i]; + return bar (); +} + +int +baz (int n, float *x, float *y) +{ + int i; + int qux (void) { +#pragma omp teams distribute parallel for simd + for (i = 0; i < n; i++) + y[i] = x[i]; + } + return qux (); +} diff --git a/gcc/tree-nested.c b/gcc/tree-nested.c index 504afafbb47..3fe23cc2b22 100644 --- a/gcc/tree-nested.c +++ b/gcc/tree-nested.c @@ -1497,6 +1497,20 @@ convert_nonlocal_reference_stmt (gimple_stmt_iterator *gsi, bool *handled_ops_p, } break; + case GIMPLE_OMP_TEAMS: + if (!gimple_omp_teams_host (as_a (stmt))) + { + save_suppress = info->suppress_expansion; + convert_nonlocal_omp_clauses (gimple_omp_teams_clauses_ptr (stmt), + wi); + walk_body (convert_nonlocal_reference_stmt, + convert_nonlocal_reference_op, info, + gimple_omp_body_ptr (stmt)); + info->suppress_expansion = save_suppress; + break; + } + /* FALLTHRU */ + case GIMPLE_OMP_PARALLEL: case GIMPLE_OMP_TASK: save_suppress = info->suppress_expansion; @@ -1601,14 +1615,6 @@ convert_nonlocal_reference_stmt (gimple_stmt_iterator *gsi, bool *handled_ops_p, info->suppress_expansion = save_suppress; break; - case GIMPLE_OMP_TEAMS: - save_suppress = info->suppress_expansion; - convert_nonlocal_omp_clauses (gimple_omp_teams_clauses_ptr (stmt), wi); - walk_body (convert_nonlocal_reference_stmt, convert_nonlocal_reference_op, - info, gimple_omp_body_ptr (stmt)); - info->suppress_expansion = save_suppress; - break; - case GIMPLE_OMP_SECTION: case GIMPLE_OMP_MASTER: case GIMPLE_OMP_ORDERED: @@ -2168,6 +2174,18 @@ convert_local_reference_stmt (gimple_stmt_iterator *gsi, bool *handled_ops_p, switch (gimple_code (stmt)) { + case GIMPLE_OMP_TEAMS: + if (!gimple_omp_teams_host (as_a (stmt))) + { + save_suppress = info->suppress_expansion; + convert_local_omp_clauses (gimple_omp_teams_clauses_ptr (stmt), wi); + walk_body (convert_local_reference_stmt, convert_local_reference_op, + info, gimple_omp_body_ptr (stmt)); + info->suppress_expansion = save_suppress; + break; + } + /* FALLTHRU */ + case GIMPLE_OMP_PARALLEL: case GIMPLE_OMP_TASK: save_suppress = info->suppress_expansion; @@ -2299,14 +2317,6 @@ convert_local_reference_stmt (gimple_stmt_iterator *gsi, bool *handled_ops_p, info->static_chain_added |= save_static_chain_added; break; - case GIMPLE_OMP_TEAMS: - save_suppress = info->suppress_expansion; - convert_local_omp_clauses (gimple_omp_teams_clauses_ptr (stmt), wi); - walk_body (convert_local_reference_stmt, convert_local_reference_op, - info, gimple_omp_body_ptr (stmt)); - info->suppress_expansion = save_suppress; - break; - case GIMPLE_OMP_SECTION: case GIMPLE_OMP_MASTER: case GIMPLE_OMP_ORDERED: @@ -2607,6 +2617,14 @@ convert_tramp_reference_stmt (gimple_stmt_iterator *gsi, bool *handled_ops_p, break; } + case GIMPLE_OMP_TEAMS: + if (!gimple_omp_teams_host (as_a (stmt))) + { + *handled_ops_p = false; + return NULL_TREE; + } + goto do_parallel; + case GIMPLE_OMP_TARGET: if (!is_gimple_omp_offloaded (stmt)) { @@ -2616,6 +2634,7 @@ convert_tramp_reference_stmt (gimple_stmt_iterator *gsi, bool *handled_ops_p, /* FALLTHRU */ case GIMPLE_OMP_PARALLEL: case GIMPLE_OMP_TASK: + do_parallel: { tree save_local_var_chain = info->new_local_var_chain; walk_gimple_op (stmt, convert_tramp_reference_op, wi); @@ -2723,6 +2742,15 @@ convert_gimple_call (gimple_stmt_iterator *gsi, bool *handled_ops_p, } break; + case GIMPLE_OMP_TEAMS: + if (!gimple_omp_teams_host (as_a (stmt))) + { + walk_body (convert_gimple_call, NULL, info, + gimple_omp_body_ptr (stmt)); + break; + } + /* FALLTHRU */ + case GIMPLE_OMP_PARALLEL: case GIMPLE_OMP_TASK: save_static_chain_added = info->static_chain_added; @@ -2798,7 +2826,6 @@ convert_gimple_call (gimple_stmt_iterator *gsi, bool *handled_ops_p, case GIMPLE_OMP_SECTIONS: case GIMPLE_OMP_SECTION: case GIMPLE_OMP_SINGLE: - case GIMPLE_OMP_TEAMS: case GIMPLE_OMP_MASTER: case GIMPLE_OMP_TASKGROUP: case GIMPLE_OMP_ORDERED: -- 2.30.2