From be3a87e7b5ff3d284a7663519826f2613dc46f69 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Mon, 28 Jan 2019 23:33:33 +0100 Subject: [PATCH] re PR middle-end/89002 (ICE in scan_omp_1_op, at omp-low.c:3166) PR middle-end/89002 * gimplify.c (gimplify_omp_for): When adding OMP_CLAUSE_*_GIMPLE_SEQ for lastprivate/linear IV, push gimplify context around gimplify_assign and, if it needed any temporaries, pop it into a gimple bind around the sequence. * testsuite/libgomp.c/pr89002.c: New test. From-SVN: r268345 --- gcc/ChangeLog | 8 +++ gcc/gimplify.c | 11 +++- libgomp/ChangeLog | 5 ++ libgomp/testsuite/libgomp.c/pr89002.c | 86 +++++++++++++++++++++++++++ 4 files changed, 109 insertions(+), 1 deletion(-) create mode 100644 libgomp/testsuite/libgomp.c/pr89002.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index b4479132090..f5872dbeab7 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2019-01-28 Jakub Jelinek + + PR middle-end/89002 + * gimplify.c (gimplify_omp_for): When adding OMP_CLAUSE_*_GIMPLE_SEQ + for lastprivate/linear IV, push gimplify context around gimplify_assign + and, if it needed any temporaries, pop it into a gimple bind around the + sequence. + 2019-01-28 Bernd Edlinger * common.opt (-Wattribute-alias): Remove "no-" from name. diff --git a/gcc/gimplify.c b/gcc/gimplify.c index 59166783edd..7e37e500d81 100644 --- a/gcc/gimplify.c +++ b/gcc/gimplify.c @@ -11167,8 +11167,17 @@ gimplify_omp_for (tree *expr_p, gimple_seq *pre_p) seq = &OMP_CLAUSE_LASTPRIVATE_GIMPLE_SEQ (c); else seq = &OMP_CLAUSE_LINEAR_GIMPLE_SEQ (c); + push_gimplify_context (); gimplify_assign (decl, t, seq); - } + gimple *bind = NULL; + if (gimplify_ctxp->temps) + { + bind = gimple_build_bind (NULL_TREE, *seq, NULL_TREE); + *seq = NULL; + gimplify_seq_add_stmt (seq, bind); + } + pop_gimplify_context (bind); + } } } diff --git a/libgomp/ChangeLog b/libgomp/ChangeLog index 5a7d4d8346c..e774e7fc1ae 100644 --- a/libgomp/ChangeLog +++ b/libgomp/ChangeLog @@ -1,3 +1,8 @@ +2019-01-28 Jakub Jelinek + + PR middle-end/89002 + * testsuite/libgomp.c/pr89002.c: New test. + 2019-01-28 Richard Biener PR testsuite/89064 diff --git a/libgomp/testsuite/libgomp.c/pr89002.c b/libgomp/testsuite/libgomp.c/pr89002.c new file mode 100644 index 00000000000..b66fada836f --- /dev/null +++ b/libgomp/testsuite/libgomp.c/pr89002.c @@ -0,0 +1,86 @@ +/* PR middle-end/89002 */ + +extern void abort (void); + +int +foo (int x) +{ + int a; + int *p = &a; + +#pragma omp taskloop lastprivate (a) + for (a = 0; a < x; ++a) + ; + return *p; +} + +int +bar (int x) +{ + int a; + int *p = &a; + +#pragma omp parallel +#pragma omp single +#pragma omp taskloop lastprivate (a) + for (a = 0; a < x; ++a) + ; + return *p; +} + +int +main () +{ +#pragma omp parallel +#pragma omp single + { + if (foo (4) != 4) + abort (); + } + if (bar (6) != 6) + abort (); + return 0; +} +/* PR middle-end/89002 */ + +extern void abort (void); + +int +foo (int x) +{ + int a; + int *p = &a; + +#pragma omp taskloop lastprivate (a) + for (a = 0; a < x; ++a) + ; + return *p; +} + +int +bar (int x) +{ + int a; + int *p = &a; + +#pragma omp parallel +#pragma omp single +#pragma omp taskloop lastprivate (a) + for (a = 0; a < x; ++a) + ; + return *p; +} + +int +main () +{ +#pragma omp parallel +#pragma omp single + { + if (foo (4) != 4) + abort (); + } + if (bar (6) != 6) + abort (); + return 0; +} -- 2.30.2