Patchwork [Revisedx3] Fix PR36502, PR42313 and PR44651

login
register
mail settings
Submitter Jack Howarth
Date Sept. 7, 2010, 11:16 a.m.
Message ID <20100907111641.GA22816@bromo.med.uc.edu>
Download mbox | patch
Permalink /patch/63989/
State New
Headers show

Comments

Jack Howarth - Sept. 7, 2010, 11:16 a.m.
This is the final version of the stack boundary realignment patch for i386/x86_64 darwin.
The previous version erroneously omitted an essential redefinition of MAIN_STACK_BOUNDARY
from gcc/config/i386/darwin.h. That change has been eliminated in this version of the patch.
  The attached patch solves PR36502, PR42313, and PR44651 eliminating the unnecessary stack 
operations, by defining STACK_BOUNDARY to BITS_PER_WORD except for profiling or the use of 
the MS_ABI at 64-bit and by replacing STACK_BOUNDARY with 128 in the MAX macro defining
PREFERRED_STACK_BOUNDARY. These changes allow the gcc.target/i386/builtin-unreachable
and gcc.target/x86_64/abi/callabi/leaf-[1,2].c test cases to pass on darwin. The enabling
of stack realignments also eliminates the need for special adjustment for SIZE in the
gcc.dg/stack-usage-1.c test case. Finally a new test case for PR36502 of of unnecessary 
stack operations, gcc.target/i386/pr36502.c, is added.

Bootstrap and regression tested on i386-apple-darwin10 and x86_64-apple-darwin10 in conjunction 
with the proposed fix for PR45234 (http://gcc.gnu.org/ml/gcc-patches/2010-08/msg01916.html).

http://gcc.gnu.org/ml/gcc-testresults/2010-09/msg00603.html
http://gcc.gnu.org/ml/gcc-testresults/2010-09/msg00620.html

                    Okay for gcc trunk?
                                     Jack

2010-09-06  H.J. Lu  <hjl.tools@gmail.com>
            Jack Howarth <howarth@bromo.med.uc.edu>

	PR 36502/target
	PR 42313/target
	PR 44651/target

	* gcc/config/i386/darwin.h (STACK_BOUNDARY): Redefine as 128 for profiling
	or 64-bit MS_ABI and as BITS_PER_WORD otherwise.
	(PREFERRED_STACK_BOUNDARY): Replace STACK_BOUNDARY with 128 in MAX macro.
	* gcc.target/i386/pr36502.c: New test.
	* gcc.target/i386/builtin-unreachable.c: Don't skip on darwin.
	* gcc/testsuite/gcc.dg/stack-usage-1.c: Use default on i386/Darwin.
Richard Henderson - Sept. 7, 2010, 5:59 p.m.
On 09/07/2010 04:16 AM, Jack Howarth wrote:
> 	PR 36502/target
> 	PR 42313/target
> 	PR 44651/target
> 
> 	* gcc/config/i386/darwin.h (STACK_BOUNDARY): Redefine as 128 for profiling
> 	or 64-bit MS_ABI and as BITS_PER_WORD otherwise.
> 	(PREFERRED_STACK_BOUNDARY): Replace STACK_BOUNDARY with 128 in MAX macro.
> 	* gcc.target/i386/pr36502.c: New test.
> 	* gcc.target/i386/builtin-unreachable.c: Don't skip on darwin.
> 	* gcc/testsuite/gcc.dg/stack-usage-1.c: Use default on i386/Darwin.

Ok.


r~
Eric Botcazou - Sept. 7, 2010, 6:02 p.m.
> 2010-09-06  H.J. Lu  <hjl.tools@gmail.com>
>             Jack Howarth <howarth@bromo.med.uc.edu>
>
> 	PR 36502/target
> 	PR 42313/target
> 	PR 44651/target
>
> 	* gcc/config/i386/darwin.h (STACK_BOUNDARY): Redefine as 128 for profiling
> 	or 64-bit MS_ABI and as BITS_PER_WORD otherwise.
> 	(PREFERRED_STACK_BOUNDARY): Replace STACK_BOUNDARY with 128 in MAX macro.
> 	* gcc.target/i386/pr36502.c: New test.
> 	* gcc.target/i386/builtin-unreachable.c: Don't skip on darwin.
> 	* gcc/testsuite/gcc.dg/stack-usage-1.c: Use default on i386/Darwin.

Correct ChangeLog is

2010-09-06  H.J. Lu  <hjl.tools@gmail.com>
            Jack Howarth <howarth@bromo.med.uc.edu>

	PR 36502/target
	PR 42313/target
	PR 44651/target
	* config/i386/darwin.h (STACK_BOUNDARY): Redefine as 128 for profiling
	or 64-bit MS_ABI and as BITS_PER_WORD otherwise.
	(PREFERRED_STACK_BOUNDARY): Replace STACK_BOUNDARY with 128 in MAX macro.


2010-09-06  H.J. Lu  <hjl.tools@gmail.com>
            Jack Howarth <howarth@bromo.med.uc.edu>

	* gcc.target/i386/pr36502.c: New test.
	* gcc.target/i386/builtin-unreachable.c: Don't skip on darwin.
	* gcc.dg/stack-usage-1.c: Use default on i386/Darwin.

Patch

Index: gcc/testsuite/gcc.target/i386/builtin-unreachable.c
===================================================================
--- gcc/testsuite/gcc.target/i386/builtin-unreachable.c	(revision 163892)
+++ gcc/testsuite/gcc.target/i386/builtin-unreachable.c	(working copy)
@@ -9,5 +9,5 @@ 
     __builtin_unreachable ();
   return p ? 1 : 0;
 }
-/* { dg-final { scan-assembler-not "%e\[bs\]p" { target { ! *-*-darwin* } } } } */
+/* { dg-final { scan-assembler-not "%e\[bs\]p" } } */
 /* { dg-final { scan-assembler-not "\[\\t \]+j" } } */
Index: gcc/config/i386/darwin.h
===================================================================
--- gcc/config/i386/darwin.h	(revision 163892)
+++ gcc/config/i386/darwin.h	(working copy)
@@ -79,7 +79,9 @@ 
    Failure to ensure this will lead to a crash in the system libraries
    or dynamic loader.  */
 #undef STACK_BOUNDARY
-#define STACK_BOUNDARY 128
+#define STACK_BOUNDARY \
+ ((profile_flag || (TARGET_64BIT && ix86_abi == MS_ABI)) \
+  ? 128 : BITS_PER_WORD)
 
 #undef MAIN_STACK_BOUNDARY
 #define MAIN_STACK_BOUNDARY 128
@@ -91,7 +93,7 @@ 
    it's below the minimum.  */
 #undef PREFERRED_STACK_BOUNDARY
 #define PREFERRED_STACK_BOUNDARY			\
-  MAX (STACK_BOUNDARY, ix86_preferred_stack_boundary)
+  MAX (128, ix86_preferred_stack_boundary)
 
 /* We want -fPIC by default, unless we're using -static to compile for
    the kernel or some such.  */
--- /dev/null	2010-09-01 11:08:32.000000000 -0400
+++ gcc/testsuite/gcc.target/i386/pr36502.c	2010-09-01 11:23:10.000000000 -0400
@@ -0,0 +1,7 @@ 
+/* PR target/36502 */
+/* { dg-do compile { target { *-*-darwin* && ilp32 } } } */
+/* { dg-options "-O -fomit-frame-pointer -fno-pic -S" } */
+int a;
+void f() {a++;}
+/* { dg-final { scan-assembler-not "esp" } } */
+
Index: gcc/testsuite/gcc.dg/stack-usage-1.c
===================================================================
--- gcc/testsuite/gcc.dg/stack-usage-1.c	(revision 163768)
+++ gcc/testsuite/gcc.dg/stack-usage-1.c	(working copy)
@@ -8,11 +8,7 @@ 
    Then check that this is the actual stack usage in the assembly file.  */
 
 #if defined(__i386__)
-#  if defined (__MACH__)
-#    define SIZE 232
-#  else
-#    define SIZE 248
-#  endif
+#  define SIZE 248
 #elif defined(__x86_64__)
 #  define SIZE 356
 #elif defined (__sparc__)