GCC Newspaper
NOVEMBER 30, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
ipa-inline

Credit aggregate copies into return slot as eliminated by inlining

Inliner now correctly accounts for aggregate copies to return values when source is a removable local variable.

The early inliner in GCC previously charged an aggregate copy to the return value even if its source was a local variable that could be eliminated after inlining. This change credits such copies as eliminated, preventing unnecessary memory operations for value-type wrappers and improving inlining efficiency. It handles both explicit return value assignments and implicit invisible-reference returns, while still excluding volatile accesses and copies from global/static variables.

In Details

The ipa-fnsummary.cc function eliminated_by_inlining_prob was enhanced to correctly assess the cost of aggregate return values. It now recognizes that aggregate copies from automatic local variables or parameters (whose addresses are not taken) to the return slot can be eliminated by inlining, similar to scalar values. This avoids overcharging the inlining cost for value-type wrappers and improves the effectiveness of early inlining, especially when combined with SRA.

For Context
IPA
IPA stands for Interprocedural Analysis. It refers to compiler analyses and optimizations that consider information from multiple functions or across the entire program, rather than just a single function in isolation.
inliner
An inliner is a compiler optimization pass that replaces calls to a function with the actual body of that function. This can reduce function call overhead and expose more opportunities for optimization.
SRA
Scalar Replacement of Aggregates (SRA) is an optimization that replaces components of an aggregate data type (like a struct or array) with individual scalar variables. This can enable further optimizations on these components.
return slot
The 'return slot' refers to the memory location or mechanism used by the compiler to pass a return value from a function back to its caller. For aggregate types, this often involves passing a pointer to a memory location where the caller expects the result.
invisible-reference result
In some calling conventions, particularly for C++, aggregate return values are passed by invisible reference. This means the compiler implicitly allocates space for the return value in the caller's scope and passes a pointer to it to the function, which then 'returns' the value by writing to that location.
Filed Under: optimizationinliningIPA