locations of loops in source files
In my pass, I'd like to know the locations of loops. For example, in a for loop, such as:
开发者_如何学编程for(int i=0; i<n; i++) { ... }
The line number of for(...) in the source file is what I am interested in. If the .bc file is generated by llvm-gcc with -O0, I can easily get this information by reading the line number of the first instruction of the loop. However, if -O3 is used, this method does not work. How can I still get the loop locations in this case?
In general you cannot, because your loop might be transformed by compiler (e.g. unrolled, reversed, etc.)
精彩评论