Defer section resolution for GIMPLE wrappers.
Fixes incorrect section name handling for GIMPLE wrappers during LTO.
This change defers section resolution for GIMPLE wrappers until the cfgexpand pass. Previously, section names could become stale during LTO if IPA ICF turned equivalent functions into GIMPLE wrappers before privatization. This deferral ensures that sections are resolved based on the final assembler names, preventing issues with stale names being streamed into LTRANS. The change also updates documentation and adds new test cases.
In Details
This commit modifies the section resolution logic for GIMPLE thunks emitted via the GIMPLE path, specifically addressing issues arising during Link-Time Optimization (LTO) when Interprocedural Function Cloning (IPA ICF) is involved. It defers the call to resolve_unique_section within the GIMPLE thunk emission path to cfgexpand, ensuring that sections are resolved based on the final, potentially privatized, assembler names. This prevents stale section information from being propagated during LTRANS, which occurred when IPA ICF transformed equivalent functions into GIMPLE wrappers before sy…
- GIMPLE
- GCC's internal representation of code, used after initial parsing and before the generation of RTL. It's an intermediate representation designed to be suitable for optimizations.
- LTO
- Link-Time Optimization. A compilation process where optimization is performed not just on individual source files, but across the entire program during the linking phase. This allows for more aggressive optimizations that depend on inter-procedural analysis.
- IPA ICF
- Inter-Procedural Function Cloning. An optimization pass that duplicates identical functions to improve locality and potentially enable further optimizations. When used with LTO, it can clone functions before their final symbol names are determined.
- cfgexpand
- A GCC pass that expands control flow graphs (CFGs) and performs various code-related expansions before RTL generation.
- RTL expansion
- The process of converting GCC's GIMPLE intermediate representation into its lower-level RTL (Register Transfer Language) representation, which is closer to machine code.