[LLVMdev] How to call native functions from bytecode run in JIT?

Chris Lattner sabre at nondot.org
Wed Jun 13 10:28:56 PDT 2007


On Tue, 12 Jun 2007, Jan Rehders wrote:
> Looking at the output of "nm codegen1" I realized that "get5" was a C+
> + function whose name was mangled to "__Z4get5v". Surrounding it by
> extern "C" helped a lot :) Now the function is found by the JIT and I
> can call it using EE->runFunction als well as using a CallInst.

That would definitely do it :)

>> Does this work?
>
> However, one strange effet remains: if I first call the function
> using EE->runFunction and then try to call it using a CallInst inside
> another function I get the old "relocation" error in PPCJITInfo.cpp,
> again. Using a CallInst first, then runFunction and then a CallInst
> again works, though. For my project this is probably a non-issue but
> it might indicate some problem in either my code or LLVM - any ideas?

There definitely is a bug here: your initial code should have worked. 
That said, noone has stepped up to fix it, and I'm busy with many other 
things.  If you'd like to dig in and fix the bug, that would be excellent
:)

-Chris

-- 
http://nondot.org/sabre/
http://llvm.org/



More information about the llvm-dev mailing list