[LLVMdev] CWriter outputs non-portable use of alloca.h
Joel Stanley
jstanley at cs.uiuc.edu
Mon Jun 16 17:43: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. In the cases where you need
dynamic memory for some task but it doesn't need to have a lifetime
longer than the current function context, etc., using alloca() would be
faster because there'd be no heap management involved. Also, on some
platforms (in particular, SparcV9) the alloca is implemented as little
more than an %sp adjustment, so it's nice and quick.
In practice, you're probably right that malloc() is more portable, but I
dunno.
Just FYI...
-j
More information about the llvm-dev
mailing list