[cfe-dev] Call external (non-JIT) function from JIT
fk.fuchs at googlemail.com
Tue Jul 13 14:41:45 PDT 2010
> On Tue, Jul 13, 2010 at 1:56 PM, Frank Fuchs <fk.fuchs at googlemail.com> wrote:
>> I'm not sure how to interpret this ... but the "known1" seems to be the
>> mapped function, while "known" is the extern "C" declared one (checked that
>> by renaming "known" in test.cpp). ... End of knowledge :)
> Right... I think using getOrInsertFunction instead of
> llvm::Function::Create will solve the issue. If you use
> llvm::Function::Create with an already existing name, it will
> automatically rename it to avoid the conflict; this is nice when you
> don't care about the name, but not what you want here.
Great! It works ... thank you!
Just for the record, I replaced the Function::create call by this one:
llvm::Function *KnownFunction = cast<llvm::Function>(Mod->getOrInsertFunction("known",llvm::TypeBuilder<int(int), false>::get(Mod->getContext())));
So this would be the way to declare C Functions to the "Script" ... now can this be done for C++ methods as well?
Is there a possibility that the JIT "links" against C++ classes from the "host" application?
More information about the cfe-dev