This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]