learnbyexample@programming.dev to Programming@programming.devEnglish · 1 day agoCommon Misconceptions about Compilerssbaziotis.comexternal-linkmessage-square6fedilinkarrow-up139arrow-down10cross-posted to: hackernews
arrow-up139arrow-down1external-linkCommon Misconceptions about Compilerssbaziotis.comlearnbyexample@programming.dev to Programming@programming.devEnglish · 1 day agomessage-square6fedilinkcross-posted to: hackernews
minus-squareTramort@programming.devlinkfedilinkarrow-up8·edit-21 day agoNow, because this article got a little long, as per a friend’s suggestion, here’s a table of contents: Optimization gives us optimal programs Branch weights and the CPU’s branch predictor -O3 produces much faster code than -O2 Javascript interpreters JIT at runtime because they don’t know which paths are hot ahead of time If you have a compiler, you don’t need an interpreter The middle-end is target/platform-independent The compiler optimizes for data locality -O0 gives you fast compilation Templates are slow to compile Separate compilation is always worth it Why does link-time optimization (LTO) happen at link-time? Inlining is useful primarily because it eliminates a call instruction The role of the inline keyword The best production compiler to study is LLVM Undefined behavior only enables optimizations The compiler can “simply” define undefined behavior 99% correctness rate is ok
Now, because this article got a little long, as per a friend’s suggestion, here’s a table of contents:
Optimization gives us optimal programs
Branch weights and the CPU’s branch predictor
-O3 produces much faster code than -O2
Javascript interpreters JIT at runtime because they don’t know which paths are hot ahead of time
If you have a compiler, you don’t need an interpreter
The middle-end is target/platform-independent
The compiler optimizes for data locality
-O0 gives you fast compilation
Templates are slow to compile
Separate compilation is always worth it
Why does link-time optimization (LTO) happen at link-time?
Inlining is useful primarily because it eliminates a call instruction
The role of the inline keyword
The best production compiler to study is LLVM
Undefined behavior only enables optimizations
The compiler can “simply” define undefined behavior 99% correctness rate is ok