diff mbox series

[committed] openmp: Avoid ICEs with declare simd; declare simd inbranch [PR93555]

Message ID 20200205103913.GY17695@tucnak
State New
Headers show
Series [committed] openmp: Avoid ICEs with declare simd; declare simd inbranch [PR93555] | expand

Commit Message

Jakub Jelinek Feb. 5, 2020, 10:39 a.m. UTC
Hi!

The testcases ICE because when processing the declare simd inbranch,
we don't create the i == 0 clone as it already exists, which means
clone_info->nargs is not adjusted, but we then rely on it being adjusted
when trying other clones.

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

2020-02-05  Jakub Jelinek  <jakub@redhat.com>

	PR middle-end/93555
	* omp-simd-clone.c (expand_simd_clones): If simd_clone_mangle or
	simd_clone_create failed when i == 0, adjust clone->nargs by
	clone->inbranch.

	* c-c++-common/gomp/pr93555-1.c: New test.
	* c-c++-common/gomp/pr93555-2.c: New test.
	* gfortran.dg/gomp/pr93555.f90: New test.


	Jakub
diff mbox series

Patch

--- gcc/omp-simd-clone.c.jj	2020-01-12 11:54:36.688409260 +0100
+++ gcc/omp-simd-clone.c	2020-02-04 18:08:11.271036096 +0100
@@ -1713,14 +1713,22 @@  expand_simd_clones (struct cgraph_node *
 	     already.  */
 	  tree id = simd_clone_mangle (node, clone);
 	  if (id == NULL_TREE)
-	    continue;
+	    {
+	      if (i == 0)
+		clone->nargs += clone->inbranch;
+	      continue;
+	    }
 
 	  /* Only when we are sure we want to create the clone actually
 	     clone the function (or definitions) or create another
 	     extern FUNCTION_DECL (for prototypes without definitions).  */
 	  struct cgraph_node *n = simd_clone_create (node);
 	  if (n == NULL)
-	    continue;
+	    {
+	      if (i == 0)
+		clone->nargs += clone->inbranch;
+	      continue;
+	    }
 
 	  n->simdclone = clone;
 	  clone->origin = node;
--- gcc/testsuite/c-c++-common/gomp/pr93555-1.c.jj	2020-02-04 22:28:54.557506688 +0100
+++ gcc/testsuite/c-c++-common/gomp/pr93555-1.c	2020-02-04 22:30:18.575246428 +0100
@@ -0,0 +1,18 @@ 
+/* PR middle-end/93555 */
+/* { dg-do compile } */
+
+#pragma omp declare simd
+#pragma omp declare simd inbranch
+int
+foo (int x)
+{
+  return x;
+}
+
+#pragma omp declare simd inbranch
+#pragma omp declare simd
+int
+bar (int x)
+{
+  return x;
+}
--- gcc/testsuite/c-c++-common/gomp/pr93555-2.c.jj	2020-02-04 22:28:57.581461328 +0100
+++ gcc/testsuite/c-c++-common/gomp/pr93555-2.c	2020-02-04 22:30:25.712139374 +0100
@@ -0,0 +1,16 @@ 
+/* PR middle-end/93555 */
+/* { dg-do compile } */
+
+#pragma omp declare simd
+#pragma omp declare simd inbranch
+void
+foo (void)
+{
+}
+
+#pragma omp declare simd inbranch
+#pragma omp declare simd
+void
+bar (void)
+{
+}
--- gcc/testsuite/gfortran.dg/gomp/pr93555.f90.jj	2020-02-04 22:31:27.578211386 +0100
+++ gcc/testsuite/gfortran.dg/gomp/pr93555.f90	2020-02-04 22:31:18.267351050 +0100
@@ -0,0 +1,11 @@ 
+! PR middle-end/93555
+! { dg-do compile }
+
+subroutine foo
+  !$omp declare simd(foo)
+  !$omp declare simd(foo) inbranch
+end
+subroutine bar
+  !$omp declare simd(bar) inbranch
+  !$omp declare simd(bar)
+end