The given code is a skeleton of a llvm pass using llvm-8 on cycle machine.
- Add LLVM binaries to your path (optional)
# Add in your .bash_profile or other shell config
export PATH=/localdisk/cs255/llvm-project/bin:$PATH
- Add
LLVM_HOME
in your environment:
export LLVM_HOME=/localdisk/cs255/llvm-project
- Use CMake and Make to compile your pass to runtime lib
mkdir build
cd build
cmake ..
make
- Use your pass
- One liner:
clang -Xclang -load -Xclang build/skeleton/libSkeletonPass.so test.cpp
- Inside the
test/Makefile
, you can find out the way that useopt
to use your own pass.
-
To do dependence testing, your first step is to find loops in the program.
- Check how to use other llvm pass in your own pass
- http://llvm.org/doxygen/classllvm_1_1Loop.html
- https://llvm.org/doxygen/classllvm_1_1LoopInfo.html
-
Get induction variables in the loops you found.
- Check how to use ScalarEvolution pass and how other llvm pass like indvars (Induction Variable Simplify) use it
- http://llvm.org/doxygen/classllvm_1_1ScalarEvolution.html#a30bd18ac905eacf3601bc6a553a9ff49