From patchwork Fri May 25 13:53:25 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 161357 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 5565FB6F9A for ; Fri, 25 May 2012 23:54:00 +1000 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1338558840; h=Comment: DomainKey-Signature:Received:Received:Received:Received: MIME-Version:Received:Received:In-Reply-To:References:Date: Message-ID:Subject:From:To:Cc:Content-Type: Content-Transfer-Encoding:Mailing-List:Precedence:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:Sender: Delivered-To; bh=MKEX+USPhOqMyB4A3M9TFoE8E2Q=; b=S9sqIFTHQh1nt/D +mUKaM3wllHdAExT3gApviuByFPrQyHse9Eg191FQzhsQO73+wvA/pwlWByaBtv2 5gJmVDMvDqeoc6ALpXRgJ78AjcQolaAMHG5dk8kbEnVbSuJs1PY8N/wNuiTiK9Xq kY8mfDLVh2OaL5jUarlu5ibsAtkg= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:MIME-Version:Received:Received:In-Reply-To:References:Date:Message-ID:Subject:From:To:Cc:Content-Type:Content-Transfer-Encoding:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=pY+Jh43wayY1iH3sHHhAyoR1W0SQQbrxHt/Pa8ECo68CmRCJ6d8+lxxreqIsEg Jg7Jx7GpFIJjyKdpDFZGh2OCC8O534UNEVJHXjrrLFhnlN133QIGkZyx/23Wy90H Y4OvKZ8+Bl1jCZH9XgNjXsGBmOyGPAntafKtNsQJsJzck=; Received: (qmail 32632 invoked by alias); 25 May 2012 13:53:40 -0000 Received: (qmail 32618 invoked by uid 22791); 25 May 2012 13:53:38 -0000 X-SWARE-Spam-Status: No, hits=-5.0 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, KHOP_RCVD_TRUST, KHOP_THREADED, RCVD_IN_DNSWL_LOW, RCVD_IN_HOSTKARMA_YE X-Spam-Check-By: sourceware.org Received: from mail-qa0-f47.google.com (HELO mail-qa0-f47.google.com) (209.85.216.47) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 25 May 2012 13:53:26 +0000 Received: by qabg1 with SMTP id g1so5037523qab.20 for ; Fri, 25 May 2012 06:53:25 -0700 (PDT) MIME-Version: 1.0 Received: by 10.224.185.204 with SMTP id cp12mr15203952qab.42.1337954005374; Fri, 25 May 2012 06:53:25 -0700 (PDT) Received: by 10.229.169.130 with HTTP; Fri, 25 May 2012 06:53:25 -0700 (PDT) In-Reply-To: <20120520144738.GA2225@intel.com> References: <20120520144738.GA2225@intel.com> Date: Fri, 25 May 2012 06:53:25 -0700 Message-ID: Subject: Re: PATCH: PR target/53383: Allow -mpreferred-stack-boundary=3 on x86-64 From: "H.J. Lu" To: Jakub Jelinek , Richard Henderson , "H. Peter Anvin" Cc: gcc-patches@gcc.gnu.org X-IsSubscribed: yes 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 On Sun, May 20, 2012 at 7:47 AM, H.J. Lu wrote: > Hi, > > This patch allows -mpreferred-stack-boundary=3 on x86-64 when SSE is > disabled.  Since this option changes ABI, I also added a warning for > -mpreferred-stack-boundary=3.  OK for trunk? > > Thanks. > > > H.J. > ---- >        PR target/53383 >        * doc/invoke.texi: Add a warning for -mpreferred-stack-boundary=3. > >        * config/i386/i386.c (ix86_option_override_internal): Allow >        -mpreferred-stack-boundary=3 for 64-bit if SSE is disenabled. > >        * config/i386/i386.h (MIN_STACK_BOUNDARY): Set to 64 for 64-bit >        if SSE is disenabled. > > diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c > index eca542c..338d387 100644 > --- a/gcc/config/i386/i386.c > +++ b/gcc/config/i386/i386.c > @@ -3660,7 +3660,7 @@ ix86_option_override_internal (bool main_args_p) >   ix86_preferred_stack_boundary = PREFERRED_STACK_BOUNDARY_DEFAULT; >   if (global_options_set.x_ix86_preferred_stack_boundary_arg) >     { > -      int min = (TARGET_64BIT ? 4 : 2); > +      int min = (TARGET_64BIT ? (TARGET_SSE ? 4 : 3) : 2); >       int max = (TARGET_SEH ? 4 : 12); > >       if (ix86_preferred_stack_boundary_arg < min > diff --git a/gcc/config/i386/i386.h b/gcc/config/i386/i386.h > index ddb3645..f7f13d2 100644 > --- a/gcc/config/i386/i386.h > +++ b/gcc/config/i386/i386.h > @@ -708,7 +708,7 @@ enum target_cpu_default >  #define MAIN_STACK_BOUNDARY (TARGET_64BIT ? 128 : 32) > >  /* Minimum stack boundary.  */ > -#define MIN_STACK_BOUNDARY (TARGET_64BIT ? 128 : 32) > +#define MIN_STACK_BOUNDARY (TARGET_64BIT ? (TARGET_SSE ? 128 : 64) : 32) > >  /* Boundary (in *bits*) on which the stack pointer prefers to be >    aligned; the compiler cannot rely on having this alignment.  */ > diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi > index 4c5c79f..daa1f3a 100644 > --- a/gcc/doc/invoke.texi > +++ b/gcc/doc/invoke.texi > @@ -13521,6 +13521,12 @@ Attempt to keep the stack boundary aligned to a 2 raised to @var{num} >  byte boundary.  If @option{-mpreferred-stack-boundary} is not specified, >  the default is 4 (16 bytes or 128 bits). > > +@strong{Warning:} When generating code for the x86-64 architecture with > +SSE extensions disabled, @option{-mpreferred-stack-boundary=3} can be > +used to keep the stack boundary aligned to 8 byte boundary.  You must > +build all modules with @option{-mpreferred-stack-boundary=3}, including > +any libraries.  This includes the system libraries and startup modules. > + >  @item -mincoming-stack-boundary=@var{num} >  @opindex mincoming-stack-boundary >  Assume the incoming stack is aligned to a 2 raised to @var{num} byte I applied the above patch to GCC 4.7 and the following patch to Linux kernel 3.4.0. Kernel boots and runs correctly. Is the patch OK for trunk? Thanks. diff --git a/arch/x86/Makefile b/arch/x86/Makefile index 94e91e4..cd4a4f7 100644 --- a/arch/x86/Makefile +++ b/arch/x86/Makefile @@ -49,6 +49,9 @@ else KBUILD_AFLAGS += -m64 KBUILD_CFLAGS += -m64 + # Use -mpreferred-stack-boundary=3 if supported. + KBUILD_CFLAGS += $(call cc-option,-mno-sse -mpreferred-stack-boundary=3) + # FIXME - should be integrated in Makefile.cpu (Makefile_32.cpu) cflags-$(CONFIG_MK8) += $(call cc-option,-march=k8) cflags-$(CONFIG_MPSC) += $(call cc-option,-march=nocona)