Knuth [] argued for profile-driven optimization by compilers
back in 1971. Wall [] summarized some investigation of how
well estimated and real profiles predicted program performance
characteristics across multiple runs with different input data; this
work is sometimes interpreted as negative support for profile-driven
optimization, since it indicated that actual profiles from actual runs
were nowhere near perfect predictors of other profiles of actual runs.
Nevertheless, numerous commercial C compilers (Digital, SGI -- MIPS
architecture; Digital -- Alpha; Hewlett-Packard -- PA-RISC; IBM --
POWER2; Convex) today do have options in their compilers to accept
profiling feedback information (basic block and function invocation
frequencies) during the compilation and link stages. However, it appears that
such information is being used primarily in the code generation phase,
for such purposes as improving accuracy of conditional branch
predictions to generate conditional branch opcodes with the the
correct direction ``hint'', and global register allocation. These
compilers do not perform high-level code transformations, nor do the
compilers actively experiment to see what output code perform best.
See [,,].
A fair amount of work has been done on profile-driven optimizations such as selective inlining and efficient polymorphic method dispatch, focused mostly on research functional languages. See [,,]. By comparison, relatively little work has been done with general frameworks for profiling-driven optimizations of programs written in C, at levels other than the code generation pass. However, some specific work on inlining and types selection exists. See [,].
Dynamic code generation (DCG) is another approach to compiling code based on actual usage. One disadvantage of DCG is that the cost of compilation is paid possibly multiple times every single program run; hence, the full suite of standard optimizations are usually not applied. In the clever compiler framework, the costs of compilation may be amortized over multiple program runs, and eventually the frequency of recompilation may be slowly reduced. One major advantage of DCG is that incorporating code generation into the program executable allows it to re-adapt for changing usage patterns on a much finer timescale than is possible with a clever compiler. See [].