May 2015
Intermediate to advanced
296 pages
5h 10m
English
The pass written in the previous recipe, Writing your own LLVM pass, is ready to be run on the LLVM IR. This pass needs to be loaded dynamically for the opt tool to recognize and execute it.
Do the following steps:
sample.c file, which we will convert into an .ll file in the next step:$ vi sample.c
int foo(int n, int m) {
int sum = 0;
int c0;
for (c0 = n; c0 > 0; c0--) {
int c1 = m;
for (; c1 > 0; c1--) {
sum += c0 > c1 ? 1 : 0;
}
}
return sum;
}
$ clang –O0 –S –emit-llvm sample.c –o sample.ll
This will generate a sample.ll file.
$ opt -load (path_to_.so_file)/FuncBlockCount.so ...
Read now
Unlock full access