Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22006

Getting assember output from GCC/Clang in LTO mode

$
0
0

Normally, one can get GCC's optimized assembler output from a source file using the -S flag in GCC and Clang, as in the following example.

gcc -O3 -S -c -o foo.s foo.c

But suppose I compile all of my source files using -O3 -flto to enable link-time whole-program optimizations and want to see the final compiler-generated optimized asm for a function, and/or see where/how it got inlined.

The result of compiling is a bunch of .o files which are really IR files disguised as object files, as expected. In linking an executable or shared library, these are then smushed together, optimized as a whole, and then compiled into the target binary.

But what if I want assembly output from this procedure? That is, the assembly source that results after link-time optimizations, during the compilation of IR to assembly, and before the actual assembly and linkage into the final executable.

I tried simply adding a -S flag to the link step, but that didn't really work.

I know disassembling the executable is possible, even interleaving with source, but sometimes it's nicer to look at actual compiler-generated asm, especially with -fverbose-asm


Viewing all articles
Browse latest Browse all 22006

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>