Kenwood HP 9000 Personal Computer User Manual


 
Chapter 8 283
Ways to Improve Performance
Profile-Based Optimization
The function _clear_counters is defined in icrt0.o. It is also defined
as a stub (an empty function that does nothing) in crt0.o. This allows
you to use the same source code without modification in the
instrumented and un-instrumented versions of the program.
Optimizing Based on Profile Data (+P/-P)
The final step in PBO is optimizing a program using profile data created
in the profiling phase. To do this, rebuild the program with the +P
compiler option. As with the +I option, the +P option causes the compiler
to generate an I-SOM .o file, rather than the usual object code, for each
source file.
Note that it is not really necessary to recompile the source files; you
could, instead, specify the I-SOM .o files that were created during the
instrumentation phase. For instance, suppose you have already created
an I-SOM file named foo.o from foo.c using the +I compiler option;
then the following commands are equivalent in effect:
cc +P foo.c
cc +P foo.o
Both commands invoke the linker, but the second command doesn't
compile before invoking the linker.
The -P Linker Option
After creating an I-SOM file for each source file, the compiler driver
invokes the linker with the -P option, causing the linker to optimize all
the .o files. As with the +I option, the driver uses
/opt/langtools/lbin/ucomp to generate code and perform various
optimizations.
To see how the compiler invokes the linker, specify the -v option when
compiling. For instance, suppose you have instrumented prog.c and
gathered profile data into flow.data. The following example shows how
the compiler driver invokes the linker when +P is specified:
$ cc -o prog -v +P prog.o
/usr/ccs/bin/ld /usr/ccs/lib/crt0.o -u main -o prog \
prog.o -P -lc
Notice how the program is now linked with /usr/ccs/lib/crt0.o
instead of /opt/langtools/lib/icrt0.o because the profiling code is
no longer needed.