How LLVM changed the world ?
LLVM stands for Low Level Virtual Machine developed by Chris Lattner and Vikram Adve as their Post Doctorate Project. It is simply a library written in C++ used to create compilers.
If you want to create your own compiled programming language which is portable and highly optimized, and you don’t have deep knowledge of how to convert your source code into the assembly code, then LLVM is there. You just have to convert your source code to IR (Intermediate Representation).
Let's take a C++ code to add two number.
void add(int x, int b){
return x+b;
}
Now, we will convert the above C++ code to IR.
define i32 @add(i32 %x, i32 %b) {
entry:
%addition = add i32 %x, %b
ret i32 %addition
}
After the source code is converted to IR. Your work is done here. Now, LLVM will perform some runs like:
Removing the dead code.
Inlining small functions to reduce overhead.
Converting the mathematical expression to postfix and solve them as much as it can be.
Data flow analysis to optimize memory accesses, identify opportunities for memory aliasing, and eliminate redundant memory operations.
and converts the code to machine code according to your chosen architecture.
LLVM supports code generation for over 60 target architectures, including popular architectures like x86, ARM, MIPS, PowerPC, RISC-V, and many others.
Due to its amazing features and reliability, LLVM became so popular among the Compiler designers. Till today 2024, LLVM is still getting its updates which made it the best Compiler Infrastructure technologies ever made.
⭐ Many famous and revolutionary programming languages are using LLVM for its working like :
Rust
Swift
Haskell
Objective-C
Crystal
Julia
C/C++(Clang compiler)
The above-mentioned programming languages are used in most used products of the globe like Swift is used in all Apple products, Rust is used in high performance and secure systems etc. C and C++ are everywhere.
This is how LLVM Changed the whole world!
So, if you find this Article Knowledgeable, then do subscribe to this SubStack.
Author: Saksham Joshi [Linkedin]