[llvm-dev] Deleting function IR after codegen

Caldarale, Charles R via llvm-dev llvm-dev at lists.llvm.org
Tue Mar 8 11:40:44 PST 2016


> From: llvm-dev [mailto:llvm-dev-bounces at lists.llvm.org] 
> On Behalf Of Larry Gritz via llvm-dev
> Subject: Re: [llvm-dev] Deleting function IR after codegen

> I've been faking it with old JIT (llvm 3.4/3.5) by using a custom subclass of 
> JITMemoryManager that squirrels away the jitted binary code so that when I free 
> the Modules, ExecutionEngine, and MemoryManager, the real memory that got allocated 
> for the binary code is hidden and does not get deallocated.

> Currently I'm struggling with bringing my code base up to MCJIT without losing this 
> ability, because the memory consumption is killing me.

> For that kind of use case, it would be great to have as a first-class feature 
> the ability to free the IR of a compiled module, and even better, to throw away 
> the Module and EE entirely but keep the ability to call into the JITed binary 

This is precisely what we do for our environment.  Updating for MCJIT took a bit of work, but not too much, using SectionMemoryManager as the base class.

When OrcJIT arrived, we realized we didn't actually need the ExecutionEngine or an LLVM-provided JIT at all.  This simplified our code and removed some undesirable dependencies.  What we have now essentially just implements the logic of MCJIT's finalizeObject(), finalizeLoadedModules(), emitObject(), and generateCodeForModule() methods coupled with the aforementioned extension of SectionMemoryManager (effectively our own ExecutionEngine).

 - Chuck



More information about the llvm-dev mailing list