开发者

locations of loops in source files

开发者 https://www.devze.com 2023-02-28 04:51 出处:网络
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++) { ... }

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.)

0

精彩评论

暂无评论...
验证码 换一张
取 消