Interprocedural analysis (IPA) enables the compiler to optimize across
different files (whole-program analysis), and can result in significant
performance improvements. You can specify interprocedural analysis on
the compile step only or on both compile and link steps ("whole
program" mode). Whole program mode expands the scope of
optimization to an entire program unit, which can be an executable or shared
object. As IPA can significantly increase compilation time, you should
limit using IPA to the final performance tuning stage of development.
You enable IPA by specifying the -qipa option. The most
commonly used suboptions and their effects are described in the following
table. The full set of suboptions and syntax is described in -qipa.
Table 12. Commonly used -qipa suboptions
suboption
| Behavior
|
level=0
| Program partitioning and simple interprocedural optimization, which
consists of:
- Automatic recognition of standard libraries.
- Localization of statically bound variables and procedures.
- Partitioning and layout of procedures according to their calling
relationships. (Procedures that call each other frequently are located
closer together in memory.)
- Expansion of scope for some optimizations, notably register
allocation.
|
level=1
| Inlining and global data mapping. Specifically:
- Procedure inlining.
- Partitioning and layout of static data according to reference
affinity. (Data that is frequently referenced together will be located
closer together in memory.)
This is the default level if you do not specify any suboptions with the
-qipa option.
|
level=2
| Global alias analysis, specialization, interprocedural data flow:
- Whole-program alias analysis. This level includes the
disambiguation of pointer dereferences and indirect function calls, and the
refinement of information about the side effects of a function call.
- Intensive intraprocedural optimizations. This can take the form of
value numbering, code propagation and simplification, code motion into
conditions or out of loops, elimination of redundancy.
- Interprocedural constant propagation, dead code elimination, pointer
analysis, and code motion across functions.
- Procedure specialization (cloning).
|
inline=variable
| Allows you precise control over function inlining.
|
fine_tuning
| Other values for -qipa provide the ability to specify the
behavior of library code, tune program partitioning, read commands from a
file, etc.
|
It is not necessary to compile everything with -qipa, but try to
apply it to as much of your program as possible. Here are some
suggestions:
- Specify the -qipa option on both the compile and link steps of
the entire application, or as much of it as possible. Although you can
also use -qipa with libraries, shared objects, and executables, be
sure to use -qipa to compile the main and exported
functions.
- When compiling and linking separately, use -qipa=noobject on
the compile step for faster compilation.
- When specifying optimization options in a makefile, remember to use the
compiler driver (xlc) to link, and to include all compiler options
on the link step.
- As IPA can generate significantly larger object files than traditional
compilations, ensure that there is enough space in the /tmp
directory (at least 200 MB), or use the TMPDIR environment variable
to specify a different directory with sufficient free space.
- Try varying the level suboption if link time is too
long. Compiling with -qipa=level=0 can still be very
beneficial for little additional link time.
- Use -qlist or -qipa=list to
generate a report of functions that were inlined. If too few or too
many functions are inlined, consider using -qipa=inline or
-qipa=noinline. To control inlining of specific
functions, use -Q+ or -Q-.
