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:
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.
Minimum criteria for the 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
The function must be called if it is declared as static. Otherwise, it will be deleted.
Minimum criteria for the callee:
Does not have variable argument list.
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.
Is not considered unsafe for other reasons.
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:
The default heuristic focuses on the most frequently executed call sites, based on the profile information gathered for the program.
By default, the compiler does not inline functions with more than 230 intermediate statements. You can change this value by specifying the option -Qoption,f,-ip_ninl_max_stats=new value.
The default inline heuristic will stop inlining when direct recursion is detected.
The default heuristic always inlines very small functions that meet the minimum inline criteria.
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.
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.
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.