[LLVMdev] MCJIT vs JT

Malea, Daniel daniel.malea at intel.com
Tue Aug 14 13:39:00 PDT 2012


Hi, please see answers inline.

On 2012-08-14, at 3:27 PM, Xinglin Zhang wrote:

Compiled the 3.0.0 version of the source code , then tried
lli --use-mcjit irfile.txt

On both windows and linux, I got:
LLVM ERROR: Unknow object format.

If I omit the -use-mcjit option, the command works well. It seems to me that something about MCJIT is broken in the 3.0.0 version. Also tried to initialize an ExecutionEngine from code, got errors like "Target does not support MC emission" on Windows or "Unknow object format" when the EngineBuilder::create() method is called.

Got the trunk version from svn, compiled and the above lli command succeeded.

That makes sense; I don't believe a fully-capable ELF loader was present in the 3.0 release. I know there's been some improvements since the 3.0 release in that area.

Here are several questions regarding MCJIT and JIT:

1. What does "MC" mean in MCJIT?

MC stands for Machine Code. There's a very informative blog post about MC, which I recommend reading:
http://blog.llvm.org/2010/04/intro-to-llvm-mc-project.html

2. What is the difference between MCJIT and JIT?

JIT compiles individual functions, and uses 'stubs' to implement calls to other functions, whereas MCJIT compiles an entire module into an in-memory object (ELF or otherwise) which is then loaded (copied into executable memory and relocations applied) by the appropriate RuntimeDyld implementation for the object type that was emitted. Currently, there's no COFF loader implementation (that I know of) but there are working loaders for ELF and MachO objects in trunk. If you want to use MCJIT on Windows, it is possible to use the ELF loader if you can tell LLVM to generate ELF objects.

Regarding the last point, how to tell LLVM to generate ELF objects -- there's been discussion on this list about that:
http://lists.cs.uiuc.edu/pipermail/llvmdev/2012-January/046670.html

However, consensus has not been reached and I don't believe an implementation of the discussed topic was ever committed.

3. According to "Debugging JIT-ed Code With GDB http://llvm.org/docs/DebuggingJITedCode.html" , we need to use MCJIT in order to debug the JIT-ed code? Is there any more documentation on this? I am working on adding DWARF debug information to the IR for a language and I need to test how gdb works with the IR+DWARF.

Minimal debugging with GDB works with the "legacy JIT" too, but is limited to showing function names in stack traces, as opposed to the full source-level debugging that is possible with MCJIT. Both implementations communicate with GDB through the JIT-interface described here in GDB's manual:
http://sourceware.org/gdb/onlinedocs/gdb/JIT-Interface.html

However, unlike MCJIT which registers a real object file (that can contain DWARF .debug sections if the input IR contains appropriate metadata) with GDB, the legacy JIT creates a very minimal object (with only a symbol table and some exception-unwinding information) which is not enough for source-level debugging (i.e. stepping through code, examining variables, etc.)

Hope the above addresses your questions!

Good luck,
Daniel




More information about the llvm-dev mailing list