#pragma option_override

Category

Optimization and tuning

Purpose

Allows you to specify optimization options at the subprogram level that override optimization options given on the command line.

This enables finer control of program optimization, and can help debug errors that occur only under optimization.

Syntax

Read syntax diagramSkip visual syntax diagram
>>-#--pragma--option_override----------------------------------->

                  .------------------------------------------------.      
                  V                                                |      
>--(--identifier----,----"--opt--(--+-compact--+-------+-+--)--"---+--)-><
                                    |          +-, yes-+ |                
                                    |          '-, no--' |                
                                    +-level--,--+-0-+----+                
                                    |           +-2-+    |                
                                    |           '-3-'    |                
                                    +-spill--,----size---+                
                                    '-strict--+-------+--'                
                                              '-, yes-'                   

Parameters

identifier
The name of a function for which optimization options are to be overridden.
The following table shows the equivalent command line option for each pragma suboption.
#pragma option_override value Equivalent compiler option
compact COMPACT
compact, yes
compact, no NOCOMPACT
level, 0 OPT(0)
level, 1 OPT(2)
level, 2 OPT(2)
level, 3 OPT(3)
spill, size SPILL(size)
strict STRICT
strict, yes
strict, no NOSTRICT
Notes:
  1. If optimization level -O3 or higher is specified on the command line, #pragma option_override(identifier, "opt(level, 0)") or #pragma option_override(identifier, "opt(level, 2)") does not turn off the implication of the -qhot and -qipa options.

Defaults

See the descriptions in the z/OS XL C/C++ User's Guide for the options listed in the table above for default settings.

Usage

The pragma takes effect only if optimization is already enabled by a command-line option. You can only specify an optimization level in the pragma lower than the level applied to the rest of the program being compiled.

The #pragma option_override directive only affects functions that are defined in the same compilation unit. The pragma directive can appear anywhere in the translation unit. That is, it can appear before or after the function definition, before or after the function declaration, before or after the function has been referenced, and inside or outside the function definition.

C++ only This pragma cannot be used with overloaded member functions.

Examples

Suppose you compile the following code fragment containing the functions foo and faa using OPT(2). Since it contains the #pragma option_override(faa, "opt(level, 0)"), function faa will not be optimized.

foo(){
     .
     .
     .
     }

#pragma option_override(faa, "opt(level, 0)")

faa(){
     .
     .
     .
     }

IPA effects

You cannot specify the IPA compiler option for #pragma option_override.

During IPA compile processing, subprogram-specific options will be used to control IPA compile-time optimizations.

During IPA link processing, subprogram-specific options will be used to control IPA link-time optimizations, as well as program partitioning. They will be retained, even if the related IPA link command line option is specified.

Related information