pub struct Profile {
pub requested: bool,
pub path: Option<String>,
pub dir: Option<String>,
pub absolute: bool,
pub correction: bool,
pub partial_training: bool,
pub arcs: bool,
pub counts: Option<String>,
pub notes: 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. -fprofile-arcs is done, as Profile::arcs, and the rest of that half
is refused by the driver rather than landing here, on the same reading -gsplit-dwarf gets:
-ftest-coverage writes a .gcno beside the object, and ignoring it means a build waits for a
file that never arrives.
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.
arcs: boolWhether every function gets arc counters and the unit a record registering them, from
-fprofile-arcs. See rucc_opt::coverage.
counts: Option<String>The .gcda file the counters of this unit are written to, which the driver fills in for
each job from the object’s name, the working directory and -fprofile-dir=.
notes: boolWhether the graph the counters are on is written to a .gcno file beside the object, from
-ftest-coverage.