Clone LLVM repository:
git clone https://github.com/llvm/llvm-project.git
CHCTransform.h
into llvm-project/llvm/include/llvm/Transforms/Utils/
repositoryCHCTransform.cpp
into llvm-project/llvm/lib/Transforms/Utils/
repositoryllvm-project/llvm/lib/Passes/PassBuilder.cpp
add new line #include "llvm/Transforms/Utils/CHCTransform.h"
llvm-project/llvm/lib/Passes/PassRegistry.def
add new line FUNCTION_PASS("chc-transform", CHCTransformPass())
Into file llvm-project/llvm/lib/Transforms/Utils/CMakeLists.txt
add CHCTransform.cpp
1. cmake -S llvm-project\llvm -B build -DLLVM_ENABLE_PROJECTS=clang -DLLVM_TARGETS_TO_BUILD=X86 -Thost=x64 -DLLVM_ENABLE_EH=true -DLLVM_ENABLE_RTTI=true -G "Ninja"
2. cmake --build build --target clang
3. cmake --build build --target opt
https://llvm.org/docs/GettingStarted.html#getting-the-source-code-and-building-llvm
clang++ -Xclang -disable-O0-optnone -S -emit-llvm {source code} -o {output file}
opt -S {output file from previous command} -passes=mem2reg -o {output file}
opt -disable-output {output file from previous command} -passes=chc-transform
For example, source code file example.cpp :
clang++ -Xclang -disable-O0-optnone -S -emit-llvm example.cpp -o example.ll
opt -passes=mem2reg -S example.ll -o example.ll
opt -disable-output example.ll -passes=chc-transform >> example.smt
chc-transform.sh
./chc-transform.sh example.cpp tmp
tool.sh
./tool.sh example.cpp
test-bench.sh
./test-bench.sh sv-benchmarks/c/loops/*.yml 100
test-set.sh
./test-set.sh sv-benchmarks/c/ReachSafety-Loops.set 100
To properly run the script you to build or download software