clangllvmprofilerpgo

Clang: do I have to pass -O0 when compiling with coverage for PGO


So I am compiling a big C++ program with clang 3.8. I want to make use of PGO (Profile guided optimization). I want to use the way of compiling in instrumentation to generate the profile.

Currently I am passing -fprofile-instr-generate --coverage to the compiler and --coverage to the Linker.

So now the question is whether it would be optimal to pass -O0 too, so the compiler can map back the calls from the binary during the next compilation properly. Or is that unnecessary?


Solution

  • It is unnecessary. Coverage will be the same on optimized code, otherwise it would be worrisome ;)

    For instance the clang coverage bot builds with -O3 -fprofile-instr-generate -fcoverage-mapping