Option Type | Default Value | #pragma options | C | C++ |
-qoption | See below. | - | x | x |
Syntax
-qinline | -qinline=threshold | -qinline-names | -qinline+names | -qinline=limit | -qnoinline
Purpose
Attempts to inline functions instead of generating calls to a function. Inlining is
performed if possible, but, depending on which optimizations are performed, some functions
might not be inlined.
Notes
The -qinline option is functionally equivalent to the -Q option.
For C++, the behavior of the -qinline option has changed from previous versions of the compiler. The -qinline option now tells the compiler to inline any function, rather than only those marked as inlined.
Because inlining does not always improve run time, you should test the effects of this option on your code. Do not attempt to inline recursive or mutually recursive functions.
Normally, application performance is optimized if you request optimization (-O option), and compiler performance is optimized if you do not request optimization.
The IBM C and C++ Compilers _inline, _Inline, and __inline language keywords override all -qinline options except -qnoinline. The compiler will try to inline functions marked with these keywords regardless of other -qinline option settings.
To maximize inlining:
In the C language, the following -qinline options apply:
-qinline | The compiler attempts to inline all appropriate functions with 20 executable source statements or fewer, subject to any other settings of the suboptions to the -qinline option. If -qinline is specified last, all functions are inlined. |
-qnoinline | Does not inline any functions. If -qnoinline is specified last, no functions are inlined. |
-qinline=threshhold | Sets a size limit on the functions to be inlined. The number of
executable statements must be less than or equal to threshold for the function to
be inlined. threshold must be a positive integer. The default value is 20.
Specifying a threshold value of 0 causes no functions to be inlined
except those functions marked with the __inline, _Inline,
or _inline keywords. The threshold value applies to logical C statements. Declarations are not counted, as you can see in the example below: increment() { int a, b, i; for (i=0; i<10; i++) /* statement 1 */ { a=i; /* statement 2 */ b=i; /* statement 3 */ } } |
-qinline-names | The compiler does not inline functions listed by names. Separate
each name with a colon (:). All other appropriate functions are
inlined. The option implies -qinline. For example: -qinline-salary:taxes:expenses:benefits causes all functions except those named salary, taxes, expenses, or benefits to be inlined if possible. A warning message is issued for functions that are not defined in the source file. |
-qinline+names | Attempts to inline the functions listed by names and any other
appropriate functions. Each name must be separated by a colon (:).
The option implies -qinline. For example, -qinline+food:clothes:vacation causes all functions named food, clothes, or vacation to be inlined if possible, along with any other functions eligible for inlining. A warning message is issued for functions that are not defined in the source file or that are defined but cannot be inlined. This suboption overrides any setting of the threshold value. You can use a threshold value of zero along with -qinline+names to inline specific functions. For example: -qinline=0 followed by: -qinline+salary:taxes:benefits causes only the functions named salary, taxes, or benefits to be inlined, if possible, and no others. |
-qinline=limit | Specifies the maximum size (in bytes of generated code) to which a function can grow due to inlining. This limit does not affect the inlining of user specified functions. |
In the C++ language, the following -qinline options apply:
-qinline | Compiler inlines all functions that it can. |
-qnoinline | Compiler does not inline any functions. |
Default
The default is to treat inline specifications as a hint to the compiler, and the result
depends on other options that you select:
Example
To compile myprogram.c so that no functions are inlined, enter:
xlc myprogram.c -O -qnoinline
To compile myprogram.c so that the compiler attempts to inline functions of fewer than 12 lines, enter:
xlc myprogram.c -O -qinline=12
Program Optimization with IBM C and C++ Compilers
Using Inlined Components
Writing Optimized Code
List of Compiler Options and Their Defaults
Options that Define the Compiler Object Code Produced
_inline, _Inline, and __inline