[compiler-rt] 8111f2f - [profile] Update counter offset to account for binary ids

Petr Hosek via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 23 21:44:53 PDT 2021


Author: Petr Hosek
Date: 2021-08-23T21:43:30-07:00
New Revision: 8111f2f7eef50f8c0cdfd4b575e275c0c4b7fc41

URL: https://github.com/llvm/llvm-project/commit/8111f2f7eef50f8c0cdfd4b575e275c0c4b7fc41
DIFF: https://github.com/llvm/llvm-project/commit/8111f2f7eef50f8c0cdfd4b575e275c0c4b7fc41.diff

LOG: [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

Added: 
    

Modified: 
    compiler-rt/lib/profile/InstrProfilingFile.c
    compiler-rt/lib/profile/InstrProfilingPlatformFuchsia.c

Removed: 
    


################################################################################
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. */


        


More information about the llvm-commits mailing list