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 <---
callfoo
subl$8, %esp
pushl $2
pushl $1
callbar
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 [EMAIL PROTECTED]
with "unsubscribe freebsd-current" in the body of the message