[LLVMdev] alloca on Win32

Anton Korobeynikov asl at math.spbu.ru
Sun Jun 24 12:14:57 PDT 2007


Hello, Scott.

> Checking the assembly from llc, the first alloca call is to allocate
> local vars in _main. Is this just the state of the code at 2.0 when
> built with vs.net, or is there something that I've managed to
> mis-build locally?

_alloca is used to probe the stack, if you asks for locals of size more
that 4k. This is pretty ugly, but the names of this functions differs
for mingw32 variant (_alloca) and something like chkstk (vcpp). For
mingw32 it's exported in libgcc, dunno about vcpp (probably from some
runtime libraries). 

Since there is no dynamic linking on windows, there is special hook to
resolve _alloca call at runtime. Surely, this won't be applicable for
lli built by vcpp. Probably, you'll have either to switch to
mingw32-built lli or resolve _alloca/chkstk problem somehow (adding
hooks, special lowering code, etc). In fact, I don't know, whether
_alloca and chkstk has compartible prototypes. If yes, you might
probably just change the hook in lli (don't forget to send patch! :) ),
if no - you'll have to change lowering code...

-- 
With best regards, Anton Korobeynikov.

Faculty of Mathematics & Mechanics, Saint Petersburg State University.





More information about the llvm-dev mailing list