Profile Guided Optimization 

Profile-guided optimization (PGO), sometimes also called feedback-driven optimization (FDO), uses additional knowledge about the real-world behavior of the program to help compilers to optimize code for the most common use cases.

This is done by providing execution profile information to the compiler. For this purpose, the program will be complied and linked using special compiler options, which will enable instrumenting the resulting binary with code, which will measure and store the profile data in a format which the compiler can understand. After the application has been run under typical load, we will gather the generated execution profile and then feed that profile back into the compiler, which recompiles the application. In that manner the application will be optimally adapted for the typical environment. 

In the course of PGO recompilation, a compiler can change inlining, replace calls to a frequently called virtual function with direct calls, optimize register allocations and the location of functions in sections, and reorder code blocks to optimize branch performance. The two last optimizations are aiming at improving code locality or, in other words, at keeping the instruction cache warm.

This method has its downsides too, namely, the high run-time overhead of profile collection (due to instrumentation) and an awkward two-stage compile model (again due to instrumentation). Besides that, it can be difficult to decide what the previously mentioned typical load is under real conditions.