Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 24 May 2000 09:02:14 +0300
From:      Valentin Nechayev <netch@lucky.net>
To:        freebsd-hackers@freebsd.org
Subject:   gcc 2.95.2 extra %esp addings
Message-ID:  <20000524090214.W66599@lucky.net>

next in thread | raw e-mail | index | archive | help
Consider a little test program:

> #include <stdio.h>
> extern int func_a( int, int );
> int main()
> {
>    int i;
>    for( i = 0; i < 100; i++ ) {
>       printf( "%d\n", func_a( i, i+2 ) );
>    }
>    return 0;
> }

Part of assembler code built by gcc 2.7.2.3 (on FreeBSD-3.4-stable):

>         pushl %ebp
>         movl %esp,%ebp
>         pushl %ebx
>         xorl %ebx,%ebx
> .L15:
>         leal 2(%ebx),%eax
>         pushl %eax
>         pushl %ebx
>         call func_a
>         pushl %eax
>         pushl $.LC0
>         call printf

Part of the same built by gcc 2.95.2 (on FreeBSD 4.0-stable or 5.0-current):

>         pushl %ebp
>         movl %esp,%ebp
>         subl $20,%esp
>         pushl %ebx
>         xorl %ebx,%ebx
> .L10:
>         addl $-8,%esp
>         addl $-8,%esp
>         leal 2(%ebx),%eax
>         pushl %eax
>         pushl %ebx
>         call func_a
>         pushl %eax
>         pushl $.LC0
>         call printf

One can observe extra commands which deals with %esp (add or subtract
something). This was built with -O99 (full command line for both gcc versions:
gcc -O99 -S -g main.c), with any extra code-generation options or without
them, result is the same.

Also tested on some real programs from -current src tree, with the same
(extra addings to %esp) result.

gcc 2.95.1 from port does not add such commands.

In program where this was discovered, situation is even worse:

> .stabn 68,0,8,.LM3-main
> .LM3:
>         addl $32,%esp
>         addl $-8,%esp
>         addl $-8,%esp
>         pushl $1
>         pushl $0
>         call func_a

and none optimization groups these operations.

Is it reasonable or it is bugfeature of this gcc version?
Is it FreeBSD-specific?

And what reason is to have two identical (except some html docs) copies
of gcc - src/contrib/gcc and src/contrib/gcc.295 ?

--
NVA


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20000524090214.W66599>