I am looking into using llvm tools to generate block level profile of small programs. It looks like in older versions this was as simple as running:
perl utils/profile.pl -block program.bc
How is profiling done in newer versions of LLVM?
Use Clang and llvm-profdata
Visit the Clang User's Manual profile with instrumentation
llvm doc llvm-profdata
In summary:
Build an instrumented version of the code
clang -O2 -fprofile-instr-generate code.c
Run the instrumented executable to get the profile data file
./a.out
Combine profiles from multiple runs and format the files by running
llvm-profdata merge *.profraw -output=code.profdata
Build the code again
clang -O2 -fprofile-instr-use=code.profdata code.c
(Optional?) 5. Display the profile counters for this file and for any of the specified function(s)
llvm-profdata show -all-functions code.profdata