Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are the greatest benefits of LLVM? [closed]

Tags:

c++

c

llvm

clang

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!

like image 997
Kevin Avatar asked Oct 05 '08 23:10

Kevin


2 Answers

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.

like image 178
Louis Gerbarg Avatar answered Sep 29 '22 09:09

Louis Gerbarg


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.

like image 20
J D Avatar answered Sep 29 '22 07:09

J D