This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: alloca + inline
- From: Xanthakis Stelios <sxanth at ceid dot upatras dot gr>
- To: Robert Dewar <dewar at gnat dot com>
- Cc: neil at daikokuya dot co dot uk, gcc at gcc dot gnu dot org
- Date: Sun, 16 Mar 2003 11:18:59 +0200 (EET)
- Subject: Re: alloca + inline
On Sat, 15 Mar 2003, Robert Dewar wrote:
> 1. It does not work now, and we don't care
>
> 2. It works now, but by accident, and might stop working in the future
>
> 3. It works now, and you can reasonably expect it to work in the future
> (obviously guarantees can be made in this environment).
>
I vote for 3.
With the logic "an inline is as fast as a macro"
an inline function has nothing to do with the stack.
Unless somebody decides that inline functions must
restore the stack if they use alloca (or variable
length arrays?).
Generally, trying to take advantage of alloca leads
to good program organization. The only problem is
that functions may get big sometimes because you
have to allocate all the allocas in them.
Keeping the allocas from inline functions will
be very heplful in this case.
If it's guaranteed that inline functions will not
restore the stack for the sake of "undoing" alloca,
we are ok. Obviously, for recursive functions that
can't be inlined, the programmer should really know
what he's doing and it won't be gcc's fault that
the alloca wasn't kept.
So we can make this the standard behaviour:
Inline functions that use alloca don't
get inlined, but if the programmer
specifies always_inline then it's
guaranteed that the stack is preserved.
Ok with everybody?
Stelios