I've observed no such 10-20% slowdown on iOS, which is more CPU-constrained than most realms. Typically, LLVM-generated code is equivalent to or faster than gcc. Sometimes it's much faster.
What is an example of an optimization that a JIT compiler can make that a AOT compiler cannot?
If the developer is able to profile the application on typical end-user workloads, don't profile-guided optimizations provide the same benefit as JIT runtime profiling?
Why can't an AOT compiler just consider every path a "hot" path?
Last but not least: Got any benchmarks?
Wikipedia gives a few more[2]: runtime profile-guided optimizations and pseudo-constant propagation
In the case of non-dynamic languages like C and C++ that clang generally targets, are there other examples of where JIT would make things possible that are not possible in AOT?
Optimizing for the specific processor you're running on, as opposed to being forced to compile for a lowest common denominator.
A whole bunch of other small things like that.
For example, you might see that branch X is always taken. So you assume that X will always be true, and add a guard just in case which triggers a recompilation. You reoptimized the function on the basis of your new (speculative) information about X. This could improve register allocation, allow you remove lots of code (other branches maybe), inline functions, etc.
Java JITs have been known to inline hundreds of functions deep with this.
Profile-guided optimizations only work on the next run, and, when used by the developer, do not work for cases where there are widely different usage profiles for a single program. For example, most users would have data sets that fit in memory, but others will have ones that do not.
All I know for sure is I compiled my codebase with Clang for the first time yesterday and the compilation time was absurdly short. I thought the compiler was broken. And it enables excellent tools like clang_complete for Vim code completion.
Over time, as Clang gets more mature, it will become more and more on par (or better) than GCC.
http://gcc.gnu.org/releases.html#timeline http://www.gnu.org/philosophy/pragmatic.html (see part about Objective C)
I hear there's this kernel called Linux that depends heavily on GCC.
http://lists.cs.uiuc.edu/pipermail/cfe-dev/2010-October/0117...
"Quite frankly, I'd like there to be more competition in the open source compiler game, and that might cause some upheavals, but on the whole, gcc actually does a pretty damn good job."