From patchwork Tue Sep 7 11:16:41 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jack Howarth X-Patchwork-Id: 63989 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 0C0D8B6F0D for ; Tue, 7 Sep 2010 21:16:55 +1000 (EST) Received: (qmail 13392 invoked by alias); 7 Sep 2010 11:16:53 -0000 Received: (qmail 13353 invoked by uid 22791); 7 Sep 2010 11:16:51 -0000 X-SWARE-Spam-Status: No, hits=-0.5 required=5.0 tests=AWL, BAYES_50, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from bromo.med.uc.edu (HELO bromo.med.uc.edu) (129.137.3.146) by sourceware.org (qpsmtpd/0.43rc1) with SMTP; Tue, 07 Sep 2010 11:16:44 +0000 Received: from bromo.med.uc.edu (localhost.localdomain [127.0.0.1]) by bromo.med.uc.edu (Postfix) with ESMTP id 32CC5B005C; Tue, 7 Sep 2010 07:16:42 -0400 (EDT) Received: (from howarth@localhost) by bromo.med.uc.edu (8.14.3/8.14.3/Submit) id o87BGf8j022818; Tue, 7 Sep 2010 07:16:41 -0400 Date: Tue, 7 Sep 2010 07:16:41 -0400 From: Jack Howarth To: gcc-patches@gcc.gnu.org Cc: hjl.tools@gmail.com, mikestump@comcast.net, iains@gcc.gnu.org, ebotcazou@adacore.com Subject: [PATCH][Revisedx3] Fix PR36502, PR42313 and PR44651 Message-ID: <20100907111641.GA22816@bromo.med.uc.edu> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.18 (2008-05-17) Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org 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 Jack Howarth 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. 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__)