pub struct Profile {
pub requested: bool,
pub path: Option<String>,
pub dir: Option<String>,
pub absolute: bool,
pub correction: bool,
pub partial_training: bool,
}Expand description
What the profile reading half of the -fprofile family asked for.
A profile is a count per edge, gathered by running a build of the program that was instrumented to count, and read back on a second compilation so that the optimizer knows which way each branch actually went. It is worth more than any single optimization, because almost everything the optimizer decides is a guess about a frequency that the counts simply state.
Nothing here reads one yet, so this is recorded rather than acted on, and the family splits in
two rather than being taken or refused as a whole. The half recorded here is the half that only
costs speed when it is ignored: a build that asks to read a profile and is not read one gets the
program it would have got anyway, which is what section 4.1 means by a hint about speed. The
other half writes files, and that half is refused by the driver rather than landing here, on the
same reading -gsplit-dwarf gets: a program instrumented by -fprofile-generate writes a
.gcda when it runs and -ftest-coverage writes a .gcno beside the object, and ignoring
either means a build waits for a file that never arrives and then quietly optimizes against no
counts at all.
gcc’s own measurement is the argument for the split. -fprofile-use on a file with no counts
beside it produces an object byte for byte identical to the one no flag produces, and warns; the
same file under -fprofile-generate grows from 71 bytes of code to 375 with 296 bytes of
counters beside it. So one half of the family is already a no-op in gcc when there is nothing to
read, and the other half is never one.
Fields§
§requested: boolWhether the last of -fprofile-use and -fno-profile-use on the command line was the
first of the two.
path: Option<String>Where to read the counts from, from -fprofile-use=<path>, where None means beside the
object the way gcc looks when nobody says. A directory or a file, which is gcc’s rule and
is not something this can tell apart without looking at the filesystem.
dir: Option<String>Where the whole family’s files live, from -fprofile-dir=. Separate from path because
gcc keeps them separate: this one moves the counts for the generating half as well.
absolute: boolWhether the path recorded in those files is made absolute, from -fprofile-abs-path. It is
what a build with several object directories under one source tree needs so that two files
of the same name do not land on one set of counts.
correction: boolWhether counts that do not add up are repaired rather than refused, from
-fprofile-correction. A program that forked or was killed while it ran leaves counts that
no single execution could have produced, and this says to make the best of them.
partial_training: boolWhether the parts of the program the training run never reached are optimized as if they
were cold rather than as if nothing were known about them, from -fprofile-partial-training.