This project is really cool, but the comments in this threads seems, well, a little too optimistic.
Some assume that in the far future Cretonne could achieve performance similar to LLVM, but that simply doesn’t seem to be a possibility, and I’m not talking about the massive development and research that have gone into LLVM, but rather an architectural limitation: the lack of undefined behavior.
Undefined behavior is the cornerstone in modern optimizers. Without that, you never come near to the speed of GCC, LLVM, VeLLVM, etc.
Many optimizations are impossible without UB. In fact, the vast majority of optimization passes rely on UB in one way or another. If everything is well-defined, there’s a hell lot of things you cannot do.
I don’t see any obvious way to get around this without either adding heavy runtime checks (e.g. derefing dangling pointers gives zero or crashes the program) or undefined behavior (something happen).
I’d say making a compromise between the two extremes would make sense. For one thing, you could make derefing null pointers defined and so on. Another less extreme idea is to remove all undefined behavior except for the Undefined Value-based (Undef, as the value is known in LLVM) UB. This allows for smoother reasoning, but still carries many of the same disadvantages of normal UB, unfortunately.
That being said, I don’t think it’s a bad idea, because there are cases where accidental UB is a no-go even on the cost of performance. The web is an example. I just think that it cannot (and should not) replace the default optimizer in --release as some call for in this thread (and the reddit thread).