I'm pretty new to LLVM programming, so if this answer is pretty simple,
I apologize in advance. We are working with the released LLVM 1.9.
Say you have a class called CompiledProgram which is designed to contain
our Module and (potentially) our ExecutionEngine(s). In particular, I
would like to have an ExecutionEngine for running our program natively
and another for running via the interpreter. It is the ability to have
both flavors of execution that is causing me grief. Given a Module
pointer, module, here's the scenario:
CompiledProgram* program = new CompiledProgram(module);
Inside our CompiledProgram object, we might want to do this:
Ownership of the module will transfer to the interpretedEE at this
point. Fair enough because we've got this all buttoned up in a class
and we can handle the various orders of takedown.
Later, I'd like to make a native one:
this->nativeEE = llvm::ExecutionEngine::create(???,false);
and at this point I'm in a seeming catch-22. I can't use the same
module (I believe) to construct the second ExecutionEngine since
ownership of the module is already in the first one. Zooming around the
class hierarchy didn't seem to yield a good way to do a deep copy on a
Module, which I could have done before constructing any given
ExecutionEngine and thus sidestep the ownership issue. There doesn't
seem to be a way to release a module from an ExecutionEngine once it's
there, which would also give me a solution.
I figure it's time to ask and say hi to my fellow LLVMers. Do you have
any advice on how to handle this situation?