This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: -foptimize-sibling-calls and passing structs
- To: Jamie Lokier <egcs at tantalophile dot demon dot co dot uk>
- Subject: Re: -foptimize-sibling-calls and passing structs
- From: Gabriel Paubert <paubert at iram dot es>
- Date: Sun, 4 Jun 2000 18:19:07 +0200 (METDST)
- cc: Artur Skawina <skawina at geocities dot com>, gcc at gcc dot gnu dot org
On Sun, 4 Jun 2000, Jamie Lokier wrote:
> Artur Skawina wrote:
> > r() gets compiled to:
> >
> > <r>:
> > sub $0xc,%esp
> > lea 0x10(%esp,1),%eax
> > mov %eax,0x10(%esp,1)
> > add $0xc,%esp
> > jmp <p>
> >
> > which does seem to be a bit aggressive...
>
> I assume you mean not aggressive enough. It should be
>
> lea 4(%esp,1),%eax
> mov %eax,4(%esp,1)
> jmp <p>
It seems that you missed the key point: the generated code and the one you
suggest overwrite the first element of the structure with a pointer to the
structure. The result is likely to be hmmm... interesting :-(
Sibling calls should check for case like this and disable the
optimizationg but this is API dependant: for example this should not be
disabled on PPC for example since structure are always passed by reference
and r would become a simple "b p" instruction in this trivial example.
I have no idea on how to solve the problem (besides disabling sibling
calls optimization altogether), but it might be worth adding Arthur's code
to the testsuite.
Gabriel.