[Paper Review] Optimizing real world applications with GCC Link Time Optimization
This paper presents WHOPR, a link-time optimization (LTO) infrastructure in GCC that enables whole-program inter-procedural optimization by storing intermediate representation (IR) in object files and deferring optimization to link time. It demonstrates that LTO improves code quality and performance—especially with aggressive inlining and profile-guided tuning—while identifying key challenges in debug info, memory usage, and binary portability.
GCC has a new infrastructure to support a link time optimization (LTO). The infrastructure is designed to allow linking of large applications using a special mode (WHOPR) which support parallelization of the compilation process. In this paper we present overview of the design and implementation of WHOPR and present test results of its behavior when optimizing large applications. We give numbers on compile time, memory usage and code quality comparisons to the classical file by file based optimization model. In particular we focus on Firefox web browser. We show main problems seen only when compiling a large application, such as startup time and code size growth.
Motivation & Objective
- To design and implement a scalable, parallelizable link-time optimization infrastructure (WHOPR) in GCC that supports large-scale applications.
- To address limitations of file-by-file compilation, such as suboptimal inter-procedural optimization and missed global code transformations.
- To evaluate the impact of LTO on real-world applications like Firefox and GCC, focusing on compile time, memory usage, code size, and runtime performance.
- To identify and address key deficiencies in LTO support, including missing debug information, lack of standardized IR format, and toolchain compatibility issues.
Proposed method
- Extends GCC's middle-end to stream intermediate representation (IR) to disk in standard object files (ELF) with custom sections (e.g., .gnu.lto.opts, .gnu.lto.symtab).
- Introduces a linker plugin (integrated with Gold) that invokes the LTO front-end during linking, enabling whole-program optimization.
- Uses a WHOPR mode to parallelize compilation by decoupling inter-procedural analysis from local code generation, enabling distributed and incremental compilation.
- Employs a symbol table and type/declaration merging system to manage cross-unit optimization and avoid symbol mismatches between IR and final assembly.
- Applies inter-procedural optimization passes (e.g., devirtualization, function specialization, inlining) using a callgraph and varpool data structure.
- Combines LTO with profile feedback to guide optimization decisions, improving inlining quality and code layout.
Experimental results
Research questions
- RQ1How does link-time optimization with WHOPR improve code quality and performance in large C/C++ applications like Firefox and GCC?
- RQ2What are the performance and resource trade-offs (compile time, memory usage) of LTO compared to traditional file-by-file compilation?
- RQ3What are the key limitations of LTO in real-world deployment, particularly regarding debug information and binary compatibility?
- RQ4To what extent can profile-guided optimization enhance the benefits of LTO in practice?
- RQ5How can incremental and distributed compilation be supported within the LTO framework to improve scalability?
Key findings
- LTO improves GCC performance by 4% when enabling aggressive inlining with a 5% code size growth limit, demonstrating the benefit of global optimization scope.
- Runtime performance improvements for Firefox and GCC were less than 1% under default settings, indicating that prior hand-tuning for single-file compilation limits immediate gains.
- Debug information support in LTO was severely limited at the time of writing, with compiler crashes occurring during Firefox builds when enabled.
- The on-disk IR representation is not standardized, requiring full recompilation when compiler or options change, limiting library distribution and reuse.
- Memory usage in LTO is comparable to other compilers like MSVC, but can be reduced by minimizing the number of streamed declarations and types.
- WHOPR enables parallel and distributed compilation, but scaling beyond 24 parallel jobs offers diminishing returns due to the serial WPA phase dominating compilation time.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.