tags:

views:

2691

answers:

3

Does anyone have experience with LLVM, llvm-gcc, or Clang?

The whole idea behind llvm seems very intriguing to me and I'm interested in seeing how it performs. I just don't want to dump a whole lot of time into trying the tools out if the tools are not ready for production.

If you have experience with the tools, what do you think of them? What major limitations have you encountered? What are the greatest benefits?

Many thanks!

+9  A: 

I've had an initial play around with LLVM and working through this tutorial left me very very excited about it's potential; the idea that I can use it to build a JIT into an app with relative ease has me stoked.

I haven't gone deep enough to be able to offer any kind of useful opinion on it's limitations, stability, performance and suchlike. I understand that it's good on all counts but that's purely hearsay.

Great link: +1.
jkp
+17  A: 

I can't say enough good things about LLVM. It is so easy to work with compared to other compiler projects I have looked at. I am not a compiler guy, but when I get frustrated with some limitation of LLVM or clang it is usually pretty easy to dive in and change it.

We (Nate Begeman, myself, and a few others) wrote the PPC backend with no real experience in compiler design, but it looked simple enough that non-experts could approach it. We were pretty familiar with PPC assembly, but it was still pretty incredible we managed to get LLVM-gcc outputting PPC code in a few weeks of our spare time. Definitely one of the most satisfying Hello World's I have ever compiled.

Louis Gerbarg
+15  A: 

I have been playing with LLVM on and off for many months now. I wrote two OCaml Journal articles covering the use of LLVM from the OCaml programming language. That is particularly interesting because the OCaml language is ideal for writing compilers and has a wealth of powerful and mature tools and libraries for parsing and so on.

Overall, my experience has been extremely positive. LLVM does what it says on the tin and is very easy to use. The performance of the generated code is superb. One of the programs I wrote was a simple little Brainf*ck compiler that generates some of the fastest executables of any compiler I tested (including GCC).

I have only two gripes with LLVM. Firstly, it uses abort() whenever anything goes wrong instead of raising an exception. This was a deliberate design decision by its authors who are striving to remove all uses of exceptions from LLVM but it makes it impossible to get backtraces from OCaml when trying to debug a compiler that uses LLVM: your program just dies with a textual explanation from LLVM but no clue as to where the error occurred in your source. Secondly, LLVM's compiled library is monstrously big (20Mb). I assume this is due to the bloat incurred by C++ but it makes compilation painfully slow.

EDIT: My work on LLVM culminated in the creation of a high-performance high-level garbage-collected virtual machine. Free download here and check out the corresponding benchmarks (wow!). @Alex: I'll get that BF compiler up for you somewhere ASAP.

Jon Harrop
Can you post the BF compiler? I wrote a BF->C translator which, I think, is about as good as you can get in a single pass, and llvm-gcc falls over pretty badly in really big programs. They are kinda unfair, though.
alex strange