I’m glad to announce the availability of the AutoFDO converter for LLVM. This tool reads a profile generated with Linux Perf (https://perf.wiki.kernel.org/) and converts it into a format readable with LLVM’s sample-based profiler. The converter shares a significant amount of code with GCC’s converter tool (authored by Dehao Chen), so we can support both compilers with it.
At this time, I’m looking for volunteers to try out the tool and use it with their own code. There will be missing documentation, sharp edges and other issues typical of a tool that so far has had limited use.
To download and build the converter:
$ git clone https://github.com/google/autofdo.git autofdo
$ cd autofdo && ./configure && make
Note that you will need a compiler with C++11 support (either gcc 4.7+ or a recent Clang/LLVM).
To use the converter, you need to use Perf with a kernel that supports LBR (any kernel post 3.4 should suffice) and LLVM from trunk (there is some support in the 3.4 release, but there were changes post 3.4 that are only present in trunk). The workflow is:
$ clang++ -O2 -gline-tables-only code.cc -o code
$ perf record -b ./code
$ create_llvm_prof --binary=./code --out=code.prof
$ clang++ -O2 -fprofile-sample-use=code.prof code.cc -o code
The second version of ‘code’ should run faster than the first one. In theory.
For issues with the tool itself, please use the issue tracker in github (https://github.com/google/autofdo/issues). There is also a mailing list where you can ask questions about it (https://groups.google.com/forum/#!forum/autofdo)).