문제

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.

도움이 되었습니까?

해결책

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.

다른 팁

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top