[LLVMdev] Module management questions

Reid Kleckner reid.kleckner at gmail.com
Fri Aug 20 14:30:58 PDT 2010


On Fri, Aug 20, 2010 at 12:39 PM, Larry Gritz <lg at larrygritz.com> wrote:
> On Aug 18, 2010, at 10:24 AM, Reid Kleckner wrote:
>
>> You can free the machine code yourself by saying
>> EE->freeMachineCodeForFunction(F) .  If you destroy the EE, it will
>> also free the machine code.
>
> Thanks, but unfortunately, this is exactly the opposite of what I want to do.  I need to retain the machine code indefinitely, but I want to free all possible other resources that are not strictly needed simply to jump into the machine code and execute it.  In particular, the Modules appear to be the culprit in the memory consumption.
>
> If I call ExecutionEngine::removeModule (after JITing a function from the module), does that mean that I can subsequently no longer call the function?  Or can I?  Can I delete the Module at that point and still use the machine code?

I'm pretty sure you cannot delete the module and still execute the
code.  The JIT uses pointers to Function objects in its internal data
structures, and if you try to free one while it's holding a reference,
I believe you'll get an assertion error.  The Module owns the
Functions, so deleting it will free them.

I would imagine that most memory is used in the IR of the functions,
which you can delete as I described in my last message.  Did that
help?

Reid




More information about the llvm-dev mailing list