Currently I'm trying to use a llvm::ExecutionEngine
to JIT llvm::Function
's I generated lazily through my code generator one after another.
The content of some functions depend on the evaluation of others which means some functions need to be ready for execution in the JIT whereas others aren't generated yet.
This results in a directed acyclic code generation graph:
func_1 ---> func_2 (depends on fn1)
\
\-> func_3 -> func_4 (depends on func_1 and func_3)
time -------------->
All functions theoretically belong to the same compilation unit,
and shall be returned as one llvm::Module
the amalgamation.
Is it possible somehow to feed the ExecutionEngine with new functions without adding a module (engine->addModule(...);
) with forward declaration every time I want to add a new function to the JIT (which basically means 1 module for every function when generating recursively)?
Because then I would have to clone all functions through llvm::CloneFunctionInto
into the amalgamation (or generate it again) which doesn't look like a good solution for me.