In this question I will focus on Visual Studio 2012 and GCC 4.7
On the one hand, profile-guided compilation optimizes branch prediction by instrumenting the code at run-time, and then using this information during a second compilation. On the other hand, many compilers provide extensions to hint to the compiler which branch will most-likely be taken: GCC provides __builtin_expect
and Visual Studio provides __assume
.
Is there a way to extract the profile-guided information (of either compiler) so as to be able to rewrite the code using both compiler extensions? The goal would be to provide an "optimized" source code for people willing to recompile their own version of the binary.