[AutoFDO][llvm-profgen] Profile generation for LBR(non-CS) sample
authorwlei <wlei@fb.com>
Thu, 23 Sep 2021 03:00:24 +0000 (20:00 -0700)
committerwlei <wlei@fb.com>
Fri, 24 Sep 2021 20:55:34 +0000 (13:55 -0700)
commitd5f2013004ef8d2d9995fd45a154744bf7c264e9
tree9de94bac9a4b71cf8c8f88f4e8933a2dddd72f65
parent2a876a711dc7c644936017daf20e78f48bfd2270
[AutoFDO][llvm-profgen] Profile generation for LBR(non-CS) sample

This patch introduces non-CS AutoFDO profile generation into LLVM. The profile is supposed to be well consumed by compiler using `-fprofile-sample-use=[profile]`.

After range and branch counters are extracted from the LBR sample, here we go through each addresses for symbolization, create FunctionSamples and populate its sub fields like TotalSamples, BodySamples and HeadSamples etc. For inlined code, as we need to map back to original code, so we always add body samples to the leaf frame's function sample.

Reviewed By: wenlei, hoy

Differential Revision: https://reviews.llvm.org/D109551
llvm/test/tools/llvm-profgen/Inputs/inline-noprobe.perfbin [new file with mode: 0755]
llvm/test/tools/llvm-profgen/Inputs/inline-noprobe.perfscript [new file with mode: 0644]
llvm/test/tools/llvm-profgen/Inputs/inline-noprobe2.perfbin [new file with mode: 0755]
llvm/test/tools/llvm-profgen/Inputs/inline-noprobe2.perfscript [new file with mode: 0644]
llvm/test/tools/llvm-profgen/inline-noprobe.test [new file with mode: 0644]
llvm/test/tools/llvm-profgen/inline-noprobe2.test [new file with mode: 0644]
llvm/test/tools/llvm-profgen/noinline-noprobe.test [moved from llvm/test/tools/llvm-profgen/noprobe.test with 83% similarity]
llvm/tools/llvm-profgen/ProfileGenerator.cpp
llvm/tools/llvm-profgen/ProfileGenerator.h
llvm/tools/llvm-profgen/ProfiledBinary.h
llvm/tools/llvm-profgen/llvm-profgen.cpp