[LLVMdev] Fwd: Basic questions

Graham Wakefield mail at grahamwakefield.net
Thu Nov 6 18:41:23 PST 2008

Thanks, that helps. I saw the possibility to redefine function bodies  
in the Kaleidoscope tutorial. What's not so clear to me yet, is how  
to support multiple Modules, but it's getting clearer now.

Can I run a potential case past you just to be sure that it is/isn't  

I'd like to support users dynamically adding and using functions  
(plus structs, globals etc) to a Module, JIT compiling to an  
ExecutionEngine, in an interleaved fashion. That is, declare & define  
a function, run it through a FunctionPassManager, add it to an  
ExecutionEngine, use it, go ahead and repeat for a different function  
with the same Module, FunctionPassManager & ExecutionEngine, etc.

Also, does there need to be a 1-1-1 correspondence between Module,  
FunctionPassManager and ExecutionEngine, or can it be 1-many(1-1)?

Thanks again, and once again sorry if this info is available in  
existing docs; I haven't been able to find it yet.

On Nov 6, 2008, at 8:36 AM, Nuno Lopes wrote:

> Hi,
> The JIT engine currently uses a single memory block for all  
> functions that you JIT-compile (and global variables, constants,  
> etc..). Still, you can easily create and delete machine code.
> You can use the following functions:
> engine->freeMachineCodeForFunction(function); // clean the JITed code
> function->eraseFromParent(); // clean a function's IR
> About the lifetime of the classes, its better to create them only  
> once, for eficiency sake. Allocating PassManagers each time you  
> compile a given piece of code is slow (and probably not useful as  
> you can reuse it).
> Nuno

More information about the llvm-dev mailing list