Skip to content

Commit

Permalink
Update counter offset to account for binary ids
Browse files Browse the repository at this point in the history
In the raw profile, binary ids immediately follow the header so when
computing counters offset we need to account for the new section.

(cherry picked from commit 8111f2f)
  • Loading branch information
gulfemsavrun authored and tstellar committed Sep 8, 2021
1 parent 09f6594 commit 427df19
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions compiler-rt/lib/profile/InstrProfilingFile.c
Original file line number Diff line number Diff line change
Expand Up @@ -657,8 +657,9 @@ static void initializeProfileForContinuousMode(void) {
const uint64_t *CountersBegin = __llvm_profile_begin_counters();
const uint64_t *CountersEnd = __llvm_profile_end_counters();
uint64_t DataSize = __llvm_profile_get_data_size(DataBegin, DataEnd);
const uint64_t CountersOffset =
sizeof(__llvm_profile_header) + (DataSize * sizeof(__llvm_profile_data));
const uint64_t CountersOffset = sizeof(__llvm_profile_header) +
__llvm_write_binary_ids(NULL) +
(DataSize * sizeof(__llvm_profile_data));

int Length = getCurFilenameLength();
char *FilenameBuf = (char *)COMPILER_RT_ALLOCA(Length + 1);
Expand Down
5 changes: 3 additions & 2 deletions compiler-rt/lib/profile/InstrProfilingPlatformFuchsia.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,9 @@ void __llvm_profile_initialize(void) {
const uint64_t *CountersBegin = __llvm_profile_begin_counters();
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));
const uint64_t CountersOffset = 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. */
Expand Down

0 comments on commit 427df19

Please sign in to comment.