开发者

Unrolling gcc compiler optimization

I am interested in seeing the code where gcc has actually optimized the code. Is there a way I could do?

I have gone through few other similar questoins, I have tried following few things,

  1. -W开发者_JS百科a,ahl=filename.lst :- this option is really good, you can browse the code and corresponding machine code, but it is not good when I enable O3 option.
  2. Dumping optimized tree :- I am sure gcc is giving me good amount of debug information. But I do not how to decipher it. I will be glad if someone could point to any available information.

Is there any other better way, to find out what part of the code gcc optimized?

Thanks, Madhur


You can compile the code twice, first with:

$ gcc -O0 -S -o yourfile_o0.s

Then with:

$ gcc -O3 -S -o yourfile_o3.s

Then you can diff the two resulting assembly files:

$ diff -u yourfile_o0.s yourfile_o3.s
$ vim -d yourfile_o0.s yourfile_o3.s
$ emacs --eval '(ediff "yourfile_o0.s" "yourfile_o3.s")'


Look at the assember code or decompile your compiled application. C decompilers produce ugly C code, but for analyzing which code was generated, it have to suffice.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜