Q

Option Type Default Value #pragma options C C++
-flag See below. - x x

Syntax

    -Q | -Q=threshold | -Q-names | -Q+names | -Q! 

Purpose
In the C language, 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.

In the C++ language, specifies which functions will be inlined instead of generating a call to a function.

Notes
The -Q option is functionally equivalent to the -qinline option.

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 VisualAge C++ _inline, _Inline, and __inline C language keywords override all -Q options except -Q!. The compiler will try to inline functions marked with these keywords regardless of other -Q option settings.

To maximize inlining:

 

In the C language, the following -Q options apply:

-Q Attempts to inline all appropriate functions with 20 executable source statements or fewer, subject to the setting of any of the suboptions to the -Q option. If -Q is specified last, all functions are inlined.
-Q! Does not inline any functions. If -Q! is specified last, no functions are inlined.

 

In the C++ language, the following -Q options apply:

-Q Compiler inlines all functions that it can.
-Q! Compiler does not inline any functions.

 

In the C language, the following -Q options apply:

-Q=threshold 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 */ 
      } 
    }
-Q-names Does not inline functions listed by names. Separate each name with a colon (:). All other appropriate functions are inlined. The option implies -Q.

For example:

    -Q-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.

-Q+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 -Q.

For example,

    -Q+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 -Q+names to inline specific functions. For example:

    -Q=0

followed by:

    -Q+salary:taxes:benefits

causes only the functions named salary, taxes, or benefits to be inlined, if possible, and no others.

Default
The default is to treat inline specifications as a hint to the compiler and depends on other options that you select:

Example
To compile the program myprogram.c so that no functions are inlined, enter:

xlC myprogram.c -O -Q!

To compile the program my_c_program.c so that the compiler attempts to inline functions of fewer than 12 lines, enter:

xlc my_c_program.c -O -Q=12


Overview of Optimization


Optimize Your Application


List of Batch Compiler Options and Their Defaults
Batch Options that Define the Compiler Object Code Produced
_inline, _Inline, and __inline
Equivalent Batch Compile-Link and Incremental Build Options