Profiling with '-a' [was Re: Libgcc symbols]
Scott A Crosby
crosby@qwes.math.cmu.edu
Mon Apr 16 10:17:00 GMT 2001
On 16 Apr 2001, Nix wrote:
> On 14 Apr 2001, Mark Mitchell stipulated:
>
> OK, I've glimpsed the GCC tree up; time to use that :)
>
> > # ??? Some of these are for `-a', which ought to die.
>
> (They're all, of course, basic block profiling things.)
>
> > __bb
>
> This is the structure the basic block data is stored in. If -a and -ax
> really are going to die, so should this.
>
I've used basic block profiling once or twice... It can come in handy for,
for example, figuring out which way a branch tends to go in practice.
GPROF knows how to use this data (from the texinfo):
`-l'
`--line'
The `-l' option enables line-by-line profiling, which causes
histogram hits to be charged to individual source code lines,
instead of functions. If the program was compiled with
basic-block counting enabled, this option will also identify how
many times each line of code was executed. While line-by-line
profiling can help isolate where in a large function a program is
spending its time, it also significantly increases the running
time of `gprof', and magnifies statistical inaccuracies. *Note
Sampling Error::.
This annotates each basic block in the source file with a usecount.
Probably the documentation for the gcc '-a' option should be changed to
reflect this option.. People might not be using this because the gcc
manual says that the data format is unsupported by gprof.
I tested this out a year or two ago; it did work for x86. I say to not
junk it. It works, it is useful, and could be made much more useful in
terms of profile-based optimization.
May I suggest a small change to the manual, which currently reads:
-a Generate extra code to write profile information
for basic blocks, which will record the number of
times each basic block is executed. This data
could be analyzed by a program like tcov. Note,
however, that the format of the data is not what
tcov expects. Eventually GNU gprof should be ex
tended to process this data.
to something like:
Generate extra code to write profile information for basic blocks, which
will record the number of times each basic block is executed. This data
is currently analyzed by the gprof '-l' option which will identify how
many times each line of source code is executed. Although currently
unimplemented, eventualy GCC could be made to use this information for
profile-based optimization.
>
> This does not seem to be heavily used code... can anything yet *read*
> the files that -ax outputs? I cannot recall ever using it, or ever
> seeing anyone use it for anything. But, equally, other than some
> target-specific mess, I'm not sure how much code would actually be saved
> by junking -a; it's really just writing out data that's collected anyway
> for -fbranch-probabilities...
Whats -fbranch-probabilities? Unless it does the same as '-a', don't junk
'-a'
Scott
More information about the Gcc
mailing list