Visible to Intel only — GUID: GUID-6608F908-2791-4059-8DD9-936FEAB81936
Visible to Intel only — GUID: GUID-6608F908-2791-4059-8DD9-936FEAB81936
Inline Expansion of Functions
Inline function expansion does not require that the applications meet the criteria for whole program analysis normally required by IPO; so this optimization is one of the most important optimizations done in Interprocedural Optimization (IPO). For function calls that the compiler believes are frequently executed, the compiler often decides to replace the instructions of the call with code for the function itself.
In the compiler, inline function expansion is performed on relatively small user functions more often than on functions that are relatively large. This optimization improves application performance by performing the following:
Removing the need to set up parameters for a function call
Eliminating the function call branch
Propagating constants
Function inlining can improve execution time by removing the runtime overhead of function calls; however, function inlining can increase code size, code complexity, and compile times. In general, when you instruct the compiler to perform function inlining, the compiler can examine the source code in a much larger context, and the compiler can find more opportunities to apply optimizations.
Using the Windows* options can, in some cases, significantly increase compile time and code size.
Compiler-Directed Inline Expansion of Functions
Without directions from the user, the compiler attempts to estimate what functions should be inlined to optimize application performance.
The following options are useful in situations where an application can benefit from user function inlining but does not need specific direction about inlining limits.
Option | Effect |
---|---|
inline-level(Linux*) or Ob (Windows*) |
Specifies the level of inline function expansion. Note that the option /Ob2 on Windows* is equivalent to -inline-level=2 on Linux*. Allowed values are 0, 1, and 2. |
Developer-Directed Inline Expansion of User Functions
In addition to the options that support compiler directed inline expansion of user functions, the compiler also provides compiler options and directives that allow you to more precisely direct when and if inline function expansion should occur.
The compiler measures the relative size of a routine in an abstract value of intermediate language units, which is approximately equivalent to the number of instructions that will be generated. The compiler uses the intermediate language unit estimates to classify routines and functions as relatively small, medium, or large functions. The compiler then uses the estimates to determine when to inline a function; if the minimum criteria for inlining is met and all other things are equal, the compiler has an affinity for inlining relatively small functions and not inlining relative large functions.
Typically, the compiler targets functions that have been marked for inlining based on the following:
- Procedure-specific inlining directives: Tells the compiler to inline calls within the targeted procedure if it is legal to do so. For example, !DIR$ ATTRIBUTES INLINE, !DIR$ ATTRIBUTES FORCEINLINE.
The following developer directed inlining options and directives provide the ability to change the boundaries used by the inliner to distinguish between small and large functions.