A few weeks ago, I announced the availability of a conversion tool that converts Linux Perf sample profiles to LLVM’s sample profiler (https://github.com/google/autofdo).
I have now ported this tool to the LLVM tree, so it can be made available as part of LLVM. I’ve got a working version, but I still need to massage the code to use LLVM’s own libraries (logging, flags, etc) and adapt it to LLVM’s coding guidelines.
I expect to have an initial patch ready in a few days. In the meantime, I would like to open it up for some bike shedding on how this tool will integrate with LLVM. I cannot guarantee that I’ll agree to address all feedback myself, but I do want to make sure that the major issues and direction are addressed.
The tool receives two inputs: a profile file and an ELF executable (built with -gmlt). It produces as output a profile in the format expected by -fprofile-sample-use.
The requirements on the input is that we must be able to map counts to specific source file locations. So, the profiling source must be some kind of sample-based instruction execution counter. Anything that keeps track of how frequently a specific instruction has been executed.
Using the executable’s line table information, the tool maps instruction locations back to source locations.
Currently, the native profile reader for Linux Perf and the writer for LLVM’s profile are part of the same tree. They both reside in llvm/tools/llvm-prof-converter.
I would like to support more than Linux Perf, eventually. So, I’m thinking that I want to move the LLVM profile writer to llvm/lib/ProfileData and only have the various readers under llvm/tools/llvm-prof-converter.
I don’t think I will be working on supporting anything other than Linux Perf for now. But if anyone is interested in supporting profilers in other platforms, please let me know. I want to make sure the implementation doesn’t tie itself too much to Linux Perf.
Thanks. Diego.