Hi<br><br>Thanks for the help Jake and Anton.<br><br>Attached is a patch for DynamicLibrary.inc to fix alloca resolving. It uses the function that _alloca compiles to when it's compiled by VS. (== _alloca_probe == _chkstk). I tried this in 2003, but I haven't grabbed the 
post-2.0 from CVS to try with 2005. Looking at the code for 2005, it looks as if it will work fine.<br><br>scott<br><br><div><span class="gmail_quote">On 6/24/07, <b class="gmail_sendername">Jake</b> <<a href="mailto:jake@jakeonthenet.com">
jake@jakeonthenet.com</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div>The alloca hook is in lib\System\Win32\DynamicLibrary.inc all the way at the bottom. You'll see a __MING32__ #ifdef around the definition. You just have to implement those methods and it'll work just fine.
</div><span class="sg">

<div> </div>
<div>Jake<br><br> </div>
</span><div><span class="q"><span class="gmail_quote">On 6/24/07, <b class="gmail_sendername">Scott Graham</b> <<a href="mailto:scott.llvm@h4ck3r.net" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
scott.llvm@h4ck3r.net</a>> wrote:</span>
</span><div><span class="e" id="q_1135f7e6d4a84fd4_4"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0px 0px 0px 0.8ex; padding-left: 1ex;">Hi<br><br>Thanks for the info, it led to the source of the error I was having.
<br><br>I was using llvm-gcc binaries (built with mingw I guess) to compile a .c file that is my language runtime, llvm-link'ing that with my frontend's .ll, and using an vcpp-built lli to run the resulting bytecode. This caused the special case in X86RegisterInfo::emitPrologue for "main" to try to align the stack using _alloca which caused the problem, because it felt that target was CygMing. Hacking the output of llvc-gcc from target triple="mingw32" to "win32" makes it "work". Is that generally dangerous, or should it be OK? I suppose I'll have to battle with msys/bison/m4 again, but they beat me soundly last time I tried to build mingw-lli. 
<br><br>I tried to fix the alloca resolution, as it does appear the same thing will happen once there's > 4k on the stack as you mentioned (mingw hacking or no). I wasn't able to understand where lli was doing the hooking you describe though. Once I have some larger functions, I'll dig in more deeply (or if someone points me at it...). 
<br><br>Thanks for the help,<br><span>scott</span> 
<div><span><br><br><br>
<div><span class="gmail_quote">On 6/24/07, <b class="gmail_sendername">Anton Korobeynikov</b> <<a href="mailto:asl@math.spbu.ru" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">asl@math.spbu.ru</a>

> wrote:</span> 
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Hello, Scott.<br><br>> Checking the assembly from llc, the first alloca call is to allocate
<br>> local vars in _main. Is this just the state of the code at 2.0 when<br>> built with <a href="http://vs.net/" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">vs.net</a> , or is there something that I've managed to
<br>> mis-build locally?<br><br>_alloca is used to probe the stack, if you asks for locals of size more<br>that 4k. This is pretty ugly, but the names of this functions differs <br>for mingw32 variant (_alloca) and something like chkstk (vcpp). For
<br>mingw32 it's exported in libgcc, dunno about vcpp (probably from some<br>runtime libraries).<br><br>Since there is no dynamic linking on windows, there is special hook to <br>resolve _alloca call at runtime. Surely, this won't be applicable for
<br>lli built by vcpp. Probably, you'll have either to switch to<br>mingw32-built lli or resolve _alloca/chkstk problem somehow (adding<br>hooks, special lowering code, etc). In fact, I don't know, whether <br>_alloca and chkstk has compartible prototypes. If yes, you might
<br>probably just change the hook in lli (don't forget to send patch! :) ),<br>if no - you'll have to change lowering code...<br><br>--<br>With best regards, Anton Korobeynikov. <br><br>Faculty of Mathematics & Mechanics, Saint Petersburg State University.
<br><br><br>_______________________________________________<br>LLVM Developers mailing list<br><a href="mailto:LLVMdev@cs.uiuc.edu" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">LLVMdev@cs.uiuc.edu 
</a>         <a href="http://llvm.cs.uiuc.edu/" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://llvm.cs.uiuc.edu</a><br><a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">

http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br></blockquote></div><br></span></div><br>_______________________________________________<br>LLVM Developers mailing list<br><a href="mailto:LLVMdev@cs.uiuc.edu" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">

LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu/" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://llvm.cs.uiuc.edu</a><br><a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">

http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br><br></blockquote></span></div></div><br>
<br>_______________________________________________<br>LLVM Developers mailing list<br><a onclick="return top.js.OpenExtLink(window,event,this)" href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a>         <a onclick="return top.js.OpenExtLink(window,event,this)" href="http://llvm.cs.uiuc.edu" target="_blank">
http://llvm.cs.uiuc.edu</a><br><a onclick="return top.js.OpenExtLink(window,event,this)" href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br><br>
</blockquote></div><br>