[PATCH] ProfileData: A library for reading and writing profiling data

Justin Bogner mail at justinbogner.com
Fri Mar 14 10:27:54 PDT 2014


Diego Novillo <dnovillo at google.com> writes:
> ================
> Comment at: include/llvm/ProfileData/InstrProf.h:11
> @@ +10,3 @@
> +// This file contains support for instrumentation based PGO and coverage.
> +//
> +//===----------------------------------------------------------------------===//
> ----------------
> Document the file format here?

Done.

> ================
> Comment at: include/llvm/ProfileData/InstrProfReader.h:82
> @@ +81,3 @@
> +  /// Return the maximum of all known function counts.
> +  uint64_t getMaximumFunctionCount() { return MaxFunctionCount; }
> +
> ----------------
> Curious. What is this used for?

Currently, it's used to figure out the call frequency of a given
function, relative to the function that's called most in the program.
This feeds adding inline and cold attributes to functions.

> ================
> Comment at: lib/ProfileData/InstrProfReader.cpp:148
> @@ +147,3 @@
> +                                              uint64_t &FunctionHash,
> +                                              std::vector<uint64_t> &Counts) {
> +  InstrProfCursor Cursor(DataBuffer.get());
> ----------------
> So, once you get this vector of Counts from here. Do you walk down the
> AST of the function assigning weights in sequence? What does each
> entry in 'Counts' represent? Is that the instrumented count
> corresponding to a line of code?

We walk the AST and assign counters to particular control flow
expressions, yes.  What each count represents depends on the type of
control flow - there's a counter at the start of the true block of an if
statement, a counter inside a loop body, one after a label, etc.

The counters are documented in tools/clang/lib/CodeGen/CodeGenPGO.cpp,
in the MapRegionCounters struct.



More information about the llvm-commits mailing list