LLVM IR ModulePass testbed with zero boilerplate coding. Tested with LLVM 15. It probably also works with later versions unless they drastically change their APIs (again).
- LLVM 15+ (either system-wide, source-code built, or pre-built)
- CMake 3.22.1+ (moderately lower versions may work, too)
- Download a pre-built LLVM, unpack it, and add a path to LLVM.
$ export PATH=<path/to/llvm/bin/dir>:$PATH # Ignore this if you already have LLVM.
- Clone the repository.
$ git clone git@github.com:gwangmu/IRTestbed.git
$ cd IRTestbed
- Make.
$ make
- Check
buildfor built binaries (tb-clang/tb-clang++).
- Implement a module pass in
testbed.cpp::IRTestbed::run(). - Make again.
- Use
tb-clangandtb-clang++inbuildas C/C++ compilers.- The module pass is applied to compiled C/C++ source code.
- Can I move
tb-clang/tb-clang++to another directory?- No, unfortunately, but you can always make symbolic links to them or add a
path to
buildto thePATHenvironment variable.
- No, unfortunately, but you can always make symbolic links to them or add a
path to
- (Obviously) ready-to-use LLVM IR pass testbed.
- How to build an LLVM plugin with CMake. (-> CMakeFiles.txt)
- How to write a compiler wrapper with C. (-> wrapper.cpp)