Programming, Software and Code

Haskell with LLVM

[Update 23 Feb 2010: I've been informed that this was not a JIT, but instead a native-code generation backend for LLVM demonstrating LLVM's aggressive optimization potential. These numbers are not representative of JIT performance.]

Several people sent me a link to a very interesting blog post yesterday about using LLVM to provide native code generation for Haskell in GHC. I recommend it as an interesting read.

One thing I will point out is that the blog post doesn't really explain the whole situation. He shows plenty of examples where LLVM improved performance, but only mentions briefly that this isn't typical of larger programs and that most programs won't experience as much speed up, if any. So to anybody who reads this remember the caveat that the results aren't typical. JIT speeds some things up and slows some things down. It's not a magic bullet that makes everything better.


Just to clarify things (author here), this isn't a JIT backend -- this is a new, alternative native code backend for GHC, which already has two native code backends.

GHC generates, in this case, LLVM bytecode, and then assembly, which is linked statically.

LLVM happens to optimize a few cases better than the existing GHC backends based on GCc, and a native one written in Haskell. It isn't always faster, but it does better at the loops generated via the stream fusion optimization..

Now, obviously, if you do replace a bytecode interpreter with LLVM-based JIT, you'll probably see great speedups, but that's not what is happening here.

Thanks for the information dons! I guess I mis-understood some bits of what was happening. I'll update the post to make clear that this is not a JIT.

Thanks again

thats good info mate! Not sure but do you know if libjit is still maintained? I took the latest tarball and played with some examples and they worked nicely the api is nice, but i ran them through valgrind and i get memory errors :S just the example code. Not sure whats happening libjit these days i guess thats whats made llvm very popular now :0 even though yeah llvm is pretty cool it scares me since its soo massive!

This entry was originally posted on Blogger and was automatically converted. There may be some broken links and other errors due to the conversion. Please let me know about any serious problems.