[llvm][profile] Add padding after binary IDs
authorLeonard Chan <leonardchan@google.com>
Tue, 28 Sep 2021 18:49:37 +0000 (11:49 -0700)
committerLeonard Chan <leonardchan@google.com>
Tue, 28 Sep 2021 18:50:50 +0000 (11:50 -0700)
commitb9f547e8e51182d32f1912f97a3e53f4899ea6be
tree899219c8f771bae91ba945eefd444747a4e18fef
parent9b944c184396ce55a3ad608779cc326ba12c9ee3
[llvm][profile] Add padding after binary IDs

Some tests with binary IDs would fail with error: no profile can be merged.
This is because raw profiles could have unaligned headers when emitting binary
IDs. This means padding should be emitted after binary IDs are emitted to
ensure everything else is aligned. This patch adds padding after each binary ID
to ensure the next binary ID size is 8-byte aligned. This also adds extra
checks to ensure we aren't reading corrupted data when printing binary IDs.

Differential Revision: https://reviews.llvm.org/D110365
compiler-rt/lib/profile/InstrProfilingPlatformLinux.c
compiler-rt/test/profile/Linux/binary-id-padding.c [new file with mode: 0644]
llvm/lib/ProfileData/InstrProfReader.cpp
llvm/test/tools/llvm-profdata/binary-ids-padding.test [new file with mode: 0644]
llvm/test/tools/llvm-profdata/insufficient-binary-ids-size.test [new file with mode: 0644]
llvm/test/tools/llvm-profdata/large-binary-id-size.test [new file with mode: 0644]
llvm/test/tools/llvm-profdata/misaligned-binary-ids-size.test [new file with mode: 0644]