[Pixman] [PATCH 2/2] configure.ac: For SSE2 and SSSE3 require GCC 4.4 and then use -mstackrealign

Søren Sandmann sandmann at cs.au.dk
Wed Oct 2 17:33:37 PDT 2013


From: Søren Sandmann Pedersen <ssp at redhat.com>

Code compiled by GCC with -msse2 and -mssse3 assumes a 16 byte aligned
stack, but on x86-32 such alignment is not guaranteed.

Instead of using the __force_align_arg_pointer__ attribute on all
entry points that could potentially call into code compiled with
-msse2 or -mssse3, just compile pixman-sse2.c and pixman-ssse3.c with
-mstackrealign.

This fixes the glyph-test crash introduced by the previous commit and
also

     https://bugs.freedesktop.org/show_bug.cgi?id=68300
---
 configure.ac         | 13 +++++++------
 pixman/pixman-sse2.c |  6 ------
 pixman/pixman.c      | 19 -------------------
 3 files changed, 7 insertions(+), 31 deletions(-)

diff --git a/configure.ac b/configure.ac
index 2dd4776..ab38f5a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -391,7 +391,7 @@ if test "x$SSE2_CFLAGS" = "x" ; then
          SSE2_CFLAGS="-xarch=sse2"
       fi
    else
-      SSE2_CFLAGS="-msse2 -Winline"
+      SSE2_CFLAGS="-mstackrealign -msse2 -Winline"
    fi
 fi
 
@@ -401,10 +401,8 @@ xserver_save_CFLAGS=$CFLAGS
 CFLAGS="$SSE2_CFLAGS $CFLAGS"
 
 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
-#if defined(__GNUC__) && (__GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 2))
-#   if !defined(__amd64__) && !defined(__x86_64__)
-#      error "Need GCC >= 4.2 for SSE2 intrinsics on x86"
-#   endif
+#if defined(__GNUC__) && (__GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 4))
+#  error "Need GCC >= 4.4 for SSE2 intrinsics on x86"
 #endif
 #include <mmintrin.h>
 #include <xmmintrin.h>
@@ -440,7 +438,7 @@ dnl ===========================================================================
 dnl Check for SSSE3
 
 if test "x$SSSE3_CFLAGS" = "x" ; then
-    SSSE3_CFLAGS="-mssse3 -Winline"
+    SSSE3_CFLAGS="-mstackrealign -mssse3 -Winline"
 fi
 
 have_ssse3_intrinsics=no
@@ -449,6 +447,9 @@ xserver_save_CFLAGS=$CFLAGS
 CFLAGS="$SSSE3_CFLAGS $CFLAGS"
 
 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
+#if defined(__GNUC__) && (__GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 4))
+#  error "Need GCC >= 4.4 for SSSE3 intrinsics on x86"
+#endif
 #include <mmintrin.h>
 #include <xmmintrin.h>
 #include <emmintrin.h>
diff --git a/pixman/pixman-sse2.c b/pixman/pixman-sse2.c
index 42c7209..47e8f75 100644
--- a/pixman/pixman-sse2.c
+++ b/pixman/pixman-sse2.c
@@ -3312,9 +3312,6 @@ sse2_composite_over_n_8_8888 (pixman_implementation_t *imp,
 
 }
 
-#if defined(__GNUC__) && !defined(__x86_64__) && !defined(__amd64__)
-__attribute__((__force_align_arg_pointer__))
-#endif
 static pixman_bool_t
 sse2_fill (pixman_implementation_t *imp,
            uint32_t *               bits,
@@ -6411,9 +6408,6 @@ static const pixman_iter_info_t sse2_iters[] =
     { PIXMAN_null },
 };
 
-#if defined(__GNUC__) && !defined(__x86_64__) && !defined(__amd64__)
-__attribute__((__force_align_arg_pointer__))
-#endif
 pixman_implementation_t *
 _pixman_implementation_create_sse2 (pixman_implementation_t *fallback)
 {
diff --git a/pixman/pixman.c b/pixman/pixman.c
index 9555cea..5490e59 100644
--- a/pixman/pixman.c
+++ b/pixman/pixman.c
@@ -547,25 +547,6 @@ analyze_extent (pixman_image_t       *image,
     return TRUE;
 }
 
-/*
- * Work around GCC bug causing crashes in Mozilla with SSE2
- *
- * When using -msse, gcc generates movdqa instructions assuming that
- * the stack is 16 byte aligned. Unfortunately some applications, such
- * as Mozilla and Mono, end up aligning the stack to 4 bytes, which
- * causes the movdqa instructions to fail.
- *
- * The __force_align_arg_pointer__ makes gcc generate a prologue that
- * realigns the stack pointer to 16 bytes.
- *
- * On x86-64 this is not necessary because the standard ABI already
- * calls for a 16 byte aligned stack.
- *
- * See https://bugs.freedesktop.org/show_bug.cgi?id=15693
- */
-#if defined (USE_SSE2) && defined(__GNUC__) && !defined(__x86_64__) && !defined(__amd64__)
-__attribute__((__force_align_arg_pointer__))
-#endif
 PIXMAN_EXPORT void
 pixman_image_composite32 (pixman_op_t      op,
                           pixman_image_t * src,
-- 
1.7.11.7



More information about the Pixman mailing list