Hi, I'm trying to run the following module in lli on LLVM 2.6, Windows/MSVS 2008, 32 bits memory model:<br>---<br>declare x86_stdcallcc i8* @GetStdHandle(i32)<br><br>define i32 @main() {<br>        %handle = call i8* @GetStdHandle(i32 -11)<br>

        ret i32 0<br>}<br>---<br>(This small modules that just retrieve the handle to stdout using WIN32 API).<br><br>I'm converting it to bytecode using: <br>llvm-as.exe -f helloworldwin32.ll <br>and running it with lli using:<br>

lli.exe helloworldwin32.bc<br>which results into a crash.<br><br>When debbugging the lli crash, I found the following code being called by llvm::ExecutionEngine::runFunctionAsMain():<br>---<br>01E80010  sub         esp,4 <br>

01E80013  mov         dword ptr [esp],0FFFFFFF5h <br>01E8001A  call        7C812FD9 <br>01E8001F  xor         eax,eax <br>01E80021  add         esp,4<br>01E80024  ret              <br>---<br><br>It is my understanding that the final "add esp, 4" should not be present when using the stdcall convention as the callee is responsible for popping the arguments from the stack, but I'm not an expert on this.<br>

<br>Is the x86_stdcallcc call convention actually supported? I found it by digging into LLVM sources (it is not listed on <a href="http://llvm.org/docs/LangRef.html#callingconv">http://llvm.org/docs/LangRef.html#callingconv</a>).<br>

<br>Is my initial LLVM-IR correct for invoking WIN32 API function?<br><br>Thanks,<br>Baptiste.<br><br>