Italian C++ Conference 2019
Link Time Optimization (LTO) and Profile Guided Optimization (PGO) are two complementary techniques for improving the performance of C++ code beyond what’s normally achieved by optimizing compilers. In most projects, optimization and inlining opportunities are limited because C++ inherits the concept of independent translation units from C. LTO sidesteps this issue by deferring emission of the final binary code to the linker. After turning on LTO, Firefox saw 5% and up improvements in some benchmarks. PGO uses profiling data collected at runtime to optimize decisions made by the compiler, like branch predictions and code placement. This talk will explore LTO and PGO as implemented by clang. We’ll show how to enable these features in an example project, and dissect the generated code to understand how they work.