Inlining
Inlining replaces certain function calls with
the actual code of the function and is performed before all other
optimizations. Not only does inlining eliminate the linkage overhead,
it also exposes the entire called function to the caller, which enables
the compiler to better optimize your code.
Note: See Inlining under IPA for information on differences in inlining under
IPA.
The following types of calls are not inlined:
- A call where the number of parameters on the call does not match that on the function definition. An example of this is a variable argument function call.
- A call that is directly recursive; the routine calls itself.
- K&R style var_arg functions.
Consider the C examples CCNGOP1 and CCNGOP2, shown in Table 1. CCNGOP1 specifies the #pragma inline directive for the function which_group(). If you use the OPTIMIZE option when you compile CCNGOP1, the compiler determines that CCNGOP1 is equivalent to CCNGOP2.
Sample program CCNGOP1 | Sample program CCNGOP2 |
---|---|
|
|