[LLVMdev] Relocatability of LLVM code

Gary Benson gbenson at redhat.com
Thu Aug 20 06:42:03 PDT 2009


Hi all,

As I understand it, LLVM's JIT memory manager works by allocating a
16Mb block of memory and generating native code into it.  Once that
block is exhausted no more functions can be JIT compiled.  I'm trying
to figure out ways to work around this limitation.

One idea I had was to use that 16Mb block as a scratch area for
generating code.  Once a method has been compiled (and therefore its
size is known) a new block of memory would be allocated and the native
code copied into it.  The original copy could then be freed, leaving
the whole 16Mb block free for the next compilation.  I realize this
approach is not generically suitable for LLVM, but it might be
possible for the application I'm working on because a) a single thread
manages all compilations sequentially, and b) the compiled methods
don't make direct calls to other methods (so stubs will never be
generated).

What I need to know is, is the native code generated by LLVM
relocatable such that it could be copied to another location in memory
like this?  Also, does LLVM do anything to the native code after it is
first emitted?  Does it try rewriting it, for example?

Cheers,
Gary

-- 
http://gbenson.net/



More information about the llvm-dev mailing list