From d26fc9797bd7888d50fb8d09fbe7d258b0236444 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Fri, 10 Jul 2015 12:26:19 +0200 Subject: [PATCH] re PR middle-end/66820 (internal compiler error: in get_expr_operands, at tree-ssa-operands.c:910) PR middle-end/66820 * gimplify.c (maybe_fold_stmt): Don't fold in ORT_PARALLEL or ORT_TASK contexts. * omp-low.c (lower_omp): Call fold_stmt even if taskreg_nesting_level is non-zero. * gcc.dg/gomp/pr66820.c: New test. From-SVN: r225661 --- gcc/ChangeLog | 8 ++++++++ gcc/gimplify.c | 9 +++++---- gcc/omp-low.c | 4 ++-- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/gomp/pr66820.c | 18 ++++++++++++++++++ 5 files changed, 38 insertions(+), 6 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/gomp/pr66820.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 8d4d499060a..e3b8d27da86 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2015-07-10 Jakub Jelinek + + PR middle-end/66820 + * gimplify.c (maybe_fold_stmt): Don't fold in ORT_PARALLEL + or ORT_TASK contexts. + * omp-low.c (lower_omp): Call fold_stmt even if taskreg_nesting_level + is non-zero. + 2015-07-10 Kyrylo Tkachov * expr.c (expand_cond_expr_using_cmove): Fix typos in comment diff --git a/gcc/gimplify.c b/gcc/gimplify.c index c621305fe6b..07ea2a7aa61 100644 --- a/gcc/gimplify.c +++ b/gcc/gimplify.c @@ -2245,16 +2245,17 @@ gimplify_arg (tree *arg_p, gimple_seq *pre_p, location_t call_location) return gimplify_expr (arg_p, pre_p, NULL, test, fb); } -/* Don't fold inside offloading regions: it can break code by adding decl - references that weren't in the source. We'll do it during omplower pass - instead. */ +/* Don't fold inside offloading or taskreg regions: it can break code by + adding decl references that weren't in the source. We'll do it during + omplower pass instead. */ static bool maybe_fold_stmt (gimple_stmt_iterator *gsi) { struct gimplify_omp_ctx *ctx; for (ctx = gimplify_omp_ctxp; ctx; ctx = ctx->outer_context) - if (ctx->region_type == ORT_TARGET) + if (ctx->region_type == ORT_TARGET + || (ctx->region_type & (ORT_PARALLEL | ORT_TASK)) != 0) return false; return fold_stmt (gsi); } diff --git a/gcc/omp-low.c b/gcc/omp-low.c index 2517f1873cd..aa1e6666dbd 100644 --- a/gcc/omp-low.c +++ b/gcc/omp-low.c @@ -11890,8 +11890,8 @@ lower_omp (gimple_seq *body, omp_context *ctx) for (gsi = gsi_start (*body); !gsi_end_p (gsi); gsi_next (&gsi)) lower_omp_1 (&gsi, ctx); /* During gimplification, we haven't folded statments inside offloading - regions (gimplify.c:maybe_fold_stmt); do that now. */ - if (target_nesting_level) + or taskreg regions (gimplify.c:maybe_fold_stmt); do that now. */ + if (target_nesting_level || taskreg_nesting_level) for (gsi = gsi_start (*body); !gsi_end_p (gsi); gsi_next (&gsi)) fold_stmt (&gsi); input_location = saved_location; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index eb59054b49a..04c64c45ff9 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2015-07-10 Jakub Jelinek + + PR middle-end/66820 + * gcc.dg/gomp/pr66820.c: New test. + 2015-07-10 Paolo Carlini PR c++/65592 diff --git a/gcc/testsuite/gcc.dg/gomp/pr66820.c b/gcc/testsuite/gcc.dg/gomp/pr66820.c new file mode 100644 index 00000000000..2fe4af1871a --- /dev/null +++ b/gcc/testsuite/gcc.dg/gomp/pr66820.c @@ -0,0 +1,18 @@ +/* PR middle-end/66820 */ +/* { dg-do compile } */ +/* { dg-options "-fopenmp" } */ + +void bar (char *); + +void +foo (char **x) +{ +#pragma omp parallel for + for (int i = 0; i < 16; i++) + { + char y[50]; + __builtin_strcpy (y, x[i]); + __builtin_strcat (y, "foo"); + bar (y); + } +} -- 2.30.2