[LLVMdev] two questions about JIT compilation
nicholas.maxwell.lester at gmail.com
Tue Jul 26 18:22:00 PDT 2011
I've written a small language implementation that JIT-compiles code prior to
execution. At the moment, i execute the function through
ExecutionEngine::runFunction. However, this requires me to keep all of the
code generation artifacts (instructions, constants, etc) around during
execution. Given that execution compiles the program down to machine code,
is there a reasonably straight-forward way to discard the contents of my
generated Module, and simply call the JITted function through a pointer
obtained through ExecutionEngine::getPointerToFunction? I tried creating an
independent JITMemoryManager and keeping that around, but the execution
engine takes ownership of it (maybe to prevent this behaviour?).
My second question is about how to embed a reference to a c/c++ function
into LLVM-generated code. I'm only interested in the JIT case, so this code
doesn't have to outlive the generating executable's lifetime. The way i
think this can be achieved is to cast a pointer to this function to an int,
insert it into the generated code via ConstantInt, then use inttoptr to cast
it back to the correct function type and call it. Is there a more direct
way of doing this?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the llvm-dev