[LLVMdev] How to call native functions from bytecode run in JIT?
Jan Rehders
cmdkeen at gmx.de
Tue Jun 12 14:08:27 PDT 2007
Hi,
> Okay. If the function exists in your application's address space
> already,
> just name the LLVM function the same name as the native function
> and the
> JIT should find it an do the right thing. This is how it finds
> printf and
> a variety of other things. You don't need to call addGlobalMapping at
> all.
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.
> 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?
Anyway, thank you all for the helpful comments. I'd surely yielded to
despair without your help :)
- Jan
More information about the llvm-dev
mailing list