- LLVM version:
9.0.0svn
; - CMake version:
3.13.4
;
- The
Range Analysis
was modified for the LLVM9.0.0
; - The
Profile Class
was reimplemented and it's working correctly, printing the running times in seconds; - The
Range Analysis
andvSSA
passes are now separated.
export LLVM_DIR=<path to llvm build>
cd <printer base dir>
mkdir build
cd build
cmake ..
make
To add the Pass to the llvm compilation tree:
cp -r VSSA <path to llvm source>/llvm/lib/Transforms/
cp -r RangeAnalysis <path to llvm source>/llvm/lib/Transforms/
cp -r DeadCodeElimination <path to llvm source>/llvm/lib/Transforms/
- Add
add_subdirectory(VSSA)
to<path to llvm source>/llvm/lib/Transforms/CMakeLists.txt
- Add
add_subdirectory(RangeAnalysis)
to<path to llvm source>/llvm/lib/Transforms/CMakeLists.txt
- Add
add_subdirectory(DeadCodeElimination)
to<path to llvm source>/llvm/lib/Transforms/CMakeLists.txt
Remove MODULE
, PLUGIN_TOOL
and the opt
line from the CMakeList.txt in each of the copied dirs. Then, we can compile the llvm normally (now with our pass included):
cd <path to llvm source>
mkdir build
cd build
cmake .. -G "Unix Makefiles"
make
First, we need to create the intermediate representation of the program:
clang <input>.c -o <output_1>.bc -c -emit-llvm -O0
opt -instnamer -mem2reg -break-crit-edges <output_1>.bc -o <output_2>.rbc
opt -load <build>/VSSA/LLVMVSSA.so -vssa <output_2>.rbc -o <output_3>.vssa.rbc
opt -load <build>/DeadCodeElimination/LLVMDeadCodeElimination.so -ra-dce <output_3>.vssa.rbc -o <output_4>.dce.rbc
opt -vssa <output_2>.rbc -o <output_3>.vssa.rbc
opt -ra-dce <output_3>.vssa.rbc -o <output_4>.dce.rbc
I have some scripts to help execution in the Tests
folder:
run_DCE.sh
: Run the DCE for an .c file as argument;test.sh
: Run the DCE for all tests inTests
folder;show.sh
: Usedot
to show a .dot file to pdf (may not be compatible);
Just rewrite the variables CLANG
, OPT
and BUILD_DIR
to your configuration.