Hello!
Attached patch fixes PR87928, where we ICE in ix86_compute_frame_layout in
gcc_assert (preferred_alignment >= STACK_BOUNDARY / BITS_PER_UNIT);
when __attribute__ ((sysv_abi) is used. When the testcase is compiled,
ix86_cfun_abi () returns SYSV_ABI due to function __attribute__
override, while ix86_abi returns MS_ABI. These ABIs have different
STACK_BOUNDARY definition, so we compare preferred_alignment with
wrong STACK boundary definition.
Attached patch makes STACK_BOUNDARY dependant on function ABI attribute.
2018-11-09 Uros Bizjak <[email protected]>
PR target/87928
* config/i386/i386.h (STACK_BOUNDARY): Use TARGET_64BIT_MS_ABI
instead of (TARGET_64BIT && ix86_abi == MS_ABI).
* config/i386/darwin.h (STACK_BOUNDARY): Ditto.
* config/i386/cygming.h (STACK_BOUNDARY): Remove.
testsuite /Changelog:
2018-11-09 Uros Bizjak <[email protected]>
PR target/87928
* gcc.target/i386/pr87928.c: New test.
Bootstrapped and regression tested on x86_64-linux-gnu {,-m32}.
I will commit the patch to mainline SVN early next week to allow
Darwin and Ming/Cygwin maintainers some time to test the patch on
their targets.
Uros.
Index: config/i386/cygming.h
===================================================================
--- config/i386/cygming.h (revision 265930)
+++ config/i386/cygming.h (working copy)
@@ -268,9 +268,6 @@
bytes in one go. */
#define CHECK_STACK_LIMIT 4000
-#undef STACK_BOUNDARY
-#define STACK_BOUNDARY (TARGET_64BIT && ix86_abi == MS_ABI ? 128 :
BITS_PER_WORD)
-
/* By default, target has a 80387, uses IEEE compatible arithmetic,
returns float values in the 387 and needs stack probes.
We also align doubles to 64-bits for MSVC default compatibility. */
Index: config/i386/darwin.h
===================================================================
--- config/i386/darwin.h (revision 265930)
+++ config/i386/darwin.h (working copy)
@@ -113,8 +113,7 @@
or dynamic loader. */
#undef STACK_BOUNDARY
#define STACK_BOUNDARY \
- ((profile_flag || (TARGET_64BIT && ix86_abi == MS_ABI)) \
- ? 128 : BITS_PER_WORD)
+ ((profile_flag || TARGET_64BIT_MS_ABI) ? 128 : BITS_PER_WORD)
#undef MAIN_STACK_BOUNDARY
#define MAIN_STACK_BOUNDARY 128
Index: config/i386/i386.h
===================================================================
--- config/i386/i386.h (revision 265930)
+++ config/i386/i386.h (working copy)
@@ -807,8 +807,7 @@
#define PARM_BOUNDARY BITS_PER_WORD
/* Boundary (in *bits*) on which stack pointer should be aligned. */
-#define STACK_BOUNDARY \
- (TARGET_64BIT && ix86_abi == MS_ABI ? 128 : BITS_PER_WORD)
+#define STACK_BOUNDARY (TARGET_64BIT_MS_ABI ? 128 : BITS_PER_WORD)
/* Stack boundary of the main function guaranteed by OS. */
#define MAIN_STACK_BOUNDARY (TARGET_64BIT ? 128 : 32)
Index: testsuite/gcc.target/i386/pr87928.c
===================================================================
--- testsuite/gcc.target/i386/pr87928.c (nonexistent)
+++ testsuite/gcc.target/i386/pr87928.c (working copy)
@@ -0,0 +1,23 @@
+/* { dg-do compile { target lp64 } } */
+/* { dg-options "-O1 -mstackrealign -mabi=ms" } */
+
+struct foo
+{
+ int a;
+ int b;
+ int c;
+ int d;
+};
+
+__attribute__ ((sysv_abi))
+struct foo bar (void)
+{
+ struct foo retval;
+
+ retval.a = 1;
+ retval.b = 2;
+ retval.c = 3;
+ retval.d = 4;
+
+ return retval;
+}