Question

I'm new to LLVM framework and compilers field. I'm trying to get acquainted with it. Having done some preliminary reading in compilers i have the following question:

I would like to know how is function inlining done in LLVM JIT. Is it the same pass that is used in static inlining used at jit compile time as well coz i feel that information at run-time (i.e jit compile time) is better compared at static compile time and hence some better optimization passes(which are inexpensive in terms of time) can be used.

Am i missing any thing ?? I really appreciate some help in this regard.

Thanks in advance.

Was it helpful?

Solution

You're not missing anything. LLVM is, was, and probably will be for years to come, more suited for static compiler. It supports JIT compilation in the basic sense just fine (pretty well, in fact, with the advent of MCJIT) in that you can go from IR to in-memory machine code without much hassle. But it does not do things like tracing execution or profiling out of the box. You can add them, but AFAIK the support for patching already-emitted code is limited at best (i.e. you'd probably have to re-compile large amounts of code). And while you can always add code to collect metrics and write your own optimization passes which make use of these (or are otherwise tailored to the JIT compiler's requirements), this takes significant effort. See also: Unladen Swallow Retrospective (third section; be warned that this post is >1 year old).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top