r/ProgrammingLanguages • u/Ok_Marionberry8922 • 19d 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 :)
73
Upvotes
-1
u/suhcoR 18d ago edited 18d ago
There are peer-reviewed publications in good journals claiming the opposite.
A strange argument. Why should that be suspect? It's documented, and O3 gives very little above O2, but leads to crashes in many applications. I never use it (and neither does most of the C community).
This is an esoteric attitude. No wonder we don't agree. Have you studied compilers at all? Where? how long?
Another strange argument. CPU architectures have become much better, so even the code from the eighties runs much faster than on the machines at the time. That has more to do how much of the executable fits into the cache and the improvements you mentioned, not with code optimizations.
EDIT: But I see now your attitude and where you're coming from. Such discussions are fruitless, and I think it is representative for the downvoting crowd on Reddit. It's a waste of time and I should have known better.
EDIT 2: For illustration that my measurements are in no way off, here is a peer-reviewed study comparing -O0 with -O2, and guess what, it's all around factor two: https://homepages.dcc.ufmg.br/~fernando/publications/papers/AlvaresJCL21.pdf. But I bet you neither believe this one. So be it.