Patchwork Fix PR36502

login
register
mail settings
Submitter Jack Howarth
Date Sept. 2, 2010, 9:07 p.m.
Message ID <20100902210738.GA29668@bromo.med.uc.edu>
Download mbox | patch
Permalink /patch/63552/
State New
Headers show

Comments

Jack Howarth - Sept. 2, 2010, 9:07 p.m.
The attached patch solves PR36502, 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. A new
testcase, gcc.target/i386/pr36502.c, to test for the unnecessary stack operations is added as well.
Bootstrap and regression tested on 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/msg00168.html

Okay for gcc trunk?
         Jack


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

        PR 36502/target

        * gcc/config/i386/darwin.h: Redefine STACK_BOUNDARY 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.

Patch

Index: gcc/config/i386/darwin.h
===================================================================
--- gcc/config/i386/darwin.h	(revision 163748)
+++ 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" } } */
+