From owner-freebsd-current Wed Jun 5 22:40:32 2002 Delivered-To: freebsd-current@freebsd.org Received: from mailman.zeta.org.au (mailman.zeta.org.au [203.26.10.16]) by hub.freebsd.org (Postfix) with ESMTP id 08B3837B400; Wed, 5 Jun 2002 22:40:20 -0700 (PDT) Received: from bde.zeta.org.au (bde.zeta.org.au [203.2.228.102]) by mailman.zeta.org.au (8.9.3/8.8.7) with ESMTP id PAA13016; Thu, 6 Jun 2002 15:39:49 +1000 Date: Thu, 6 Jun 2002 15:40:23 +1000 (EST) From: Bruce Evans X-X-Sender: bde@gamplex.bde.org To: Matthew Dillon Cc: current@FreeBSD.ORG, Subject: Re: fixes for gcc -falign-foo In-Reply-To: <200206060428.g564SY1c011166@apollo.backplane.com> Message-ID: <20020606152514.H10454-100000@gamplex.bde.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Wed, 5 Jun 2002, Matthew Dillon wrote: > Hey Bruce or David... has GCC3 by any chance fixed the stack alignment > eyesore or is that still the default? If so could we by any chance fix > it in our version? It creates massive bloat when you have lots of tiny > functions and as far as I can tell there is no advantage at all except > for the occassional floating point intensive app. I really hate having > to specify -mpreferred-stack-boundary=2 in my builds. Apparently not. It seems to have even added an extra stack alignment instruction: %%% $ cat z.c main() { foo(); bar(1, 2); } $ cc -O -S z.c $ cat z.s .file "z.c" .text .p2align 2,,3 .globl main .type main,@function main: pushl %ebp movl %esp, %ebp subl $8, %esp andl $-16, %esp <--- call foo subl $8, %esp pushl $2 pushl $1 call bar leave ret .Lfe1: .size main,.Lfe1-main .ident "GCC: (GNU) 3.1 [FreeBSD] 20020509 (prerelease)" %%% This andl is precisely what is needed to get the stack to a known alignment starting from an unknown one, but I think it should only be done if the function has any local variables that need more than 4-byte alignment (and/or if the cpu arch cares). But in the above it is just an extra instruction if the caller has already aligned the stack. The alignment and the extra alignment is even down when it is obviously just wasted: %%% $ cat z.c main() { } $ cc -O3 -S z.c $ cat z.s .file "z.c" .text .p2align 2,,3 .globl main .type main,@function main: pushl %ebp movl %esp, %ebp subl $8, %esp <-- old alignment andl $-16, %esp <-- new alignment leave <-- alignment not actually used ret .Lfe1: .size main,.Lfe1-main .ident "GCC: (GNU) 3.1 [FreeBSD] 20020509 (prerelease)" %%% I use the default for this except for compiling gcc itself. Bruce To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message