Skip to content

Commit e908320

Browse files
committed
Revert "mmapForContinuousMode: Align Linux's impl to __APPLE__'s more. NFC. (#95702)"
This reverts commit 7cf84d3. (llvmorg-19-init-14939-g7cf84d3b0bc5) This has my wrong assumptions possibly. This was failing fuchsia.
1 parent f477784 commit e908320

File tree

1 file changed

+4
-26
lines changed

1 file changed

+4
-26
lines changed

compiler-rt/lib/profile/InstrProfilingFile.c

Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -237,46 +237,24 @@ static int mmapForContinuousMode(uint64_t CurrentFileOffset, FILE *File) {
237237
const char *CountersEnd = __llvm_profile_end_counters();
238238
const char *BitmapBegin = __llvm_profile_begin_bitmap();
239239
const char *BitmapEnd = __llvm_profile_end_bitmap();
240-
const char *NamesBegin = __llvm_profile_begin_names();
241-
const char *NamesEnd = __llvm_profile_end_names();
242-
const uint64_t NamesSize = (NamesEnd - NamesBegin) * sizeof(char);
243240
uint64_t DataSize = __llvm_profile_get_data_size(DataBegin, DataEnd);
244-
uint64_t CountersSize =
245-
__llvm_profile_get_counters_size(CountersBegin, CountersEnd);
246-
uint64_t NumBitmapBytes =
247-
__llvm_profile_get_num_bitmap_bytes(BitmapBegin, BitmapEnd);
248241
/* Get the file size. */
249242
uint64_t FileSize = 0;
250243
if (getProfileFileSizeForMerging(File, &FileSize))
251244
return 1;
252245

253-
int Fileno = fileno(File);
254-
/* Determine how much padding is needed before/after the counters and
255-
* after the names. */
256-
uint64_t PaddingBytesBeforeCounters, PaddingBytesAfterCounters,
257-
PaddingBytesAfterNames, PaddingBytesAfterBitmapBytes,
258-
PaddingBytesAfterVTable, PaddingBytesAfterVNames;
259-
__llvm_profile_get_padding_sizes_for_counters(
260-
DataSize, CountersSize, NumBitmapBytes, NamesSize, /*VTableSize=*/0,
261-
/*VNameSize=*/0, &PaddingBytesBeforeCounters, &PaddingBytesAfterCounters,
262-
&PaddingBytesAfterBitmapBytes, &PaddingBytesAfterNames,
263-
&PaddingBytesAfterVTable, &PaddingBytesAfterVNames);
264-
265-
CurrentFileOffset = 0;
266-
uint64_t FileOffsetToCounters = CurrentFileOffset +
267-
sizeof(__llvm_profile_header) + DataSize +
268-
PaddingBytesBeforeCounters;
269-
270246
/* Map the profile. */
271247
char *Profile = (char *)mmap(NULL, FileSize, PROT_READ | PROT_WRITE,
272-
MAP_SHARED, Fileno, 0);
248+
MAP_SHARED, fileno(File), 0);
273249
if (Profile == MAP_FAILED) {
274250
PROF_ERR("Unable to mmap profile: %s\n", strerror(errno));
275251
return 1;
276252
}
253+
const uint64_t CountersOffsetInBiasMode =
254+
sizeof(__llvm_profile_header) + __llvm_write_binary_ids(NULL) + DataSize;
277255
/* Update the profile fields based on the current mapping. */
278256
INSTR_PROF_PROFILE_COUNTER_BIAS_VAR =
279-
(intptr_t)Profile - (uintptr_t)CountersBegin + FileOffsetToCounters;
257+
(intptr_t)Profile - (uintptr_t)CountersBegin + CountersOffsetInBiasMode;
280258

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

0 commit comments

Comments
 (0)