每次 GCC 进行优化后获取汇编代码? [英] Get Assembly code after every optimization GCC makes?
问题描述
来自维基百科上的优化编译器,
编译器优化通常使用优化转换序列实现,这些算法采用程序并对其进行转换,以生成使用较少资源的语义等效输出程序.
Compiler optimization is generally implemented using a sequence of optimizing transformations, algorithms which take a program and transform it to produce a semantically equivalent output program that uses fewer resources.
而且 GCC 有 很多 优化选项.
and GCC has a lot of optimization options.
我想研究在使用 -O1
、 等不同标志编译时 GCC 执行的每次优化后生成的程序集(
、-S
给出的程序集)-O2-O3
等
I'd like to study the generated assembly (the one -S
gives) after each optimization GCC performs when compiling with different flags like -O1
, -O2
, -O3
, etc.
我该怎么做?
我的输入将是 C 代码.
My input will be C code.
推荐答案
中间表示可以使用 -fdump-tree-all
开关保存到文件中.
Intermediate representation can be saved to files using -fdump-tree-all
switch.
有更多细粒度的 -fdump
开关可用.
There are more fine-grained -fdump
switches awailable.
详见 gcc 手册.
为了能够阅读这些表示,查看 GCC 内部手册.
To be able to read these representations, take a look into GCC internals manual.
这篇关于每次 GCC 进行优化后获取汇编代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!