GSoC: possible IPA-ICF project direction
GSoC student explores IPA-ICF with separate function bodies, finding issues with inlining and non-null promises.
A GSoC student is investigating a project direction for IPA-ICF (Interprocedural Analysis - Identical Code Folding), focusing on the use of separate function bodies. Initial experiments with test cases for PR119006 and PR123227 reveal issues related to incorrect code generation when function bodies are inlined and problems with non-null promises. The student also observed differences in behavior with GNU extern inline and plans further investigation into IPA-cloning and ICF’s handling of losing bodies.
- proposer
Reports findings from experiments with separate function bodies for IPA-ICF, highlighting incorrect code generation for PR119006 when leaders are inlined and issues with non-null promises for PR123227.
“For PR119006, the current merge is safe when the leader's out-of-line body is not inlined, but inlining the leader into the other caller produces the wrong code. Defining the two structs in the opposite order swaps the leader and makes the failure disappear. I also emulated your model by making both functions always_inline, putting them in an anonymous namespace so the originals get inlined into…”
- reviewer
Acknowledged the findings and noted the specifics of PR119006.
“On Tue, 15 Sep 2026, Rohith Kapelli wrote: > Hi Richard, > > I looked into the separate-body idea using reduced testcases for > PR119006 and PR123227, using trunk from 3 September, before the PR119006 > and PR123227 fixes. > > For PR119006, the current merge is safe when the leader's out-of-line > body is not inlined, but inlining the leader into the other caller > produces the wrong code. D…”
Technical Tradeoffs
- Potential for code size reduction through improved ICF.
- Risk of incorrect code generation if separate bodies or inlining are handled improperly.
- Complexity in managing function visibility and linkage across compilation units.
In Details
This GSoC project explores a new direction for GCC's Identical Code Folding (ICF) pass, specifically focusing on how it interacts with Interprocedural Analysis (IPA). The student is testing a "separate-body" approach, where function definitions might be placed in distinct compilation units or sections, and examining its impact on ICF's ability to merge identical code. The discussion details issues encountered with specific PRs (119006, 123227) related to inlining, non-null pointer promises, and the interaction with GNU extern inline semantics.
- IPA
- Interprocedural Analysis, a compiler analysis technique that examines function calls and data flow across entire program execution, not just within a single function.
- ICF
- Identical Code Folding, a compiler optimization pass that identifies and merges identical functions or code blocks to reduce executable size.
- GSoC
- Google Summer of Code, an annual program where Google funds student contributions to open-source projects.
- PR
- Problem Report, a bug report filed in a project's issue tracking system.
- non-null promise
- An assumption or guarantee made by code that a pointer will not be null, which can be exploited by optimizations but may lead to issues if violated.
- extern inline
- A C language specifier that affects how functions defined with
inlineare treated, particularly concerning linkage and visibility across translation units.