Pregunta

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.

¿Fue útil?

Solución

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.

Otros consejos

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

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top