278 Chapter 8
Ways to Improve Performance
Profile-Based Optimization
The Startup File icrt0.o
The icrt0.o startup file uses the atexit system call to register the
function that writes out profile data. (For 64-bit mode, the initialization
code is in /usr/ccs/lib/pa20_64/fdp_init.0.) That function is
called when the application exits.
atexit allows a fixed number of functions to be registered from a user
application. Instrumented applications (those linked with -I) will have
one less atexit call available. One or more instrumented shared
libraries will use a single additional atexit call. Therefore, an
instrumented application that contains any number instrumented
shared libraries will use two of the available atexit calls.
For details onatexit, see atexit(2).
The -I Linker Option
When invoked with the -I option, the linker instruments all the
specified object files. Note that the linker instruments regular object files
as well as I-SOM files; however, with regular object files, only procedure
call instrumentation is added. With I-SOM files, additional
instrumentation is done within procedures.
For instance, suppose you have a regular object file namedfoo.o created
by compiling without the +I option, and you compile a source file bar.c
with the +I option and specify foo.o on the compile line:
$cc -c foo.c
$cc -v -o foobar -O +I bar.c foo.o
/opt/langtools/lbin/cpp bar.c /var/tmp/ctm456
/opt/ansic/lbin/ccom /var/tmp/ctm456 bar.o -O2 -I
/usr/ccs/bin/ld /opt/langtools/lib/icrt0.o -u main -o foobar \
bar.o foo.o -I -lc
In this case, the linker instruments both bar.o and foo.o. However,
since foo.o is not an I-SOM file, only its procedure calls are
instrumented; basic blocks within procedures are not instrumented. To
instrument foo.c to the same extent, you must compile it with the +I
option — for example:
$cc -v -c +I -O foo.c
/opt/langtools/lbin/cpp foo.c /var/tmp/ctm432
/opt/ansic/lbin/ccom /var/tmp/ctm432 foo.o -O2 -I
$cc -v -o foobar -O +I bar.c foo.o
/opt/langtools/lbin/cpp bar.c /var/tmp/ctm456
/opt/ansic/lbin/ccom /var/tmp/ctm456 bar.o -O2 -I
/usr/ccs/bin/ld /opt/langtools/lib/icrt0.o -u main -o foobar \
bar.o foo.o -I -lc