[LLVMdev] Why JITC?

Andrew Lenharth alenhar2 at uiuc.edu
Mon Aug 7 11:56:48 PDT 2006


On Mon, 2006-08-07 at 18:17 +0100, Mike Hearn wrote:
> I guess this is slightly offtopic, but the post about the JIT and garbage
> collection made me wonder why LLVM supports JIT compilation at all. It has
> much smaller scope for optimisation due to the speed requirements, takes
> more memory and causes the same work to be repeated over and over for each
> execution. 
> 
> What reason is there for anything to use JIT compilation over
> ahead-of-time compiling to native code?

A lot of optimizations are based on runtime behavior.  Your choices
there are either extensive profiling or runtime profiling with JITing.

As an example, let's say you have a indirect function call.  Most of the
time this function goes to one target.  With a JIT, you can expand
heavily biased calls to test the function pointer (as a validation) and
do a direct call.  Then you may be able to inline or IP-constant
propagate the call site.  The target of that call site might be input
data based, in which case you cannot statically do these optimizations
profitiably, and even profiling may blur the fact that the call is
mostly static (since different input data may generate different call
targets).  Thus you must do runtime profiling and JITing.

Granted, LLVM currently doesn't really do much of this, but the
infastructure is there to do so.

Andrew




More information about the llvm-dev mailing list