-finline-functions (-qinline)

Pragma equivalent

None.

Purpose

Attempts to inline functions instead of generating calls to those functions, for improved performance.

Syntax

Read syntax diagramSkip visual syntax diagram
>>--- -finline-functions---------------------------------------><

Read syntax diagramSkip visual syntax diagram
   .- -qnoinline------------------------------.   
>>-+- -qinline-+----------------------------+-+----------------><
               |   .-:--------------------. |     
               |   V                      | |     
               +-=---+-auto-------------+-+-+     
               |     +-noauto-----------+   |     
               |     '-level--=--number-'   |     
               |         .-:-------------.  |     
               |         V               |  |     
               '-+- + +----function_name-+--'     
                 '- - '                           

Defaults

If -qinline is not specified, the default option is as follows:
  • -qnoinline at the -O0 or -qnoopt optimization level
  • -qinline=noauto:level=5 at the -O2 optimization level
  • -qinline=auto:level=5 at the -O2 -qipa, -O3 or higher optimization level

If -qinline is specified without any suboptions, the default option is -qinline=auto:level=5.

Parameters

auto | noauto
Enables or disables automatic inlining. When option -qinline=auto is in effect, all functions are considered for inlining by the compiler. When option -qinline=noauto is in effect, only the following types of functions are considered for inlining:
  • Functions that are defined with the inline specifier
  • Small functions that are identified by the compiler
The compiler determines whether a function is appropriate for inlining, and enabling automatic inlining does not guarantee that a function is inlined.
level=number
Indicates the relative degree of inlining. The values for number must be integers in the range 0 - 10 inclusive. The default value for number is 5. The greater the value of number, the more aggressive inlining the compiler conducts.
function_name
If function_name is specified after the -qinline+ option, the named function must be inlined. If function_name is specified after the -qinline- option, the named function must not be inlined. C++ only beginsThe function_name must be the mangled name of the function. You can find the mangled function name in the listing file.C++ only ends

Usage

You can specify C++ only begins-qinlineC++ only ends or specify -qinline with any optimization level of C++ only begins-OC++ only ends, -O2, -O3, -O4, or -O5 to enable inlining of functions, including those functions that are declared with the inline specifier C++ only beginsor that are defined within a class declarationC++ only ends.

When -qinline is in effect, the compiler determines whether inlining a specific function can improve performance. That is, whether a function is appropriate for inlining is subject to two factors: limits on the number of inlined calls and the amount of code size increase as a result. Therefore, enabling inlining a function does not guarantee that function will be inlined.

Because inlining does not always improve runtime performance, you need to test the effects of this option on your code. Do not attempt to inline recursive or mutually recursive functions.

You can use the -qinline+<function_name> or -qinline-<function_name> option to specify the functions that must be inlined or must not be inlined.

IBM only beginsThe -qinline-<function_name> option takes higher precedence than the always_inline or __always_inline__ attribute. When you specify both the always_inline or __always_inline__ attribute and the -qinline-<function_name> option to a function, that function is not inlined.IBM only ends

Specifying -qnoinline disables all inlining, including that achieved by the high-level optimizer with the -qipa option, and functions declared explicitly as inline. However, the -qnoinline option does not affect the inlining of the following functions:
  • IBM only beginsFunctions that are specified with the always_inline or __always_inline__ attributeIBM only ends
  • Functions that are specified with the -qinline+<function_name> option

If you specify the -g option to generate debugging information, the inlining effect of -qinline might be suppressed.

If you specify the -qcompact option to avoid optimizations that increase code size, the inlining effect of -qinline might be suppressed.

Predefined macros

None.

Examples

Example 1

To compile myprogram.c so that no functions are inlined, use the following command:

xlc myprogram.c -O2 -qnoinline

However, if some functions in myprogram.c are specified with IBM only beginsthe always_inline or __always_inline__ attributeIBM only ends, the -qnoinline option has no effect on these functions and they are still inlined.

If you want to enable automatic inlining, you use the auto suboption:

-O2 -qinline=auto

You can specify an inlining level 6 - 10 to achieve more aggressive automatic inlining. For example:

-O2 -qinline=auto:level=7

If automatic inlining is already enabled by default and you want to specify an inlining level of 7, you enter:

-O2 -qinline=level=7

Example 2

C only begins

Assuming myprogram.c contains the salary, taxes, expenses, and benefits functions, you can use the following command to compile myprogram.c to inline these functions:

xlc myprogram.c -O2 -qinline+salary:taxes:expenses:benefits

If you do not want the functions salary, taxes, expenses, and benefits to be inlined, use the following command to compile myprogram.c:

xlc myprogram.c -O2 -qinline-salary:taxes:expenses:benefits

You can also disable automatic inlining and specify certain functions to be inlined with the -qinline+ option. Consider the following example:

-O2 -qinline=noauto -qinline+salary:taxes:benefits

In this case, the functions salary, taxes, and benefits are inlined. Functions that are specified with IBM only beginsthe always_inline or __always_inline__ attributeIBM only ends or declared with the inline specifier are also inlined. No other functions are inlined.

You cannot mix the + and - suboptions with each other or with other -qinline suboptions. For example, the following options are invalid suboption combinations:
-qinline+increase-decrease    // Invalid
-qinline=level=5+increase     // Invalid
However, you can use multiple -qinline options separately. See the following example:
-qinline+increase -qinline-decrease -qinline=noauto:level=5
C only ends

C++ only beginsIn C++, you can use the -qinline+ and -qinline- options in the same way as in example 2; however, you must specify the mangled function names instead of the actual function names after these options.C++ only ends



Voice your opinion on getting help information Ask IBM compiler experts a technical question in the IBM XL compilers forum Reach out to us