This patch disables optimizations on IR Functions that are considered “cold” by PGO
profiles. The primary goal for this work is to improve code optimization
speed (which also improves compilation and LTO speed) without making too
much impact on target code performance.
The mechanism is pretty simple: In the second phase (i.e. optimization
phase) of PGO, we would add optnone attributes on functions that are
considered “cold”. That is, functions with low profiling counts.
In addition to de-optimizing on functions whose profiling counts are
exactly zero (the -profile-omit-cold-func-opt flag). If the previous CLI flag
is enabled, another knob (-profile-omit-cold-func-opt-percent=<X percent>) can
be used to adjust the “cold threshold”. That is, after sorting profiling counts
of all functions, this knob provides an option to de-optimize functions
whose count values are sitting in the lower X percent.
Our evaluation results showed an average of 10% compilation speed
improvement with up to 2% performance overhead on various of thresholds using the
LLVM Test Suite as the benchmark. Using with FullLTO, it brought average
of 20% (LTO) link time improvement with up to 2% performance overhead.
Second part of this patch series: https://reviews.llvm.org/D87338
authors: myhsu, probinson, and edd