Awesome
LLVM-Examples
LLVM Examples and Code samples. LLVM Passes. Based on llvm-project
Clone the LLVM Repository in the $HOME
directory or change the paths
in the MAKEFILEs to point to the build directory of the LLVM
.
# Clone
$ git clone https://github.com/llvm/llvm-project.git
# Change directory
$ cd llvm-project
# Install the essential packages with make and cmake.
$ sudo apt-get install make ninja-build cmake cmake-data binutils build-essentials python3 python3-pip
# llvm cmake command
$ cmake \
-S llvm -B build -Wno-dev -GNinja \
-DCMAKE_INSTALL_PREFIX=/usr \
-DLLVM_ENABLE_PROJECTS="llvm;compiler-rt;clang;clang-tools-extra;lldb;lld;mlir" \
-DLLVM_BUILD_RUNTIMES="libcxx;libcxxabi" \
-DLLVM_BINUTILS_INCDIR=$HOME/binutils/include \
-DCMAKE_BUILD_TYPE=Release \
-DLLVM_ENABLE_RTTI=ON \
-DLLVM_ENABLE_FFI=ON \
-DLLVM_BUILD_TESTS=ON \
-DLLVM_INSTALL_UTILS=ON
$ cd build && ninja -j10 all
Installing from Docker
Check build
commands in the Dockerfile
for more information
on installing LLVM
on local machine.
$ docker build -f DockerFile -t prodrelworks/llvm-examples:latest .
$ docker run --name llvm-examples --ulimit stack=10000000:10000000 \
--cpus=4 --memory=20g -it prodrelworks/llvm-examples:latest
Running Examples.
$ cd NewPMExample
$ make clean
$ make all
Examples & Implementations :
- Source Level Debugging
- llvm::LoopInfo in the runOnModule
- Analysing CFGs with LLVM
- A tutorial on how to write a compiler using LLVM
References & Links :
-
Legacy Pass Example : See
folder
. -
New LLVM Pass Manager :
-
For function paraments as operands, you can get it get it via Function Argumentslist()
-
Some other differences are listed here. Even C++ one is quadratic probed.
-
Where is "emit-llvm"? ASMWritter
AsmWritter.cpp
. -
LLVM Data Structures
: -
LLVM RTTI
: -
Inspection & Traversal over
CFG
inIR
: