Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I get a log of optimizations applied by the compiler? [duplicate]

When compiling a C++ application or library with optimizations turned on, like -O3 for gcc, is there a way to get the applied optimizations listed? I mean, without comparing the actual byte code. This would be interesting to learn.

like image 329
danijar Avatar asked Mar 24 '14 10:03

danijar


2 Answers

From

http://gcc.gnu.org/onlinedocs/gcc/Debugging-Options.html

the -fopt-info family of switches causes the optimizer to dump out information to stderr (or a file if you prefer). In particular, -fopt-info-missed can be useful to see why an optimisation could not be applied.

There are quite a few different combinations available. From the linked page:

For example,

          gcc -O3 -fopt-info-missed=missed.all

outputs missed optimization report from all the passes into missed.all.

As another example,

  gcc -O3 -fopt-info-inline-optimized-missed=inline.txt

will output information about missed optimizations as well as optimized locations from all the inlining passes into inline.txt.

like image 155
Tristan Brindle Avatar answered Nov 04 '22 18:11

Tristan Brindle


If you're really looking for which flags are applied for a given optimization level, just look it up in the manual pages: http://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html

like image 1
blockchaindev Avatar answered Nov 04 '22 18:11

blockchaindev