I would like to understand why calling a native function from a function
in LLVM IR can be much faster than calling an equivalent function in LLVM
IR.
For instance, here are two equivalent programs. The first calls an llvm
function while the second calls a native function. On my AMD machine, the
first takes 4.48s to run while the second takes 3.49s.
I am calling method runFunction of ExecutionEngine. I am using the default
code gen optimization level.
LLVM does not optimize your IR unless you explicitly ask for it. For
your example, once optimized, the code that is all LLVM will run faster
than the other version that calls a non-LLVM function.