Patchwork PR 56043, Fix segfault in 4.7/4.8 powerpc tests

login
register
mail settings
Submitter Michael Meissner
Date Feb. 7, 2013, 10:34 p.m.
Message ID <20130207223408.GA19552@ibm-tiger.the-meissners.org>
Download mbox | patch
Permalink /patch/219011/
State New
Headers show

Comments

Michael Meissner - Feb. 7, 2013, 10:34 p.m.
The following patch fixes a segmentation fault for the powerpc-none-eabi
toolchain on the vsx-mass-1.c test.  Some of the builtin functions are not
defined in that environment, and the compiler did not check whether a pointer
was NULL before using it.  I also fixed the test so that it would only run
under powerpc*-*-linux*, since the text would fail on systems like eabi because
some of the builtin functions would not call their vector counterparts in the
MASS library.

I've built both 4.8 and 4.7 with this patch, and I didn't notice any
regressions.  Is it ok to install in both the 4.7 tree and trunk?

[gcc]
2013-02-07  Michael Meissner  <meissner@linux.vnet.ibm.com>

	PR target/56043
	* config/rs6000/rs6000.c (rs6000_builtin_vectorized_libmass):
	If there is no implicit builtin declaration, just return NULL.

[gcc/testsuite]
2013-02-07  Michael Meissner  <meissner@linux.vnet.ibm.com>

	PR target/56043
	* gcc.target/powerpc/vsx-mass-1.c: Only run this test on
	powerpc*-*-linux*.
David Edelsohn - Feb. 8, 2013, 1:46 a.m.
On Thu, Feb 7, 2013 at 5:34 PM, Michael Meissner
<meissner@linux.vnet.ibm.com> wrote:
> The following patch fixes a segmentation fault for the powerpc-none-eabi
> toolchain on the vsx-mass-1.c test.  Some of the builtin functions are not
> defined in that environment, and the compiler did not check whether a pointer
> was NULL before using it.  I also fixed the test so that it would only run
> under powerpc*-*-linux*, since the text would fail on systems like eabi because
> some of the builtin functions would not call their vector counterparts in the
> MASS library.
>
> I've built both 4.8 and 4.7 with this patch, and I didn't notice any
> regressions.  Is it ok to install in both the 4.7 tree and trunk?
>
> [gcc]
> 2013-02-07  Michael Meissner  <meissner@linux.vnet.ibm.com>
>
>         PR target/56043
>         * config/rs6000/rs6000.c (rs6000_builtin_vectorized_libmass):
>         If there is no implicit builtin declaration, just return NULL.
>
> [gcc/testsuite]
> 2013-02-07  Michael Meissner  <meissner@linux.vnet.ibm.com>
>
>         PR target/56043
>         * gcc.target/powerpc/vsx-mass-1.c: Only run this test on
>         powerpc*-*-linux*.

Okay.

Thanks, David

Patch

Index: gcc/config/rs6000/rs6000.c
===================================================================
--- gcc/config/rs6000/rs6000.c	(revision 195825)
+++ gcc/config/rs6000/rs6000.c	(working copy)
@@ -3699,7 +3699,8 @@  rs6000_builtin_vectorized_libmass (tree 
 	  bdecl = builtin_decl_implicit (fn);
 	  suffix = "d2";				/* pow -> powd2 */
 	  if (el_mode != DFmode
-	      || n != 2)
+	      || n != 2
+	      || !bdecl)
 	    return NULL_TREE;
 	  break;
 
@@ -3736,7 +3737,8 @@  rs6000_builtin_vectorized_libmass (tree 
 	  bdecl = builtin_decl_implicit (fn);
 	  suffix = "4";					/* powf -> powf4 */
 	  if (el_mode != SFmode
-	      || n != 4)
+	      || n != 4
+	      || !bdecl)
 	    return NULL_TREE;
 	  break;
 
@@ -3749,6 +3751,9 @@  rs6000_builtin_vectorized_libmass (tree 
 
   gcc_assert (suffix != NULL);
   bname = IDENTIFIER_POINTER (DECL_NAME (bdecl));
+  if (!bname)
+    return NULL_TREE;
+
   strcpy (name, bname + sizeof ("__builtin_") - 1);
   strcat (name, suffix);
 
Index: gcc/testsuite/gcc.target/powerpc/vsx-mass-1.c
===================================================================
--- gcc/testsuite/gcc.target/powerpc/vsx-mass-1.c	(revision 195825)
+++ gcc/testsuite/gcc.target/powerpc/vsx-mass-1.c	(working copy)
@@ -1,4 +1,4 @@ 
-/* { dg-do compile { target { powerpc*-*-* } } } */
+/* { dg-do compile { target { powerpc*-*-linux* } } } */
 /* { dg-skip-if "" { powerpc*-*-darwin* } { "*" } { "" } } */
 /* { dg-require-effective-target powerpc_vsx_ok } */
 /* { dg-options "-O3 -ftree-vectorize -mcpu=power7 -ffast-math -mveclibabi=mass" } */