#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--(--+-size--+-------+----------------+--)--"---+--)-><
                                    |       +-, yes-+                |                
                                    |       '-, no--'                |                
                                    +-level--,--+-0-+----------------+                
                                    |           +-2-+                |                
                                    |           +-3-+                |                
                                    |           +-4-+                |                
                                    |           '-5-'                |                
                                    +-registerspillsize--,----size---+                
                                    |         .-,------------------. |                
                                    |         V                    | |                
                                    '-strict----+----------------+-+-'                
                                                +-no-------------+                    
                                                +-all------------+                    
                                                +-none-----------+                    
                                                '-suboption_list-'                    

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
level, 0 -O
level, 2 -O2
level, 3 -O3
level, 4 -O4
level, 5 -O5
registerspillsize, size -qspill=size
size -qcompact
size, yes
size, no -qnocompact
strict, all -qstrict, -qstrict=all
strict, no, none -qnostrict
strict, suboption_list -qstrict=suboption_list

Defaults

See the descriptions 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.

Examples

Suppose you compile the following code fragment containing the functions foo and faa using -O2. 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(){
     .
     .
     .
     }

Related information