[llvm-profgen] Fix inconsistent loading address issues
authorwlei <wlei@fb.com>
Fri, 14 Oct 2022 03:42:51 +0000 (20:42 -0700)
committerwlei <wlei@fb.com>
Fri, 14 Oct 2022 06:19:30 +0000 (23:19 -0700)
commit467652486f24b9f33eca7b4aaa6cb1e8ec6d18a7
tree5ea5289dccb7b9f724146759436bef4d7daac9f1
parent4d3a0cade2ed0bdc87256c197215691c2e279ed0
[llvm-profgen] Fix inconsistent loading address issues

This is to fix two issues related with loading address:

1) When multiple MMAPs occur and their loading address are different, before it only used the first MMap as base address, all perf address after it used the wrong base address.

2) For pseudo probe profile, the address is always based on preferred loading address. If the base address is not equal to the preferred loading address, the pseudo probe address query will be wrong.

Solution: Instead of converting the address to offset lazily, right now all the address after parsing are converted on the fly based on preferred loading address in the parsing time. There is no "offset" used in profile generator any more.

Reviewed By: hoy, wenlei

Differential Revision: https://reviews.llvm.org/D126827
llvm/test/tools/llvm-profgen/Inputs/noinline-cs-pseudoprobe.perfscript
llvm/test/tools/llvm-profgen/inline-noprobe2.test
llvm/test/tools/llvm-profgen/invalid-range.test
llvm/test/tools/llvm-profgen/pseudoprobe-decoding.test
llvm/tools/llvm-profgen/PerfReader.cpp
llvm/tools/llvm-profgen/ProfileGenerator.cpp
llvm/tools/llvm-profgen/ProfileGenerator.h
llvm/tools/llvm-profgen/ProfiledBinary.cpp
llvm/tools/llvm-profgen/ProfiledBinary.h