Environment Setting

LLVM+Clang Download

Add LLVM path

After building the LLVM source code or downloading the prebuild, you should add the path of bin dir in build dir you created for the build or the prebuild your loaded. The bin dir contains the libraries you need for writing pass.

In Ubuntu or Mac OS, you can add the LLVM bin path to ~/.bashrc if you like. Attention the appending order of the LLVM path in $PATH

Testing installation

BC generation by Clang

Write passes

CMakeList Configuration

The key difficulty of writing the pass is the configuration of CMakeLists.txt. In the CMake Project of LLVM pass, you need to use find_package(LLVM REQUIRED CONFIG) in your CMakeLists.txt so that the LLVM lib(located in the bin directory of LLVM-config