[profile] Fix profile merging with binary IDs
authorPetr Hosek <phosek@google.com>
Fri, 30 Jul 2021 09:40:27 +0000 (02:40 -0700)
committerPetr Hosek <phosek@google.com>
Sat, 31 Jul 2021 01:54:27 +0000 (18:54 -0700)
commit83302c84890e5e6cb74c7d6c9f8eaaa56db0077c
treeeb426ad5fb617f4d603c952566314597b9048980
parentd3dd07e3d05a72da8834044d2efa885845c7d879
[profile] Fix profile merging with binary IDs

This fixes support for merging profiles which broke as a consequence
of e50a38840dc3db5813f74b1cd2e10e6d984d0e67. The issue was missing
adjustment in merge logic to account for the binary IDs which are
now included in the raw profile just after header.

In addition, this change also:
* Includes the version in module signature that's used for merging
to avoid accidental attempts to merge incompatible profiles.
* Moves the binary IDs size field after version field in the header
as was suggested in the review.

Differential Revision: https://reviews.llvm.org/D107143
15 files changed:
compiler-rt/include/profile/InstrProfData.inc
compiler-rt/lib/profile/InstrProfilingBuffer.c
compiler-rt/lib/profile/InstrProfilingMerge.c
compiler-rt/test/profile/Linux/binary-id.c
llvm/include/llvm/ProfileData/InstrProf.h
llvm/include/llvm/ProfileData/InstrProfData.inc
llvm/lib/ProfileData/InstrProfReader.cpp
llvm/test/tools/llvm-profdata/Inputs/c-general.profraw
llvm/test/tools/llvm-profdata/Inputs/compressed.profraw
llvm/test/tools/llvm-profdata/malformed-ptr-to-counter-array.test
llvm/test/tools/llvm-profdata/raw-32-bits-be.test
llvm/test/tools/llvm-profdata/raw-32-bits-le.test
llvm/test/tools/llvm-profdata/raw-64-bits-be.test
llvm/test/tools/llvm-profdata/raw-64-bits-le.test
llvm/test/tools/llvm-profdata/raw-two-profiles.test