Criteria for Inline Function Expansion

For a call to be considered for inlining, it has to meet certain minimum criteria. There are three main components of a call:

The following table details the  minimum criteria for each component:

Component

Minimum criteria

Call-site

The number of actual arguments must match the number of formal arguments of the callee.

The number of return values must match the number of return values of the callee.

The data types of the actual and formal arguments must be compatible.

No multilingual inlining is permitted. Caller and callee must be written in the same source language.

Caller

At most, 2000 intermediate statements will be inlined into the caller from all the call-sites being inlined into the caller.

The function must be called if it is declared as static. Otherwise, it will be deleted.

Callee

Does not have variable argument list.

Is not considered unsafe for other reasons.

Is not considered infrequent due to the name. Routines which contain the following substrings in their names are not inlined: abort, alloca, denied, err, exit, fail, fatal, fault, halt, init, interrupt, invalid, quit, rare, stop, timeout, trace, trap, and warn.

Selecting Routines for Inlining

If the minimum criteria identified are met, the compiler picks the routines whose inline expansions will provide the greatest benefit to program performance. This is done using the default heuristics. The inlining heuristics used by the compiler differ based on whether you use profile-guided optimizations, -prof-use (Linux*) or /Qprof-use (Windows*), or not.

When you use profile-guided optimizations with -ip or -ipo (Linux) or /Qip or /Qipo (Windows), the compiler uses the following heuristics:

Platform

Command

Linux

-Qoption,c,-ip_ninl_max_stats=n

Windows

/Qoption,c,-ip_ninl_max_stats=n

where n is a new value.

Note

There is a higher limit for functions declared by the user as inline or __inline.

See Using Qoption Specifiers and Profile-Guided Optimization Overview.

When you do not use profile-guided optimizations with -ip or -ipo (Linux) or /Qip or /Qipo (Windows), the compiler uses less aggressive inlining heuristics: it inlines a function if the inline expansion does not increase the size of the final program.

Inlining (Linux*)

If you do not use profile-guided optimizations with -ip or -ipo, the compiler uses less aggressive inlining heuristics:

PGO (Windows*)

The compiler uses characteristics of the source code to estimate which function calls are executed most frequently. It applies these estimates to the PGO-based heuristics described previously. The estimation of frequency, based on static characteristics of the source, is not always accurate. Hence, use of /Qip and /Qipo without PGO can result in longer compilation times and even slower application execution.