Llvm-profgen with non-LBR profiles

Hi!

I’ve read the updated documentation about Sampling PGO in Clang (link) and found a mention about a new (for me) tool for converting Linux Perf profiles into LLVM-compatible profiles - llvm-profgen.

According to the help in llvm-profgen, Linux Perf profiles should be created with “perf record -b” (enabled LBR). However, it’s not clear right now - does llvm-profgen work with non-LBR profiles or not since the “should” word does not enforce this requirement (instead of “must”). I quickly checked the sources for llvm-profgen, and it seems like the tool works only with LBR profiles.

Does llvm-profgen support non-LBR profiles? If not, I suggest fixing the llvm-profgen help and writing a note about LBR-only supported profiles in the Clang documentation about Sampling PGO (like it’s already done for create_llvm_prof).

Thank you.

I did some quick tests with Redis. I compiled Redis with -gline-tables-only, collected a perf profile with perf record redis-server (without -b flag since my CPU does not support LBR/BRS), then ran llvm-profgen --binary=./src/redis-server --output=code.prof --perfdata=perf.data, and got the following error:

llvm-profgen: error: Invalid perf script input!

At least for now, I can conclude that llvm-profgen does not work without LBR samples in the perf profile.