-qipa

Category

Optimization and tuning

@PROCESS

None.

Purpose

Enables or customizes a class of optimizations known as interprocedural analysis (IPA).

IPA is a two-step process: the first step, which takes place during compilation, consists of performing an initial analysis and storing interprocedural analysis information in the object file. The second step, which takes place during linking, and causes a complete recompilation of the entire application, applies the optimizations to the entire program.

You can use -qipa during the compilation step, the link step, or both. If you compile and link in a single compiler invocation, only the link-time suboptions are relevant. If you compile and link in separate compiler invocations, only the compile-time suboptions are relevant during the compile step, and only the link-time suboptions are relevant during the link step.

You can generate relinkable objects while preserving IPA information by specifying -r -qipa=relink. This creates a nonexecutable package that contains all object files. By using this suboption, you can postpone linking until the very last stage.

If you want to use your own archive files as input, you can use the ar tool and set the XL_AR environment variable to point to its location. If you do not specify a location, the compiler sets the environment variable according to the information contained in the configuration file.

Note:
  • This suboption does not link the objects; instead, it only aggregates them. As such, the compiler does not report any error or warning messages. Furthermore, the compiler silently ignores linker or binder options when you use this suboption.
  • You must use the -r suboption with -qipa=relink. Without -r, -qipa=relink is ignored.

Syntax

Read syntax diagramSkip visual syntax diagram
-qipa compile-time syntax

        .-noipa--------------------.   
>>- -q--+-ipa--+-----------------+-+---------------------------><
               |    .-object---. |     
               '-=--+-noobject-+-'     

Read syntax diagramSkip visual syntax diagram
-qipa link-time syntax

        .-noipa--------------------------------------------------.   
>>- -q--+-ipa--+-----------------------------------------------+-+-><
               |    .-:--------------------------------------. |     
               |    |             .-,-------------.          | |     
               |    V             V               |          | |     
               '-=----+-exits--=----function_name-+--------+-+-'     
                      |           .-1-.                    |         
                      +-level--=--+-0-+--------------------+         
                      |           '-2-'                    |         
                      +-list--+------------------+---------+         
                      |       '-=--+-file_name-+-'         |         
                      |            +-long------+           |         
                      |            '- short----'           |         
                      |             .-,-------------.      |         
                      |             V               |      |         
                      +-lowfreq--=----function_name-+------+         
                      | .-malloc16---.                     |         
                      +-+-nomalloc16-+---------------------+         
                      |             .-unknown--.           |         
                      +-missing--=--+-safe-----+-----------+         
                      |             +-isolated-+           |         
                      |             '-pure-----'           |         
                      |               .-medium-.           |         
                      +-partition--=--+-small--+-----------+         
                      |               '-large--'           |         
                      +-relink-----------------------------+         
                      | .-nostdexits-.                     |         
                      +-+-stdexits---+---------------------+         
                      | .-threads--+---------------+-.     |         
                      | |          |    .-auto---. | |     |         
                      | |          '-=--+-number-+-' |     |         
                      | |               '-noauto-'   |     |         
                      +-+-nothreads------------------+-----+         
                      |                  .-,-------------. |         
                      |                  V               | |         
                      +-+-isolated-+--=----function_name-+-+         
                      | +-pure-----+                       |         
                      | +-safe-----+                       |         
                      | '-unknown--'                       |         
                      '-file_name--------------------------'         

Defaults

Parameters

You can specify the following parameters during a separate compile step only:

object | noobject
Specifies whether to include standard object code in the output object files.

Specifying noobject can substantially reduce overall compile time by not generating object code during the first IPA phase. Note that if you specify -S with noobject, noobject will be ignored.

If compiling and linking are performed in the same step and you do not specify the -S or any listing option, -qipa=noobject is implied.

Specifying -qipa with no suboptions on the compile step is equivalent to -qipa=object.

You can specify the following parameters during a combined compile and link in the same compiler invocation, or during a separate link step only:
exits
Specifies names of procedures which represent program exits. Program exits are calls which can never return and can never call any procedure which has been compiled with IPA pass 1. The compiler can optimize calls to these procedures (for example, by eliminating save/restore sequences), because the calls never return to the program. These procedures must not call any other parts of the program that are compiled with -qipa.
isolated
Specifies a comma-separated list of procedures that are not compiled with -qipa. Procedures that you specify as isolated or procedures within their call chains cannot refer directly to any global variable.
level
Specifies the optimization level for interprocedural analysis. Valid suboptions are one of the following suboptions:
0
Performs only minimal interprocedural analysis and optimization.
1
Enables inlining, limited alias analysis, and limited call-site tailoring.
2
Performs full interprocedural data flow and alias analysis.
If you do not specify a level, the default is 1.

To generate data reorganization information, specify the optimization level -qipa=level=2 or -O5 together with -qreport. During the IPA link phase, the data reorganization messages for program variable data are written to the data reorganization section of the listing file. Reorganizations include common block splitting, array splitting, array transposing, memory allocation merging, array interleaving, and array coalescing.

list
Specifies that a listing file be generated during the link phase. The listing file contains information about transformations and analyses performed by IPA, as well as an optional object listing for each partition.

If you do not specify a list_file_name, the listing file name defaults to a.lst. If you specify -qipa=list together with any other option that generates a listing file, IPA generates an a.lst file that overwrites any existing a.lst file. If you have a source file named a.f, the IPA listing will overwrite the regular compiler listing a.lst. You can use the -qipa=list=list_file_name suboption to specify an alternative listing file name.

Additional suboptions are one of the following suboptions:
short
Requests less information in the listing file. Generates the Object File Map, Source File Map and Global Symbols Map sections of the listing.
long
Requests more information in the listing file. Generates all of the sections generated by the short suboption, plus the Object Resolution Warnings, Object Reference Map, Inliner Report and Partition Map sections.
lowfreq
Specifies procedures that are likely to be called infrequently. These are typically error handling, trace, or initialization procedures. The compiler may be able to make other parts of the program run faster by doing less optimization for calls to these procedures.
malloc16 | nomalloc16
Informs the compiler that the dynamic memory allocation routines will return 16-byte aligned memory addresses. The compiler can then optimize the code based on that assertion.

In 64-bit mode, AIX® always returns 16-byte aligned addresses and therefore by default -qipa=malloc16 is in effect. You can use -qipa=nomalloc16 to override the default setting.

Note: You must make sure that the executables generated with -qipa=malloc16 run in an environment in which dynamic memory allocations return 16-byte aligned addresses, otherwise, wrong results can be generated. For example, in 32-bit mode, addresses are not 16-byte aligned. In this case, you must set the MALLOCALIGN=16 runtime environment variable.
missing
Specifies the interprocedural behavior of procedures that are not compiled with -qipa and are not explicitly named in an unknown, safe, isolated, or pure suboption.
Valid suboptions are one of the following suboptions:
safe
Specifies that the missing procedures do not indirectly call a visible (not missing) function either through direct call or through a procedure pointer.
isolated
Specifies that the missing procedures do not directly reference global variables accessible to visible procedures. Procedures bound from shared libraries are assumed to be isolated.
pure
Specifies that the missing procedures are safe and isolated and do not indirectly alter storage accessible to visible procedures. pure procedures also have no observable internal state.
unknown
Specifies that the missing procedures are not known to be safe, isolated, or pure. This suboption greatly restricts the amount of interprocedural optimization for calls to missing procedures.
The default is to assume unknown.
partition
Specifies the size of each program partition created by IPA during pass 2. Valid suboptions are one of the following suboptions:
  • small
  • medium
  • large
Larger partitions contain more procedures, which result in better interprocedural analysis but require more storage to optimize. Reduce the partition size if compilation takes too long because of paging.
pure
Specifies pure procedures that are not compiled with -qipa. Any procedure specified as pure must be isolated and safe, and must not alter the internal state or have side-effects, defined as potentially altering any data visible to the caller.
relink
Creates relinkable objects by packaging them into a nonexecutable file. When using this suboption, you must also use the -r option along with it. Otherwise, the compiler ignores -qipa=relink.
Note:
  • You might indirectly use -qipa=noobject if you link and compile your object files in one step. If you use -qipa=noobject (either directly or indirectly) and use the relink suboption, you must link the resulting object files with -qipa. Otherwise, unresolved references to your object files can occur.
  • In addition, you cannot use the shared objects with -qipa=relink, they must be used at the last link step together with the prelink output.
safe
Specifies safe procedures that are not compiled with -qipa and do not call any other part of the program. Safe procedures can modify global variables and dummy arguments, but may not call procedures compiled with -qipa.
stdexits | nostdexits
Specifies that certain predefined routines can be optimized as with the exits suboption. The procedures are: abort, exit, _exit, and _assert.
threads | nothreads
Runs portions of the IPA optimization process during pass 2 in parallel threads, which can speed up the compilation process on multi-processor systems. Valid suboptions for the threads suboption are as follows:
auto | noauto
When auto is in effect, the compiler selects a number of threads heuristically based on machine load. When noauto is in effect, the compiler creates one thread per machine processor.
number
Instructs the compiler to use a specific number of threads. number can be any integer value in the range of 1 to 32 767. However, number is effectively limited to the number of processors available on your system.
Specifying threads with no suboptions implies -qipa=threads=auto.
unknown
Specifies unknown procedures that are not compiled with -qipa. Any procedure specified as unknown can make calls to other parts of the program compiled with -qipa, and modify global variables and dummy arguments.
file_name
Gives the name of a file which contains suboption information in a special format.
The file format is shown as follows:
# ... comment 
attribute{, attribute} = name{, name}

missing = attribute{, attribute} 
exits = name{, name} 
lowfreq = name{, name}
list [ = file-name | short | long ]
level = 0 | 1 | 2 
partition = small | medium | large  
where attribute is one of:
  • exits
  • lowfreq
  • unknown
  • safe
  • isolated
  • pure
Note:
  • -qipa=inline and all of its associated suboptions are deprecated, -qinline replaces them all. For details, see -qinline and Deprecated options.
  • As of the V11.1 release of the compiler, the pdfname suboption is deprecated; you should use -qpdf1=pdfname or -qpdf2=pdfname in your new applications. See -qpdf1, -qpdf2 for details.

Usage

Specifying -qipa automatically sets the optimization level to -O2. For additional performance benefits, you can also specify the -qinline option. The -qipa option extends the area that is examined during optimization and inlining from a single procedure to multiple procedures (possibly in different source files) and the linkage between them.

If any object file used in linking with -qipa was created with the -qipa=noobject option, any file containing an entry point (the main program for an executable program, or an exported function for a library) must be compiled with -qipa.

You can link objects created with different releases of the compiler, but you must ensure that you use a linker that is at least at the same release level as the newer of the compilers used to create the objects being linked.

You can use -r -qipa=relink to create a relinkable package that contains all object files without generating an executable program. if you want to use your archive files as input, set the path to your ar tool using the XL_AR environment variable.

Some symbols which are clearly referenced or set in the source code may be optimized away by IPA, and may be lost to debug, dump, or nm outputs. Using IPA together with the -g compiler will usually result in non-steppable output.

Note that if you specify -qipa with -#, the compiler does not display linker information subsequent to the IPA link step.

For recommended procedures for using -qipa, see Optimizing your applications.

Examples

The following example shows how you might compile a set of files with interprocedural analysis:
xlf -c *.f -qipa
xlf -o product *.o -qipa 
Here is how you might compile the same set of files, improving the optimization of the second compilation, and the speed of the first compile step. Assume that there exist a set of routines, user_trace1, user_trace2, and user_trace3, which are rarely executed, and the routine user_abort that exits the program:
xlf95 -c *.f -qipa=noobject
xlf95 -c *.o -qipa=lowfreq=user_trace[123]:exit=user_abort 
The following example demonstrates how you can create a relinkable package that includes your object files:
xlf –O5 –o –r –qipa=relink result obj1.o obj2.o obj3.o

ls –l result

-rw-r--r-- result

xlf –O5 –o res result obj4.o obj5.o
Here is how you can generate a relinkable package using your own archive files:
ar –X64 –r arch1.a object11.o object12.o

ar –X64 –r arch2.a object21.o object22.o

xlf –O5 –o –r –qipa=relink –q64 result obj1.o obj2.o obj3.o arch1.a arch2.a
xlf –O5 –o res result obj4.o obj5.o

Related information