MCJIT -- Poor run-time performance for Fibonacci example in LLVM 3.8.1

We have been using LLVM 3.4 and are currently migrating to LLVM 3.8.1. We have been using the Old JIT and since it has been removed since 3.6, we have to use MCJIT. I find that run-time performance is very poor in 3.8.1 for the Fibonacci example in llvm/examples/fibonacci.cpp. Logs below for fib34 and fib381 for input values of 30 and 40. I first thought it could be that MCJIT compile time is slower, but as I increase the input value, fib381 gets slower and slower in run-time performance (almost 200X for an input value of 40). Any hints on what could be going wrong? TIA.

% time fib34 30

starting fibonacci(30) with JIT…

Result: 832040

0.008u 0.000s 0:00.01 0.0% 0+0k 0+0io 0pf+0w

% time fib34 40

starting fibonacci(40) with JIT…

Result: 102334155

0.427u 0.003s 0:00.44 95.4% 0+0k 0+0io 0pf+0w

% time fib381 30

starting fibonacci(30) with JIT…

Result: 832040

0.795u 0.001s 0:00.81 97.5% 0+0k 0+0io 0pf+0w

% time fib381 40

starting fibonacci(40) with JIT…

Result: 102334155

97.591u 0.006s 1:37.71 99.8% 0+0k 0+0io 0pf+0w

Compile command used for each version (Platform: Linux 2.6.32-504.16.2.el6.x86_64):

clang++ -std=c++11 fibonacci.cpp llvm-config --cxxflags --ldflags --libs -ldl -lpthread -lncurses -o fib381

clang++ fibonacci.cpp llvm-config --cxxflags --ldflags --libs -o fib34

Hi Riyaz,

I don't know much about it, but MCJIT was also replaced, by a new JIT
called "ORC".

The Kaleidoscope example has been updated, you can look there:


Hi Riyaz, Renato,

Attempting to run Fibonacci from LLVM 3.8.1 on Darwin I get:

./fib381: Failed to construct ExecutionEngine: Interpreter has not been linked in.

This suggests that the reason for the slowdown isn’t in the JIT itself. Instead, when we removed the old JIT we probably didn’t update the Fibonacci example to request a JIT at all, so now it’s falling back to the interpreter. I’m just digging in to confirm this now, and will update the example code as needed to fix this.


Hi Riyaz, Renato,

I’ve updated MCJIT and the Fibonacci example in r272455. The example performance should now be comparable to llvm-3.4. I’ll update it again in the near future to use ORC rather than MCJIT.

Riyaz - You may want to consider moving straight to ORC, rather than MCJIT. ORC provides a superset of MCJIT’s functionality (including support for lazy JITing on some platforms), and is better at managing memory. The new tutorial series that I’m working on might be helpful: .

  • Lang.