In this recipe, we will take a brief look into the other analysis passes that are provided by LLVM and can be used to get analysis information about a basic block, function, module, and so on. We will look into passes that have already been implemented in LLVM, and how we can use them for our purpose. We will not go through all the passes but take a look at only some of them.
Write the test code in the testcode1.c
file, which will be used for analysis purposes:
$ cat testcode1.c void func() { int i; char C[2]; char A[10]; for(i = 0; i != 10; ++i) { ((short*)C)[0] = A[i]; C[1] = A[9-i]; } }
Convert the C code to bitcode format, using the following command line:
$ clang -c -emit-llvm testcode1.c -o testcode1.bc