@@ -237,46 +237,24 @@ static int mmapForContinuousMode(uint64_t CurrentFileOffset, FILE *File) {
237
237
const char * CountersEnd = __llvm_profile_end_counters ();
238
238
const char * BitmapBegin = __llvm_profile_begin_bitmap ();
239
239
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 );
243
240
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 );
248
241
/* Get the file size. */
249
242
uint64_t FileSize = 0 ;
250
243
if (getProfileFileSizeForMerging (File , & FileSize ))
251
244
return 1 ;
252
245
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
-
270
246
/* Map the profile. */
271
247
char * Profile = (char * )mmap (NULL , FileSize , PROT_READ | PROT_WRITE ,
272
- MAP_SHARED , Fileno , 0 );
248
+ MAP_SHARED , fileno ( File ) , 0 );
273
249
if (Profile == MAP_FAILED ) {
274
250
PROF_ERR ("Unable to mmap profile: %s\n" , strerror (errno ));
275
251
return 1 ;
276
252
}
253
+ const uint64_t CountersOffsetInBiasMode =
254
+ sizeof (__llvm_profile_header ) + __llvm_write_binary_ids (NULL ) + DataSize ;
277
255
/* Update the profile fields based on the current mapping. */
278
256
INSTR_PROF_PROFILE_COUNTER_BIAS_VAR =
279
- (intptr_t )Profile - (uintptr_t )CountersBegin + FileOffsetToCounters ;
257
+ (intptr_t )Profile - (uintptr_t )CountersBegin + CountersOffsetInBiasMode ;
280
258
281
259
/* Return the memory allocated for counters to OS. */
282
260
lprofReleaseMemoryPagesToOS ((uintptr_t )CountersBegin , (uintptr_t )CountersEnd );
0 commit comments