There have been several PRs that all boil down to the fact that SSE
insns segfault since one of their operands isn't sufficiently aligned.
Initially, it seemed that only Solaris 9/x86 wass affected, and the issue
was fixed on the 4.9 branch (the last supported on Solaris 9) by
enabling -mstackrealign by default:

        Only assume 4-byte stack alignment on Solaris 9/x86 (PR libgomp/60107)
        http://gcc.gnu.org/ml/gcc-patches/2014-02/msg00662.html

Now PRs target/61949 and target/62281 show the same issue on 32-bit
Solaris 10/x86, and I've received confirmation that Solaris indeed only
guarantees 4-byte stack alignment as required by the i386 psABI.  Given
that, the following patch generalizes the patch above.

Bootstrapped without regressions on i386-pc-solaris2.1[012].  I'm
applying it to mainline now, although I don't yet understand why the
testcases only fail on Solaris 10.  Given that this is a wrong-code bug,
I'm going to apply it to the gcc-5 and gcc-4.9 branches within a week.

        Rainer


2016-02-29  Rainer Orth  <r...@cebitec.uni-bielefeld.de>

        PR target/62281
        * config/i386/sol2.h (STACK_REALIGN_DEFAULT): Define.

# HG changeset patch
# Parent  fe2aecc6db984d0da6866189364e4fa9c5021495
Only assume 4-byte stack alignment on Solaris/x86 (PR target/62281)

diff --git a/gcc/config/i386/sol2.h b/gcc/config/i386/sol2.h
--- a/gcc/config/i386/sol2.h
+++ b/gcc/config/i386/sol2.h
@@ -21,6 +21,11 @@ along with GCC; see the file COPYING3.  
 #define SUBTARGET_OPTIMIZATION_OPTIONS				\
   { OPT_LEVELS_1_PLUS, OPT_momit_leaf_frame_pointer, NULL, 1 }
 
+/* 32-bit Solaris/x86 only guarantees 4-byte stack alignment as required by
+   the i386 psABI, so realign it as necessary for SSE instructions.  */
+#undef STACK_REALIGN_DEFAULT
+#define STACK_REALIGN_DEFAULT (TARGET_64BIT ? 0 : 1)
+
 /* Old versions of the Solaris assembler can not handle the difference of
    labels in different sections, so force DW_EH_PE_datarel if so.  */
 #ifndef HAVE_AS_IX86_DIFF_SECT_DELTA
2016-02-29  Rainer Orth  <r...@cebitec.uni-bielefeld.de>

        Backport from mainline
        PR target/62281
        * config/i386/sol2.h (STACK_REALIGN_DEFAULT): Define.

        Revert:
        2014-02-11  Rainer Orth  <r...@cebitec.uni-bielefeld.de>

        PR libgomp/60107
        * config/i386/sol2-9.h: New file.
        * config.gcc (i[34567]86-*-solaris2* | x86_64-*-solaris2.1[0-9]*,
        *-*-solaris2.9*): Use it.

# HG changeset patch
# Parent  20345b38cd619b11e097531603ee5eb0d7f56835
Only assume 4-byte stack alignment on Solaris/x86 (PR target/62281)

diff --git a/gcc/config.gcc b/gcc/config.gcc
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -1542,9 +1542,6 @@ i[34567]86-*-solaris2* | x86_64-*-solari
 	esac
 	with_tune_32=${with_tune_32:-generic}
 	case ${target} in
-	*-*-solaris2.9*)
-		tm_file="${tm_file} i386/sol2-9.h"
-		;;
 	*-*-solaris2.1[0-9]*)
 		tm_file="${tm_file} i386/x86-64.h i386/sol2-bi.h sol2-bi.h"
 		tm_defines="${tm_defines} TARGET_BI_ARCH=1"
diff --git a/gcc/config/i386/sol2-9.h b/gcc/config/i386/sol2-9.h
deleted file mode 100644
--- a/gcc/config/i386/sol2-9.h
+++ /dev/null
@@ -1,23 +0,0 @@
-/* Target definitions for GCC for Intel 80386 running Solaris 9
-   Copyright (C) 2014 Free Software Foundation, Inc.
-
-This file is part of GCC.
-
-GCC is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 3, or (at your option)
-any later version.
-
-GCC is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GCC; see the file COPYING3.  If not see
-<http://www.gnu.org/licenses/>.  */
-
-/* Solaris 9 only guarantees 4-byte stack alignment as required by the i386
-   psABI, so realign it as necessary for SSE instructions.  */
-#undef STACK_REALIGN_DEFAULT
-#define STACK_REALIGN_DEFAULT 1
diff --git a/gcc/config/i386/sol2.h b/gcc/config/i386/sol2.h
--- a/gcc/config/i386/sol2.h
+++ b/gcc/config/i386/sol2.h
@@ -25,6 +25,11 @@ along with GCC; see the file COPYING3.  
 #define TARGET_SUBTARGET_DEFAULT \
 	(MASK_80387 | MASK_IEEE_FP | MASK_FLOAT_RETURNS | MASK_VECT8_RETURNS)
 
+/* 32-bit Solaris/x86 only guarantees 4-byte stack alignment as required by
+   the i386 psABI, so realign it as necessary for SSE instructions.  */
+#undef STACK_REALIGN_DEFAULT
+#define STACK_REALIGN_DEFAULT (TARGET_64BIT ? 0 : 1)
+
 /* Old versions of the Solaris assembler can not handle the difference of
    labels in different sections, so force DW_EH_PE_datarel.  */
 #undef ASM_PREFERRED_EH_DATA_FORMAT
-- 
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University

Reply via email to