This pass is designed to inspects Loop in a Function and count the number of sub-block .
mkdir build && cd build
cmake ../
make
1- generate bytecode from source file
clang -emit-llvm test.c -c -o test.bc
2- run the pass on it
opt -load-pass-plugin=./build/LLVMPassCountLoop/libCountLoopPass.so -passes="countloop-pass" -S test.bc -o=test.ll
- Source file :
#include <stdio.h>
int main() {
int t=0;
for(int i=0;i<10;i++) {
for(int j=0;j<6;j++) {
t++;
}
}
for(int i=0;i<4;i++) {
t++;
}
printf("%d\n",t);
}
Function : main
LoopLevel : 0 Block : 7
LoopLevel : 1 Block : 3
LoopLevel : 0 Block : 3