Which information does GCC collect when I enable -fprofile-generate
and which optimization does in fact uses the collected information (when setting the -fprofile-use
flag) ?
I need citations here. I've searched for a while but didn't found anything documented.
Information regarding link-time optimization (LTO) would be a plus! =D
The compiler optimizes to reduce the size of the binary instead of execution speed. If you do not specify an optimization option, gcc attempts to reduce the compilation time and to make debugging always yield the result expected from reading the source code.
-O2 Optimize even more. GCC performs nearly all supported optimizations that do not involve a space-speed tradeoff. The compiler does not perform loop unrolling or function inlining when you specify -O2. As compared to -O, this option increases both compilation time and the performance of the generated code.
Profile-guided optimization (PGO) lets you optimize a whole executable file, where the optimizer uses data from test runs of the .exe or . dll file. The data represents the likely performance of the program in a production environment.
6.4 Optimization levels. In order to control compilation-time and compiler memory usage, and the trade-offs between speed and space for the resulting executable, GCC provides a range of general optimization levels, numbered from 0--3, as well as individual options for specific types of optimization.
-fprofile-generate
enables -fprofile-arcs
, -fprofile-values
and -fvpt
.
-fprofile-use
enables -fbranch-probabilities
, -fvpt
, -funroll-loops
, -fpeel-loops
and -ftracer
Source: http://gcc.gnu.org/onlinedocs/gcc-4.7.2/gcc/Optimize-Options.html#Optimize-Options
PS. Information about LTO also on that page.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With