[LLVMdev] CWriter outputs non-portable use of alloca.h

Brian R. Gaeke gaeke at uiuc.edu
Mon Jun 16 18:12:01 PDT 2003

> On Mon, 2003-06-16 at 17:33, John Criswell wrote:
> > 	What would be better yet is to modify the code so that it does not use 
> > alloca() at all.  There seems to be little reason to use it aside from 
> > convenience (but perhaps I have missed something).  
> I think the idea is that alloca can give (probably significant)
> performance gains when used properly.

There are two different issues here.

CWriter *outputs* alloca() calls so that it can be sure to output C code
that correctly corresponds to the LLVM bytecode, which may have alloca
instructions in it. I think we have little choice but to continue using
alloca() here. I'm going to hack in an ifndef for FreeBSD around
the declaration output by CWriter to fix this.

LLVM *calls* alloca() in various places because people prefer to use it,
as stated above, for performance, and perhaps more significantly, to
ease managing memory that will only be used during the lifetime of
a particular function call. I might not personally choose to introduce
more calls to alloca() in the compiler itself, but it doesn't seem to
me to be an important enough issue that I would be driven to get rid of
all the existing calls to alloca().

gaeke at uiuc.edu

More information about the llvm-dev mailing list