Get Assembly code after every optimization GCC makes?

前端 未结 7 2049
不知归路
不知归路 2020-12-19 00:19

From Optimization Compiler on Wikipedia,

Compiler optimization is generally implemented using a sequence of optimizing transformations

相关标签:
7条回答
  • 2020-12-19 01:19

    gcc -S (Capital S)

    gives asm output, but the assembler can change things so I prefer to just make an object

    gcc -c -o myfile.o myfile.c

    then disassemble

    objdump -D myfile.o

    Understand that this is not linked so external branch destinations and other external addresses will have a placeholder instead of a real number. If you want to see the optimizations compile with no optimizations (-O0) then compile with -O1 then -O2 and -O3 and see what if anything changes. There are other optimzation flags as well you can play with. To see the difference you need to compile with and without the flags and compare the differences yourself.

    diff won't work, you will see why (register allocation changes).

    0 讨论(0)
提交回复
热议问题