Is profile data collection broken in clang-13?

Hello, I hop that this is the right place to ask this...

My system is Ubuntu 20.04.

I have a pretty standard build process for some C++ targets that runs a bunch of tests with instrumentation enabled (-fprofile-instr-generate and -fcoverage-mapping on compile and link) which has been working fine up until I changed from clang-12 to clang-13 tools.

Now llvm-profdata merge reports "warning: file.profraw: malformed instrumentation profile data" for each profraw file.

The only change is the tool chain.

"file" describes the profraw files as LLVM raw profile data, version 6. Running any other version of llvm-profdata produces "unsupported instrumentation profile format version" warnings, so the profraw file generation appears to be correctly generated.

Thanks,

Ian

Hi Ian,

I encountered the same issue after upgrading to clang-13. In my case the problem was related to profiling an application with a shared library. I believe the profraw file gets corrupted when two binaries (main executable and a shared library) are accessing it.

My solution is to add %m to LLVM_PROFILE_FILE. This way each binary will be using independent profile files.

See bug report: https://github.com/llvm/llvm-project/issues/50966.

Before clang-13 this scenario was working, but I’m not sure this was intended and supported.

Bests,
Paweł