Criteria for Inline Function Expansion

While function inlining (function expansion) increases execution time by removing the runtime overhead of function calls, inlining can, in many cases, increase code size, code complexity, and compile times.

In the Intel compiler, inline function expansion typically favors relatively small user functions over functions that are relatively large; however, the compiler can inline functions only if the conditions in the three main components match the conditions listed below:

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 or not you use Profile-Guided Optimizations (PGO): -prof-use (Linux*) or /Qprof-use (Windows*).

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

Platform

Command

Linux

-Qoption,f,-ip_ninl_max_stats=n

Windows

/Qoption,f,-ip_ninl_max_stats=n

where n is a new value.

See Using Qoption Specifiers and Profile-Guided Optimization Overview.

When you do not use PGO 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.

The compiler offers some alternatives to using the Qoption specifiers; see Developer Directed Inline Expansion of User Functions for a summary.

Inlining and Preemption (Linux*)

Function preemption means the code that implements that function at run-time is replaced by different code. When a function is preempted, the new version of this function is executed rather than the old version. Preemption can be used to replace an erroneous or inferior version of a function with a correct or improved version.

The compiler assumes that when -ip (Linux) or /Qip (Windows) is specified, any function with symbol visibility attribute EXTERN can be preempted, and cannot be inlined; however, by default the compiler assigns the visibility attribute PROTECTED, which prevents preemption and permits inlining.

See Symbol Visibility Attribute Options.