How to generate the perfscript file for llvm-profgen

I’m really interested in the new CSSPGO tool, can anyone give me some more detailed instructions about how to generate the perfscript file it needs, I tried to first use “perf record -e xxx -b …” to generate a file and then use “perf script” to dump all the text into a perfscript file, but it seems to be different from the perfscript under the llvm/test/tools/llvm-profgen/Inputs directory.


Thanks for trying it out!

To get context-sensitive profile, you will need to collect perf data with both LBR and stack sample enabled. We use something like this:

perf record -g --call-graph fp -e br_inst_retired.near_taken:uppp -c 16009 -b -o <perf_data_output> <command_to_profile>

Here’s the perf script command to extract both LBR and stack sample:

perf script -F ip,brstack -i <perf_data_output> --show-mmap-event &> <perf_script_output>

Let us know how it works.