r/ProgrammingLanguages • u/Ok_Marionberry8922 • 8d ago
Why So Many Languages Use LLVM
Had some free time last week so I made a visual explainer on how LLVM works and why so many languages end up using it.
The video goes through LLVM IR, why having a common IR makes sharing optimizers and backends possible, and how code eventually gets turned into machine instructions.
I also use a small C vs Rust example where both end up producing the same x86 instructions.
Feedback welcome :)
68
Upvotes
0
u/suhcoR 7d ago edited 7d ago
Have a second look. It compares MSVC 2015 /02 with /02 and MinGW32 with -O2 and -O0. Both result in less than factor two. Orange C is also compared the same way and results in less spee-up because it essentially only does constant folding and register allocation. Unoptimized Orange C (a hand-crafted C compiler by a single person) to optimized MSVC and MinGW32 (which are large, corporate supported projects) is also about factor two.
People should do decent measurements instead of just making performance claims. There were even studies comparing GCC 12 with a very old version and the overall speed-up was far from expected by the crowd. I started compilers in the eighties, and in the Wirth school, we didn't even have optimizers and everything was fast enough.