[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 00:38:53 +0000 (17:38 -0700)
commitdcadd64986b8a84dc244d4e7faa848fb4c18cea6
tree4228e73cb05060ee1a09a6d4c56537f02d069e25
parent03b2d1a659228bc2fe7972357d9b8b41eda2f558
[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
14 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/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