djdelorie / rpms / glibc

Forked from rpms/glibc 3 years ago
Clone
79cd021
commit 3c0f7407eedb524c9114bb675cd55b903c71daaa
79cd021
Author: Florian Weimer <fweimer@redhat.com>
79cd021
Date:   Mon Mar 7 16:00:25 2016 +0100
79cd021
79cd021
    tst-audit4, tst-audit10: Compile AVX/AVX-512 code separately [BZ #19269]
79cd021
    
79cd021
    This ensures that GCC will not use unsupported instructions before
79cd021
    the run-time check to ensure support.
79cd021
79cd021
Index: b/sysdeps/x86_64/Makefile
79cd021
===================================================================
79cd021
--- a/sysdeps/x86_64/Makefile
79cd021
+++ b/sysdeps/x86_64/Makefile
79cd021
@@ -49,7 +49,7 @@ $(objpfx)tst-audit3: $(objpfx)tst-auditm
79cd021
 $(objpfx)tst-audit3.out: $(objpfx)tst-auditmod3b.so
79cd021
 tst-audit3-ENV = LD_AUDIT=$(objpfx)tst-auditmod3b.so
79cd021
 
79cd021
-$(objpfx)tst-audit4: $(objpfx)tst-auditmod4a.so
79cd021
+$(objpfx)tst-audit4: $(objpfx)tst-audit4-aux.o $(objpfx)tst-auditmod4a.so
79cd021
 $(objpfx)tst-audit4.out: $(objpfx)tst-auditmod4b.so
79cd021
 tst-audit4-ENV = LD_AUDIT=$(objpfx)tst-auditmod4b.so
79cd021
 
79cd021
@@ -66,7 +66,7 @@ $(objpfx)tst-audit7: $(objpfx)tst-auditm
79cd021
 $(objpfx)tst-audit7.out: $(objpfx)tst-auditmod7b.so
79cd021
 tst-audit7-ENV = LD_AUDIT=$(objpfx)tst-auditmod7b.so
79cd021
 
79cd021
-$(objpfx)tst-audit10: $(objpfx)tst-auditmod10a.so
79cd021
+$(objpfx)tst-audit10: $(objpfx)tst-audit10-aux.o $(objpfx)tst-auditmod10a.so
79cd021
 $(objpfx)tst-audit10.out: $(objpfx)tst-auditmod10b.so
79cd021
 tst-audit10-ENV = LD_AUDIT=$(objpfx)tst-auditmod10b.so
79cd021
 
79cd021
@@ -75,7 +75,7 @@ AVX-CFLAGS=-mavx
79cd021
 ifeq (yes,$(config-cflags-novzeroupper))
79cd021
 AVX-CFLAGS+=-mno-vzeroupper
79cd021
 endif
79cd021
-CFLAGS-tst-audit4.c += $(AVX-CFLAGS)
79cd021
+CFLAGS-tst-audit4-aux.c += $(AVX-CFLAGS)
79cd021
 CFLAGS-tst-auditmod4a.c += $(AVX-CFLAGS)
79cd021
 CFLAGS-tst-auditmod4b.c += $(AVX-CFLAGS)
79cd021
 CFLAGS-tst-auditmod6b.c += $(AVX-CFLAGS)
79cd021
@@ -84,7 +84,7 @@ CFLAGS-tst-auditmod7b.c += $(AVX-CFLAGS)
79cd021
 endif
79cd021
 ifeq (yes,$(config-cflags-avx512))
79cd021
 AVX512-CFLAGS = -mavx512f
79cd021
-CFLAGS-tst-audit10.c += $(AVX512-CFLAGS)
79cd021
+CFLAGS-tst-audit10-aux.c += $(AVX512-CFLAGS)
79cd021
 CFLAGS-tst-auditmod10a.c += $(AVX512-CFLAGS)
79cd021
 CFLAGS-tst-auditmod10b.c += $(AVX512-CFLAGS)
79cd021
 endif
79cd021
Index: b/sysdeps/x86_64/tst-audit10-aux.c
79cd021
===================================================================
79cd021
--- /dev/null
79cd021
+++ b/sysdeps/x86_64/tst-audit10-aux.c
79cd021
@@ -0,0 +1,41 @@
79cd021
+/* Test case for preserved AVX512 registers in dynamic linker, -mavx512f part.
79cd021
+   Copyright (C) 2012-2016 Free Software Foundation, Inc.
79cd021
+   This file is part of the GNU C Library.
79cd021
+
79cd021
+   The GNU C Library is free software; you can redistribute it and/or
79cd021
+   modify it under the terms of the GNU Lesser General Public
79cd021
+   License as published by the Free Software Foundation; either
79cd021
+   version 2.1 of the License, or (at your option) any later version.
79cd021
+
79cd021
+   The GNU C Library is distributed in the hope that it will be useful,
79cd021
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
79cd021
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
79cd021
+   Lesser General Public License for more details.
79cd021
+
79cd021
+   You should have received a copy of the GNU Lesser General Public
79cd021
+   License along with the GNU C Library; if not, see
79cd021
+   <http://www.gnu.org/licenses/>.  */
79cd021
+
79cd021
+#include <immintrin.h>
79cd021
+#include <stdlib.h>
79cd021
+#include <string.h>
79cd021
+
79cd021
+extern __m512i audit_test (__m512i, __m512i, __m512i, __m512i,
79cd021
+			   __m512i, __m512i, __m512i, __m512i);
79cd021
+
79cd021
+int
79cd021
+tst_audit10_aux (void)
79cd021
+{
79cd021
+#ifdef __AVX512F__
79cd021
+  __m512i zmm = _mm512_setzero_si512 ();
79cd021
+  __m512i ret = audit_test (zmm, zmm, zmm, zmm, zmm, zmm, zmm, zmm);
79cd021
+
79cd021
+  zmm = _mm512_set1_epi64 (0x12349876);
79cd021
+
79cd021
+  if (memcmp (&zmm, &ret, sizeof (ret)))
79cd021
+    abort ();
79cd021
+  return 0;
79cd021
+#else /* __AVX512F__ */
79cd021
+  return 77;
79cd021
+#endif /* __AVX512F__ */
79cd021
+}
79cd021
Index: b/sysdeps/x86_64/tst-audit10.c
79cd021
===================================================================
79cd021
--- a/sysdeps/x86_64/tst-audit10.c
79cd021
+++ b/sysdeps/x86_64/tst-audit10.c
79cd021
@@ -15,13 +15,9 @@
79cd021
    License along with the GNU C Library; if not, see
79cd021
    <http://www.gnu.org/licenses/>.  */
79cd021
 
79cd021
-/* Test case for x86-64 preserved registers in dynamic linker.  */
79cd021
-
79cd021
-#ifdef __AVX512F__
79cd021
-#include <stdlib.h>
79cd021
-#include <string.h>
79cd021
 #include <cpuid.h>
79cd021
-#include <immintrin.h>
79cd021
+
79cd021
+int tst_audit10_aux (void);
79cd021
 
79cd021
 static int
79cd021
 avx512_enabled (void)
79cd021
@@ -42,32 +38,15 @@ avx512_enabled (void)
79cd021
   return (eax & 0xe6) == 0xe6;
79cd021
 }
79cd021
 
79cd021
-
79cd021
-extern __m512i audit_test (__m512i, __m512i, __m512i, __m512i,
79cd021
-			   __m512i, __m512i, __m512i, __m512i);
79cd021
 static int
79cd021
 do_test (void)
79cd021
 {
79cd021
   /* Run AVX512 test only if AVX512 is supported.  */
79cd021
   if (avx512_enabled ())
79cd021
-    {
79cd021
-      __m512i zmm = _mm512_setzero_si512 ();
79cd021
-      __m512i ret = audit_test (zmm, zmm, zmm, zmm, zmm, zmm, zmm, zmm);
79cd021
-
79cd021
-      zmm = _mm512_set1_epi64 (0x12349876);
79cd021
-
79cd021
-      if (memcmp (&zmm, &ret, sizeof (ret)))
79cd021
-	abort ();
79cd021
-    }
79cd021
-  return 0;
79cd021
-}
79cd021
-#else
79cd021
-static int
79cd021
-do_test (void)
79cd021
-{
79cd021
-  return 0;
79cd021
+    return tst_audit10_aux ();
79cd021
+  else
79cd021
+    return 77;
79cd021
 }
79cd021
-#endif
79cd021
 
79cd021
 #define TEST_FUNCTION do_test ()
79cd021
 #include "../../test-skeleton.c"
79cd021
Index: b/sysdeps/x86_64/tst-audit4-aux.c
79cd021
===================================================================
79cd021
--- /dev/null
79cd021
+++ b/sysdeps/x86_64/tst-audit4-aux.c
79cd021
@@ -0,0 +1,39 @@
79cd021
+/* Test case for preserved AVX registers in dynamic linker, -mavx part.
79cd021
+   Copyright (C) 2009-2016 Free Software Foundation, Inc.
79cd021
+   This file is part of the GNU C Library.
79cd021
+
79cd021
+   The GNU C Library is free software; you can redistribute it and/or
79cd021
+   modify it under the terms of the GNU Lesser General Public
79cd021
+   License as published by the Free Software Foundation; either
79cd021
+   version 2.1 of the License, or (at your option) any later version.
79cd021
+
79cd021
+   The GNU C Library is distributed in the hope that it will be useful,
79cd021
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
79cd021
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
79cd021
+   Lesser General Public License for more details.
79cd021
+
79cd021
+   You should have received a copy of the GNU Lesser General Public
79cd021
+   License along with the GNU C Library; if not, see
79cd021
+   <http://www.gnu.org/licenses/>.  */
79cd021
+
79cd021
+#include <immintrin.h>
79cd021
+#include <stdlib.h>
79cd021
+#include <string.h>
79cd021
+
79cd021
+extern __m256i audit_test (__m256i, __m256i, __m256i, __m256i,
79cd021
+			   __m256i, __m256i, __m256i, __m256i);
79cd021
+
79cd021
+int
79cd021
+tst_audit4_aux (void)
79cd021
+{
79cd021
+#ifdef __AVX__
79cd021
+  __m256i ymm = _mm256_setzero_si256 ();
79cd021
+  __m256i ret = audit_test (ymm, ymm, ymm, ymm, ymm, ymm, ymm, ymm);
79cd021
+  ymm =	 _mm256_set1_epi32 (0x12349876);
79cd021
+  if (memcmp (&ymm, &ret, sizeof (ret)))
79cd021
+    abort ();
79cd021
+  return 0;
79cd021
+#else  /* __AVX__ */
79cd021
+  return 77;
79cd021
+#endif  /* __AVX__ */
79cd021
+}
79cd021
Index: b/sysdeps/x86_64/tst-audit4.c
79cd021
===================================================================
79cd021
--- a/sysdeps/x86_64/tst-audit4.c
79cd021
+++ b/sysdeps/x86_64/tst-audit4.c
79cd021
@@ -1,11 +1,24 @@
79cd021
-/* Test case for x86-64 preserved registers in dynamic linker.  */
79cd021
+/* Test case for preserved AVX registers in dynamic linker.
79cd021
+   Copyright (C) 2009-2016 Free Software Foundation, Inc.
79cd021
+   This file is part of the GNU C Library.
79cd021
+
79cd021
+   The GNU C Library is free software; you can redistribute it and/or
79cd021
+   modify it under the terms of the GNU Lesser General Public
79cd021
+   License as published by the Free Software Foundation; either
79cd021
+   version 2.1 of the License, or (at your option) any later version.
79cd021
+
79cd021
+   The GNU C Library is distributed in the hope that it will be useful,
79cd021
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
79cd021
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
79cd021
+   Lesser General Public License for more details.
79cd021
+
79cd021
+   You should have received a copy of the GNU Lesser General Public
79cd021
+   License along with the GNU C Library; if not, see
79cd021
+   <http://www.gnu.org/licenses/>.  */
79cd021
 
79cd021
-#ifdef __AVX__
79cd021
-#include <stdlib.h>
79cd021
-#include <string.h>
79cd021
 #include <cpuid.h>
79cd021
-#include <immintrin.h>
79cd021
 
79cd021
+int tst_audit4_aux (void);
79cd021
 
79cd021
 static int
79cd021
 avx_enabled (void)
79cd021
@@ -22,31 +35,15 @@ avx_enabled (void)
79cd021
   return (eax & 6) == 6;
79cd021
 }
79cd021
 
79cd021
-
79cd021
-extern __m256i audit_test (__m256i, __m256i, __m256i, __m256i,
79cd021
-			   __m256i, __m256i, __m256i, __m256i);
79cd021
 static int
79cd021
 do_test (void)
79cd021
 {
79cd021
   /* Run AVX test only if AVX is supported.  */
79cd021
   if (avx_enabled ())
79cd021
-    {
79cd021
-      __m256i ymm = _mm256_setzero_si256 ();
79cd021
-      __m256i ret = audit_test (ymm, ymm, ymm, ymm, ymm, ymm, ymm, ymm);
79cd021
-
79cd021
-      ymm =  _mm256_set1_epi32 (0x12349876);
79cd021
-      if (memcmp (&ymm, &ret, sizeof (ret)))
79cd021
-	abort ();
79cd021
-    }
79cd021
-  return 0;
79cd021
-}
79cd021
-#else
79cd021
-static int
79cd021
-do_test (void)
79cd021
-{
79cd021
-  return 0;
79cd021
+    return tst_audit4_aux ();
79cd021
+  else
79cd021
+    return 77;
79cd021
 }
79cd021
-#endif
79cd021
 
79cd021
 #define TEST_FUNCTION do_test ()
79cd021
 #include "../../test-skeleton.c"