HACKER Q&A
📣 Alifatisk

Does all languages who target LLVM have the same traits?


I mean, since Rust is using LLVM as backend, shouldn’t that mean any language who uses LLVM should perform the same?

If not, why is that?


  👤 komon Accepted Answer ✓
The output from an LLVM frontend compiler is LLVM IR, which is sort of a high-level architecture-agnostic assembly.

The LLVM backend compiles this IR to the target architecture's machine code.

Some optimizations can (and do?) happen in the backend compiler, but for the most part it is up to the frontend to emit IR that is well optimized within the semantics of the frontend language.

The history of Rust, for example, is filled with examples of optimizations made not to the standard library, but to how the frontend emits IR.

Beyond that, different languages and ecosystems are going to have differing levels of optimization in their stdlib and runtime that will have an outsize effect on day-to-day performance.