Skip to content

Commit

Permalink
mmapForContinuousMode: Redo llvm#95702: Align Linux's impl to __APPLE…
Browse files Browse the repository at this point in the history
…__'s a little.

I've made this small cosmetic changes,
`s/CountersOffsetInBiasMode/FileOffsetToCounters/`
  • Loading branch information
chapuni committed Jun 21, 2024
1 parent aafa0ef commit 2fe8498
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions compiler-rt/lib/profile/InstrProfilingFile.c
Original file line number Diff line number Diff line change
Expand Up @@ -243,18 +243,20 @@ static int mmapForContinuousMode(uint64_t CurrentFileOffset, FILE *File) {
if (getProfileFileSizeForMerging(File, &FileSize))
return 1;

int Fileno = fileno(File);
uint64_t FileOffsetToCounters =
sizeof(__llvm_profile_header) + __llvm_write_binary_ids(NULL) + DataSize;

/* Map the profile. */
char *Profile = (char *)mmap(NULL, FileSize, PROT_READ | PROT_WRITE,
MAP_SHARED, fileno(File), 0);
MAP_SHARED, Fileno, 0);
if (Profile == MAP_FAILED) {
PROF_ERR("Unable to mmap profile: %s\n", strerror(errno));
return 1;
}
const uint64_t CountersOffsetInBiasMode =
sizeof(__llvm_profile_header) + __llvm_write_binary_ids(NULL) + DataSize;
/* Update the profile fields based on the current mapping. */
INSTR_PROF_PROFILE_COUNTER_BIAS_VAR =
(intptr_t)Profile - (uintptr_t)CountersBegin + CountersOffsetInBiasMode;
(intptr_t)Profile - (uintptr_t)CountersBegin + FileOffsetToCounters;

/* Return the memory allocated for counters to OS. */
lprofReleaseMemoryPagesToOS((uintptr_t)CountersBegin, (uintptr_t)CountersEnd);
Expand Down

0 comments on commit 2fe8498

Please sign in to comment.