Sun WorkShop Compiler C 5.0 User's Guide

-xprofile=p

Collects data for a profile or uses a profile to optimize.

(SPARC) p must be collect[:name], use[:name], or tcov.

This option causes execution frequency data to be collected and saved during execution, then the data can be used in subsequent runs to improve performance. This option is only valid when you specify a level of optimization.

collect[:name]

Collects and saves execution frequency data for later use by the optimizer with -xprofile=use. The compiler generates code to measure statement execution frequency.

The name is the name of the program that is being analyzed. This name is optional. If name is not specified, a.out is assumed to be the name of the executable.

At runtime a program compiled with -xprofile=collect:name will create the subdirectory name.profile to hold the runtime feedback information. Data is written to the file feedback in this subdirectory. If you run the program several times, the execution frequency data accumulates in the feedback file; that is, output from prior runs is not lost.

use[:name]

Uses execution frequency data to optimize strategically.

As with collect:name, the name is optional and may be used to specify the name of the program.

The program is optimized by using the execution frequency data previously generated and saved in the feedback files written by a previous execution of the program compiled with -xprofile=collect.

The source files and other compiler options must be exactly the same as those used for the compilation that created the compiled program that generated the feedback file. If compiled with -xprofile=collect:name, the same program name name must appear in the optimizing compilation: -xprofile=use:name.

tcov

Basic block coverage analysis using "new" style tcov.

The -xprofile=tcov option is the new style of basic block profiling for tcov. It has similar functionality to the -xa option, but correctly collects data for programs that have source code in header files. See "-xa" for information on the old style of profiling, the tcov(1) man page, and Analyzing Program Performance With Sun WorkShop for more details.

Code instrumentation is performed similarly to that of the -xa option, but .d files are no longer generated. Instead, a single file is generated, the name of which is based on the final executable. For example, if the program is run out of /foo/bar/myprog.profile, the data file is stored in /foo/bar/myprog.profile/myprog.tcovd.

The -xprofile=tcov and the -xa options are compatible in a single executable. That is, you can link a program that contains some files that have been compiled with -xprofile=tcov, and others with -xa. You cannot compile a single file with both options.

When running tcov, you must pass it the -x option to make it use the new style of data. If not, tcov uses the old .d files, if any, by default for data, and produces unexpected output.

Unlike the -xa option, the TCOVDIR environment variable has no effect at compile-time. However, its value is used at program runtime. See tcov(1) and Analyzing Program Performance With Sun WorkShop for more details.