public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [committed] Fix ICE with OpenMP taskloop (PR middle-end/71371)
@ 2016-06-01 14:37 Jakub Jelinek
  0 siblings, 0 replies; only message in thread
From: Jakub Jelinek @ 2016-06-01 14:37 UTC (permalink / raw)
  To: gcc-patches

Hi!

I've committed following patch to fix ICE on taskloop construct where
the IV is addressable.  This doesn't ICE on for, simd or distribute because
it is ORT_WORKSHARE or ORT_SIMD and thus omp_add_variable during
create_tmp_var is called in outer context.  While it doesn't hurt in that
case, as we want to make the var just private or linear in the current
context (the latter without copyin and copyout), it is better not to call
omp_add_variable on it during create_tmp_var at all (we call it a few lines
later with the right flags).
Using create_tmp_var_raw would work too, but we'd have to manually do all
the rest of gimple_add_tmp_var except for omp_add_variable.

Bootstrapped/regtested on x86_64-linux and i686-linux, committed to trunk
and 6.2.

2016-06-01  Jakub Jelinek  <jakub@redhat.com>

	PR middle-end/71371
	* gimplify.c (gimplify_omp_for): Temporarily clear gimplify_omp_ctxp
	around creation of the temporary.

	* c-c++-common/gomp/pr71371.c: New test.

--- gcc/gimplify.c.jj	2016-05-26 10:38:02.000000000 +0200
+++ gcc/gimplify.c	2016-06-01 13:27:23.647789536 +0200
@@ -9007,7 +9007,12 @@ gimplify_omp_for (tree *expr_p, gimple_s
 	       || (ort == ORT_SIMD
 		   && TREE_VEC_LENGTH (OMP_FOR_INIT (for_stmt)) > 1))
 	{
+	  struct gimplify_omp_ctx *ctx = gimplify_omp_ctxp;
+	  /* Make sure omp_add_variable is not called on it prematurely.
+	     We call it ourselves a few lines later.  */
+	  gimplify_omp_ctxp = NULL;
 	  var = create_tmp_var (TREE_TYPE (decl), get_name (decl));
+	  gimplify_omp_ctxp = ctx;
 	  TREE_OPERAND (t, 0) = var;
 
 	  gimplify_seq_add_stmt (&for_body, gimple_build_assign (decl, var));
--- gcc/testsuite/c-c++-common/gomp/pr71371.c.jj	2016-06-01 13:35:18.639633280 +0200
+++ gcc/testsuite/c-c++-common/gomp/pr71371.c	2016-06-01 13:35:37.366390567 +0200
@@ -0,0 +1,25 @@
+/* PR middle-end/71371 */
+/* { dg-do compile } */
+
+void baz (int *);
+
+void
+foo (void)
+{
+  int i;
+  #pragma omp taskloop
+  for (i = 0; i < 100; i++)
+    baz (&i);
+}
+
+void
+bar (void)
+{
+  int i;
+  #pragma omp parallel
+  {
+    #pragma omp for
+    for (i = 0; i < 100; i++)
+      baz (&i);
+  }
+}

	Jakub

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2016-06-01 14:37 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-01 14:37 [committed] Fix ICE with OpenMP taskloop (PR middle-end/71371) Jakub Jelinek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).