"Freeing" functions generated with SimpleORC for JIT use-case

Hi all,
I am using LLVM for JIT use-case and compile functions on the fly. I want to “free” the modules after some time and reclaim any memory associated with it. I am using the SimpleORC API now.
Is there an API to “free” all the memory associated with the module? I use one “compiler” instance (think similar to KaleidoscopeJIT class with its ExecutionSession, CompileLayer etc.) in my process.

Is there an API to reset all memory used? Does deleting the “KaleidoscopeJIT” class ensure all memory is reclaimed? In that case i can periodically re-create that class to achieve what i want.

Thanks!

Rajesh S R

(+Lang, ORC Overseer)

Thanks David! If SimpleORC doesn’t yet support it, i can switch to an older API if that support is there. Any pointers to it?

See below for replies:

Hi all,
I am using LLVM for JIT use-case and compile functions on the fly. I want to “free” the modules after some time and reclaim any memory associated with it. I am using the SimpleORC API now.
Is there an API to “free” all the memory associated with the module? I use one “compiler” instance (think similar to KaleidoscopeJIT class with its ExecutionSession, CompileLayer etc.) in my process.

AFAIK the memory associated with JIT compiled code is owned by the ExecutionSession from which you obtained the JITEvaluatedSymbol and is initially allocated by the ObjectLayer using a SectionMemoryManager.

Is there an API to reset all memory used? Does deleting the “KaleidoscopeJIT” class ensure all memory is reclaimed? In that case i can periodically re-create that class to achieve what i want.

Beyond running the destructor for either the ExecutionSession or ObjectLayer, I have not seen a way to do this. Perhaps it’s possible by implementing your own SectionMemoryManager-like class?

Thanks Kavon! What would be useful is to have a Handle interface as shown here: https://releases.llvm.org/6.0.0/docs/tutorial/BuildingAJIT1.html

Should i just use this API for now?