$ cc +P -o prog.opt prog.c

//Optimize it, but name it prog.opt.

The linker is unable to find the program name prog.opt in the flow.data file and issues the error message

No profile data found for the program prog.opt in flow.data

To get around this problem, the compilers and linker provide the +pgm name option, which allows you to specify a program name to look for in the flow.data file. For instance, to make the above example work properly, you would include +pgm prog.inst on the final compile line:

$ cc +P -o prog.opt +pgm prog.inst prog.c

Like the +df option, the +pgm option is passed directly to the linker.

Selecting an Optimization Level with PBO

When -Pis specified, the code generator and linker perform profile-based optimizations on any I-SOM or regular object files found on the linker command line. In addition, optimizations will be performed according to the optimization level you specified with a compiler option when you instrumented the application. Briefly, the compiler optimization options are:

Option

Description

+O0

Minimal optimization. This is the default.

+O1

Basic block level optimization.

+O2

Full optimization within each procedure in a file. (Can also be invoked as -O.)

+O3

Full optimization across all procedures in an object B file. Includes subprogram inlining.

+O4

Full optimization across entire application, performed at link time. (Invokes ld +Ofastaccess

 

+Oprocelim.) Includes inlining across multiple files.

NOTE: The +O3 and +O4 options are incompatible with symbolic debugging. The only compiler optimization levels that allow for symbolic debugging are +O2 and lower.

For more detailed information on compiler optimization levels, see your compiler documentation.

PBO has the greatest impact when it is combined with level 2 or greater optimizations. For instance, this compile command combines level 2 optimization with PBO (note that the compiler options +O2 and -Oare equivalent):

$ cc -v -O +I -c prog.c /opt/langtools/lbin/cpp prog.c /var/tmp/ctm123 /opt/ansic/lbin/ccom /var/tmp/ctm123 prog.o -O2 -I $ cc -v -O +I -o prog prog.o

/usr/ccs/bin/ld /opt/langtools/lib/icrt0.o -u main -o prog \ prog.o -I -lc

The optimizations are performed along with instrumentation. However, profile-based optimizations are not performed until you compile later with +P:

$ cc -v +P -o prog prog.o

/usr/ccs/bin/ld /usr/ccs/lib/crt0.o -u main \ -o prog prog.o -P -lc

Using PBO to Optimize Shared Libraries

Beginning with the HP-UX 10.0 release, the-Ilinker option can be used with -bto build a shared library with instrumented code. Also, the -P, +df, and +pgm command-line options are compatible with the -boption.

212 Improving Your Application Performance

Page 212
Image 212
HP UX Software Transition Kit (STK) manual Selecting an Optimization Level with PBO, Using PBO to Optimize Shared Libraries