From 8111f2f7eef50f8c0cdfd4b575e275c0c4b7fc41 Mon Sep 17 00:00:00 2001 From: Petr Hosek Date: Mon, 23 Aug 2021 21:24:24 -0700 Subject: [PATCH] [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 --- compiler-rt/lib/profile/InstrProfilingFile.c | 2 +- compiler-rt/lib/profile/InstrProfilingPlatformFuchsia.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/compiler-rt/lib/profile/InstrProfilingFile.c b/compiler-rt/lib/profile/InstrProfilingFile.c index fb4c2fecefacb..1c53a3f172f71 100644 --- a/compiler-rt/lib/profile/InstrProfilingFile.c +++ b/compiler-rt/lib/profile/InstrProfilingFile.c @@ -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 - diff --git a/compiler-rt/lib/profile/InstrProfilingPlatformFuchsia.c b/compiler-rt/lib/profile/InstrProfilingPlatformFuchsia.c index 0146b14c193fc..7de6aa83f8afa 100644 --- a/compiler-rt/lib/profile/InstrProfilingPlatformFuchsia.c +++ b/compiler-rt/lib/profile/InstrProfilingPlatformFuchsia.c @@ -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. */