Find more on my blog: LLVM Pass Development I: Branch-Pointer Trace
It's for LLVM 17.
Biqing Su(bsu5)
- Make the script executable by running
chmod +x setup_and_run.sh
in the terminal. - Execute the script by typing
./setup_and_run.sh
.
#include <stdio.h>
int c;
void fun(int a) {
printf("Value of a is %d\n", a);
}
int main() {
void (*fun_ptr)(int) = &fun;
(*fun_ptr)(10);
int b;
for (c = 0; c < 3; c++) {
b = c + 1;
}
return c;
}
main: func_0x147e4af98
Branch Dictionary:
br_0: test1.c, 14, 15
br_1: test1.c, 14, 18
Value of a is 10
br_0
br_0
br_0
br_1
$ mkdir build
$ cd build
$ cmake ..
$ make
$ cd ..
$ cc -c logPrint.c
$ clang -fpass-plugin='build/skeleton/SkeletonPass.dylib' -c test1.c -g
$ cc test1.o logPrint.o
$ ./a.out
- Type: small contrived program
- Code source: from project description
- Run test: execute the
setup_and_run.sh
script. - Result:
- Type: small contrived program
- Code source: generate by gpt4
- Run test: change
test1
totest2
insetup_and_run.sh
before executing the script. - Result:
- Type: real-world substitute
- Code source: Employee Management System github link
- Number of non-comment non-blank lines: 583 lines
- Changes made: added function getch; moved the main to the end.
- Run test: change
test1
totest3
insetup_and_run.sh
before executing the script. - Result: