[CSSPGO][llvm-profgen] Disassemble text sections
authorwlei <wlei@fb.com>
Mon, 19 Oct 2020 17:02:05 +0000 (10:02 -0700)
committerwlei <wlei@fb.com>
Fri, 20 Nov 2020 22:26:26 +0000 (14:26 -0800)
commit32221694cb927b6acc7a8e16af7155e4e31418a4
treec07f2b70d7c45cd601194a65ff48caaa81fe1bba
parenta94fa8622971fa800d8f82c05b57117ff0372897
[CSSPGO][llvm-profgen] Disassemble text sections

This stack of changes introduces `llvm-profgen` utility which generates a profile data file from given perf script data files for sample-based PGO. It’s part of(not only) the CSSPGO work. Specifically to support context-sensitive with/without pseudo probe profile, it implements a series of functionalities including perf trace parsing, instruction symbolization, LBR stack/call frame stack unwinding, pseudo probe decoding, etc. Also high throughput is achieved by multiple levels of sample aggregation and compatible format with one stop is generated at the end. Please refer to: https://groups.google.com/g/llvm-dev/c/1p1rdYbL93s for the CSSPGO RFC.

This change enables disassembling the text sections to build various address maps that are potentially used by the virtual unwinder.  A switch `--show-disassembly` is being added to print the disassembly code.

Like the llvm-objdump tool, this change leverages existing LLVM components to parse and disassemble ELF binary files. So far X86 is supported.

Test Plan:

ninja check-llvm

Reviewed By: wmi, wenlei

Differential Revision: https://reviews.llvm.org/D89712
llvm/docs/CommandGuide/llvm-profgen.rst
llvm/test/tools/llvm-profgen/disassemble.s [new file with mode: 0644]
llvm/test/tools/llvm-profgen/lit.local.cfg
llvm/test/tools/llvm-profgen/mmapEvent.test
llvm/tools/llvm-profgen/CMakeLists.txt
llvm/tools/llvm-profgen/ErrorHandling.h
llvm/tools/llvm-profgen/LLVMBuild.txt
llvm/tools/llvm-profgen/PerfReader.cpp
llvm/tools/llvm-profgen/ProfiledBinary.cpp [new file with mode: 0644]
llvm/tools/llvm-profgen/ProfiledBinary.h
llvm/tools/llvm-profgen/llvm-profgen.cpp