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:

Call-site is the site of the call to the function that might be inlined.

Caller is the function that contains the call-site.

Callee is the function being called that might be inlined.

Minimum call-site criteria:

Minimum criteria for the caller:

-Qoption,f,-ip_ninl_max_total_stats=new value

Minimum criteria for the callee:

Selecting Routines for Inlining with or without PGO

Once the above criteria 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) or not.

When you use profile-guided optimizations with -ip or -ipo, the compiler uses the following heuristics:

- Default for ItaniumŪ-based applications: ip_ninl_min_stats = 15.

- Default for IA-32 applications: ip_ninl_min_stats = 7.

These limits can be modified with the option:
-Qoption,
f,-ip_ninl_min_stats=new value.

See -Qoption Specifiers and Profile-Guided Optimization (PGO).

When you do not use profile-guided optimizations with -ip or -ipo, 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

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 and  -ipo_obj on a file-by-file basis, the functions can be inlined. See Compilation with Real Object Files.