[LLVMdev] Question about memory allocation in JIT

Merkulov Aleksey steel1.0 at mail.ru
Wed Jul 1 09:07:25 PDT 2009


Hello!  Working with LLVM JIT-compiler I found a small bug and I'd like to correct it.  Namely, on some tests LLVM fails with message "JIT: Ran out of space for generated machine code!"

This error emerges because the test creates big static array.  Global variables are placed into memory block for function, that is first seen using given variable.  Besides, during memory allocation for function its size is not considered in any way.  Although there exist a code block (in JITEmitter::startFunction), which is able to calculate function size, allocator (in DefaultJITMemoryManager::startFunctionBody) does not consider predicted function size.  So lli fails, when a test uses big static array.

How would you advise to correct this bug?  It is possible to allocate global variables in separate memory block(s) (in my opinion, it is not so good to place variables into executable memory area), or it is possible to improve allocator so that it considers predicted function size.  However, if using size prediction, JIT calculation of exact function size may occupy time.  Probably it would be better to estimate function size instead of exact calculation.




More information about the llvm-dev mailing list