<div dir="rtl"><div dir="ltr">Since you know the argument types you can hardcode your own runFunction with the specific types.</div><div dir="ltr">You don't have to go through GenericValues at all, just get the pointer to function and call it with the correct input types.</div>

<div dir="ltr"><br></div><div dir="ltr">For example, the code to run int F(int) is:</div><div dir="ltr"><br></div><div dir="ltr"><div dir="ltr"><font face="courier new, monospace">  void *FPtr = getPointerToFunction(F);</font></div>

<div><div><font face="courier new, monospace">  assert(FPtr && "Pointer to fn's code was null after getPointerToFunction");</font></div></div><div><div><span style="font-family:'courier new',monospace">  int (*PF)(int) = (int(*)(int))(intptr_t)FPtr;</span><br>

</div><div><font face="courier new, monospace">  OutputInt = PF(InputInt);</font></div><div><font face="courier new, monospace">  return </font><span style="font-family:'courier new',monospace">OutputInt;</span></div>

</div><div><br></div><div>Yaron</div><div><br></div><div><br></div></div></div><div class="gmail_extra"><br><br><div class="gmail_quote"><div dir="ltr">2013/11/8 edA-qa mort-ora-y <span dir="ltr"><<a href="mailto:eda-qa@disemia.com" target="_blank">eda-qa@disemia.com</a>></span></div>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">It was the return type which was i64. I changed it also to my<br>
abi_int_size and it works now.  I have to take care of a few other type<br>
translations, but it looks like MCJIT is working now.<br>
<br>
Thank you.<br>
<div class="im"><br>
<br>
On 08/11/13 18:12, Yaron Keren wrote:<br>
> Something must be wrong with the Function Type. Try to debug into<br>
> runFunction to see which if condition fails.<br>
> Just a guess, if this is on 64 bit system the first argument type may be<br>
> int64 but needs to be int32.<br>
><br>
> Yaron<br>
><br>
><br>
><br>
</div>> 2013/11/8 edA-qa mort-ora-y <<a href="mailto:eda-qa@disemia.com">eda-qa@disemia.com</a> <mailto:<a href="mailto:eda-qa@disemia.com">eda-qa@disemia.com</a>>><br>
<div><div class="h5">><br>
>     That makes it more mysterious then since I am indeed only calling a main<br>
>     function.  Perhaps I have to invoke it a different way. Here's my call I<br>
>     have now:<br>
><br>
>             auto main = linker->getModule()->getFunction( "main" );<br>
><br>
>             std::vector<llvm::GenericValue> args(2);<br>
>             args[0].IntVal = llvm::APInt( platform::abi_int_size, 0 );<br>
>             args[1].PointerVal = nullptr;<br>
>             llvm::GenericValue gv = ee->runFunction( main, args );<br>
><br>
><br>
><br>
>     On 08/11/13 11:14, Yaron Keren wrote:<br>
>     > MCJIT::runFunction supports only main-style argument passing but not<br>
>     > other cases like the JIT.<br>
>     > These types of arguments will work:<br>
>     ><br>
>     > (int, char**, char**)<br>
>     > (int, char**)<br>
>     > (int)<br>
>     > (void)<br>
>     ><br>
>     > The general case is not supported since it requires creating a small<br>
>     > stub function, compiling and running it on the fly, supported by<br>
>     JIT but<br>
>     > not MCJIT.<br>
>     ><br>
>     > However, with the supported calling sequences, you can probably<br>
>     replace<br>
>     > the char** with a void* to a structure so that practically<br>
>     anything can<br>
>     > be passed to your function inside the structure.<br>
>     ><br>
>     > Yaron<br>
>     ><br>
>     ><br>
>     ><br>
>     > 2013/11/8 edA-qa mort-ora-y <<a href="mailto:eda-qa@disemia.com">eda-qa@disemia.com</a><br>
</div></div>>     <mailto:<a href="mailto:eda-qa@disemia.com">eda-qa@disemia.com</a>> <mailto:<a href="mailto:eda-qa@disemia.com">eda-qa@disemia.com</a><br>
<div><div class="h5">>     <mailto:<a href="mailto:eda-qa@disemia.com">eda-qa@disemia.com</a>>>><br>
>     ><br>
>     >     I'm trying to get MCJIT working but I get the following errors:<br>
>     >             Full-featured argument passing not supported yet!<br>
>     >             UNREACHABLE executed at MCJIT.cpp:322!<br>
>     >     I'm sure the first one will be a problem, but the second one<br>
>     prevents me<br>
>     >     from testing anything. I don't know how to fix the problem.<br>
>     ><br>
>     >     My code works when using the non-MC JIT, and I added to my<br>
>     >     EngineBuilder:<br>
>     >             .setUseMCJIT(true)<br>
>     ><br>
>     >     Reading from a tutorial* I also tried finalizing the engine<br>
>     object:<br>
>     >             ee->finalizeObject()<br>
>     ><br>
>     >     I'd like to get this working since in the release notes for 3.4 it<br>
>     >     indicates exception handling has been removed from the old<br>
>     JIT. I need<br>
>     >     exception handling support and would like to get MCJIT working<br>
>     prior to<br>
>     >     upgrading to 3.4 later.<br>
>     ><br>
>     ><br>
>     ><br>
>     *<a href="http://blog.llvm.org/2013/07/using-mcjit-with-kaleidoscope-tutorial.html" target="_blank">http://blog.llvm.org/2013/07/using-mcjit-with-kaleidoscope-tutorial.html</a><br>
>     ><br>
>     >     --<br>
>     >     edA-qa mort-ora-y<br>
>     >     -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --<br>
>     -- -- --<br>
>     >     Sign: Please digitally sign your emails.<br>
>     >     Encrypt: I'm also happy to receive encrypted mail.<br>
>     >     _______________________________________________<br>
>     >     LLVM Developers mailing list<br>
>     >     <a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a> <mailto:<a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a>><br>
</div></div>>     <mailto:<a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a> <mailto:<a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a>>><br>
<div class="im HOEnZb">>     >     <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
>     >     <a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
>     ><br>
>     ><br>
><br>
><br>
>     --<br>
>     edA-qa mort-ora-y<br>
>     -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --<br>
>     Sign: Please digitally sign your emails.<br>
>     Encrypt: I'm also happy to receive encrypted mail.<br>
><br>
><br>
<br>
<br>
</div><div class="HOEnZb"><div class="h5">--<br>
edA-qa mort-ora-y<br>
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --<br>
Sign: Please digitally sign your emails.<br>
Encrypt: I'm also happy to receive encrypted mail.<br>
</div></div></blockquote></div><br></div>