http://clang.llvm.org/
Clang has link-time optimization (with option -flto), but not profile-guided optimization (pgo).
Below are some comparisons with gcc for building and benchmarking Stockfish, in which clang comes out well.
micron wrote:gcc version 4.2.1 (Apple Inc. build 5666) (dot 3)
That's an extremely old GCC version. GCC 4.2.1 was released in July 2007. The current version is 4.5.2, and a release candidate for 4.6 was released just a couple of weeks ago.
Comparing a recent version of clang to an almost four year old version of GCC is quite meaningless, especially when you enable link-time optimization in clang. GCC 4.2.1 does not support link-time optimization, but 4.5 does. It is possible that clang would still come out ahead in a direct comparison to the latest GCC version, but I doubt it.
micron wrote:gcc version 4.2.1 (Apple Inc. build 5666) (dot 3)
That's an extremely old GCC version. GCC 4.2.1 was released in July 2007. The current version is 4.5.2, and a release candidate for 4.6 was released just a couple of weeks ago.
Comparing a recent version of clang to an almost four year old version of GCC is quite meaningless, especially when you enable link-time optimization in clang. GCC 4.2.1 does not support link-time optimization, but 4.5 does. It is possible that clang would still come out ahead in a direct comparison to the latest GCC version, but I doubt it.
Now, this is not a recent test either, but from logical inference (clang uses a virtual machine) it does not seem feasible to me for it to be equally fast.
On the other hand, I would love to be pleasanly surprised by a virtual machine that can smoke truly compiled code. But, after all, we do not expect Java, C# or other virtual machine languages to suddenly start outperforming C.
I do suspect that the LLVM might be a great engine for interpreted things like Java and VB.NET but I would be shocked if it ever beats native optimized assembly output.
Dann Corbit wrote:Now, this is not a recent test either, but from logical inference (clang uses a virtual machine) it does not seem feasible to me for it to be equally fast.
clang is just the compiler frontend project. Its a fully native compiler thats just using LLVM as the backend code generator and optimizer.
Before clang was written, there used to be a fork or something of gcc that used LLVM for code gen [edit: called LLVM-GCC, I guess]. They made clang because gcc's front end is old and crufty. clang is faster, uses less memory, and can supposedly report more useful diagnostics. The source is also (apparently) much easier to change, or to re-use in other projects such as IDEs or code analysis tools etc.
The LLVM project is a bunch of infrastructure that can also be used to make runtime compilers (like JITs for a virtual machine environment) but the clang compiler being benchmarked above generates native code just like gcc, that doesnt need or use a virtual machine environment at runtime.
I was quite impressed with gcc 4.5.0, in my benchmarks its generated code was as fast as with the newest Intel Compiler on Intel CPUs (and of course much faster on AMD CPUs, due to the purposefully bad performance icc has there).