May 2015
Intermediate to advanced
296 pages
5h 10m
English
The analysis pass provides higher-level information about IR without actually changing the IR. The results that the analysis pass provides can be used by another analysis pass to compute its result. Also, once an analysis pass calculates the result, its result can be used several times by different passes until the IR on which this pass was run is changed. In this recipe, we will write an analysis pass that counts and outputs the number of opcodes used in a function.
First of all, we write the test code on which we will be running our pass:
$ cat testcode.c int func(int a, int b){ int sum = 0; int iter; for (iter = 0; iter < a; iter++) { int iter1; for (iter1 = 0; iter1 < b; iter1++) { sum += iter > iter1 ? ...Read now
Unlock full access