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.

You can change this value by specifying the option:

-Qoption,f,-ip_ninl_max_total_stats=n

/Qoption,f,-ip_ninl_max_total_stats=n

where n is a new value.

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,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 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 and Preemption (Linux*)

Preemption of a function means that the code, which 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 is on, any externally visible function might be preempted and therefore cannot be inlined. Currently, this means that all Fortran subprograms, except for internal procedures, are not inlinable when -ip is on. However, if you use -ipo on a file-by-file basis, the functions can be inlined.