[PATCH] D22028: [PGO] Don't include full file path in static function profile counter names
Sean Silva via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 8 17:36:01 PDT 2016
silvas added a comment.
For posterity, I want to expand a bit on Jake's explanation:
> When the training build and the profile guided build are in different directories, we end up just dropping the profile data and get a warning about unprofiled functions.
To expand on Jake's explanation of this issue, the issue we ran into when building one of our games is actually slightly more complicated than he described. The main complication is that the build generates source files into the build directory. Thus, different build directories (as one might use for separate prof-gen and prof-use builds) cause issues.
During the build, `SOURCE_DIR/foo/bar/baz.cpp` files are processed by a special tool into `BUILD_DIR/foo/bar/baz.hashed.cpp` before being passed to the compiler (essentially, the tool replaces certain marked strings with an integer hash code of the string).
During a PGO build, the following happens:
1. The prof-gen build is done into `PGO_TRAIN_BUILD_DIR`. Thus, counters for *all* static functions end up with a name like `PGO_TRAIN_BUILD_DIR/foo/bar/baz.hashed.cpp:funcname`.
2. The prof-use build is done into `PGO_BUILD_DIR`. Thus, the counter name that is expected is `PGO_BUILD_DIR/foo/bar/baz.hashed.cpp:funcname`. Thus, the counter is not found. This affects *all* static functions.
Pre-inline mitigates the issue significantly (since static functions are likely to be inlined), but we still saw it occur in practice.
More information about the llvm-commits