[PATCH] Don't segv in omp-low.c (PR middle-end/59669)

Marek Polacek polacek@redhat.com
Wed Jan 8 15:25:00 GMT 2014


On Wed, Jan 08, 2014 at 04:14:06PM +0100, Jakub Jelinek wrote:
> On Wed, Jan 08, 2014 at 04:09:08PM +0100, Marek Polacek wrote:
> > We can also get NULL for the default definition, so we need to handle that
> > before calling has_zero_uses on it.
> > 
> > Bootstrapped/regtested on x86_64-linux, ok for trunk?
> 
> Looks ok, but there is similar code a few lines above, can you please fix it up
> and add it to the testcase?
> 
> I'd think
> #pragma omp declare simd uniform(a) aligned(a:32)
> void
> bar (int *a)
> {
> }
> 
> could hit the other spot.

Indeed it does.  So like this?

2014-01-08  Marek Polacek  <polacek@redhat.com>

	PR middle-end/59669
	* omp-low.c (simd_clone_adjust): Don't crash if def is NULL.
testsuite/
	* gcc.dg/gomp/pr59669-1.c: New test.
	* gcc.dg/gomp/pr59669-2.c: New test.

--- gcc/omp-low.c.mp	2014-01-08 13:48:40.353624984 +0100
+++ gcc/omp-low.c	2014-01-08 16:21:06.247268557 +0100
@@ -11537,7 +11537,7 @@ simd_clone_adjust (struct cgraph_node *n
 	unsigned int alignment = node->simdclone->args[i].alignment;
 	tree orig_arg = node->simdclone->args[i].orig_arg;
 	tree def = ssa_default_def (cfun, orig_arg);
-	if (!has_zero_uses (def))
+	if (def && !has_zero_uses (def))
 	  {
 	    tree fn = builtin_decl_explicit (BUILT_IN_ASSUME_ALIGNED);
 	    gimple_seq seq = NULL;
@@ -11587,7 +11587,7 @@ simd_clone_adjust (struct cgraph_node *n
 	tree def = ssa_default_def (cfun, orig_arg);
 	gcc_assert (INTEGRAL_TYPE_P (TREE_TYPE (orig_arg))
 		    || POINTER_TYPE_P (TREE_TYPE (orig_arg)));
-	if (!has_zero_uses (def))
+	if (def && !has_zero_uses (def))
 	  {
 	    iter1 = make_ssa_name (orig_arg, NULL);
 	    iter2 = make_ssa_name (orig_arg, NULL);
--- gcc/testsuite/gcc.dg/gomp/pr59669-1.c.mp	2014-01-08 13:50:23.710492087 +0100
+++ gcc/testsuite/gcc.dg/gomp/pr59669-1.c	2014-01-08 13:50:54.339622411 +0100
@@ -0,0 +1,9 @@
+/* PR middle-end/59669 */
+/* { dg-do compile } */
+/* { dg-options "-fopenmp" } */
+
+#pragma omp declare simd linear(a)
+void
+foo (int a)
+{
+}
--- gcc/testsuite/gcc.dg/gomp/pr59669-2.c.mp	2014-01-08 16:20:35.553121408 +0100
+++ gcc/testsuite/gcc.dg/gomp/pr59669-2.c	2014-01-08 16:20:54.099210269 +0100
@@ -0,0 +1,9 @@
+/* PR middle-end/59669 */
+/* { dg-do compile } */
+/* { dg-options "-fopenmp" } */
+
+#pragma omp declare simd uniform(a) aligned(a:32)
+void
+bar (int *a)
+{
+}

	Marek



More information about the Gcc-patches mailing list