[profile] Update counter offset to account for binary ids

In the raw profile, binary ids immediately follow the header so when
computing counters offset we need to account for the new section.

Differential Revision: https://reviews.llvm.org/D108608
This commit is contained in:
Petr Hosek 2021-08-23 21:24:24 -07:00
parent d95d2a8e4a
commit 8111f2f7ee
2 changed files with 3 additions and 2 deletions

View File

@ -591,7 +591,7 @@ static void initializeProfileForContinuousMode(void) {
return;
}
const uint64_t CountersOffsetInBiasMode =
sizeof(__llvm_profile_header) +
sizeof(__llvm_profile_header) + __llvm_write_binary_ids(NULL) +
(DataSize * sizeof(__llvm_profile_data));
/* Update the profile fields based on the current mapping. */
INSTR_PROF_PROFILE_COUNTER_BIAS_VAR = (intptr_t)Profile -

View File

@ -120,7 +120,8 @@ void __llvm_profile_initialize(void) {
const uint64_t *CountersEnd = __llvm_profile_end_counters();
const uint64_t DataSize = __llvm_profile_get_data_size(DataBegin, DataEnd);
const uint64_t CountersOffset =
sizeof(__llvm_profile_header) + (DataSize * sizeof(__llvm_profile_data));
sizeof(__llvm_profile_header) + __llvm_write_binary_ids(NULL) +
(DataSize * sizeof(__llvm_profile_data));
uint64_t CountersSize = CountersEnd - CountersBegin;
/* Don't publish a VMO if there are no counters. */