如果用 -g 调试选项进行编译,可使用 er_src(1) 公用程序(Sun Studio 性能分析工具的一部分)来查看编译器生成的源代码注释。该公用程序还用来查看用所生成的汇编语言注释的源代码。下面例举了 er_src 对一个简单的 do 循环产生的注释:
demo% f95 -c -g -O4 do.f demo% er_src do.o Source file: /home/user21/do.f Object file: do.o Load Object: do.o 1. program do 2. common aa(100),bb(100) Function x inlined from source file do.f into the code for the following line Loop below pipelined with steady-state cycle count = 3 before unrolling Loop below unrolled 5 times Loop below has 2 loads, 1 stores, 0 prefetches, 1 FPadds, 1 FPmuls, and 0 FPdivs per iteration 3. call x(aa,bb,100) 4. end 5. subroutine x(a,b,n) 6. real a(n), b(n) 7. v = 5. 8. w = 10. Loop below pipelined with steady-state cycle count = 3 before unrolling Loop below unrolled 5 times Loop below has 2 loads, 1 stores, 0 prefetches, 1 FPadds, 1 FPmuls, and 0 FPdivs per iteration 9. do 1 i=1,n 10. 1 a(i) = a(i)+v*b(i) 11. return 12. end |
注释消息详细说明编译器所采取的优化操作。在例中可以看到:编译器内联了子例程调用并将循环展开了 5 次。仔细查看该信息可能会为进一步使用优化策略提供线索。
有关编译器注释和反汇编代码的详细信息,参见 Sun Studio《性能分析器》手册。