@@ -1311,43 +1311,33 @@ Error IndexedInstrProfReader::readHeader() {
1311
1311
const IndexedInstrProf::Header *Header = &HeaderOr.get ();
1312
1312
Cur += Header->size ();
1313
1313
1314
- Cur = readSummary ((IndexedInstrProf::ProfVersion)Header->formatVersion () , Cur,
1314
+ Cur = readSummary ((IndexedInstrProf::ProfVersion)Header->Version , Cur,
1315
1315
/* UseCS */ false );
1316
- if (Header->formatVersion () & VARIANT_MASK_CSIR_PROF)
1317
- Cur =
1318
- readSummary ((IndexedInstrProf::ProfVersion)Header->formatVersion (), Cur,
1319
- /* UseCS */ true );
1316
+ if (Header->Version & VARIANT_MASK_CSIR_PROF)
1317
+ Cur = readSummary ((IndexedInstrProf::ProfVersion)Header->Version , Cur,
1318
+ /* UseCS */ true );
1320
1319
// Read the hash type and start offset.
1321
- IndexedInstrProf::HashT HashType = static_cast <IndexedInstrProf::HashT>(
1322
- endian::byte_swap< uint64_t , llvm::endianness::little >(Header->HashType ) );
1320
+ IndexedInstrProf::HashT HashType =
1321
+ static_cast <IndexedInstrProf::HashT >(Header->HashType );
1323
1322
if (HashType > IndexedInstrProf::HashT::Last)
1324
1323
return error (instrprof_error::unsupported_hash_type);
1325
1324
1326
- uint64_t HashOffset =
1327
- endian::byte_swap<uint64_t , llvm::endianness::little>(Header->HashOffset );
1328
-
1329
1325
// The hash table with profile counts comes next.
1330
1326
auto IndexPtr = std::make_unique<InstrProfReaderIndex<OnDiskHashTableImplV3>>(
1331
- Start + HashOffset, Cur, Start, HashType, Header->formatVersion () );
1327
+ Start + Header-> HashOffset , Cur, Start, HashType, Header->Version );
1332
1328
1333
1329
// The MemProfOffset field in the header is only valid when the format
1334
1330
// version is higher than 8 (when it was introduced).
1335
- if (GET_VERSION (Header->formatVersion ()) >= 8 &&
1336
- Header->formatVersion () & VARIANT_MASK_MEMPROF) {
1337
- uint64_t MemProfOffset =
1338
- endian::byte_swap<uint64_t , llvm::endianness::little>(
1339
- Header->MemProfOffset );
1340
- if (Error E = MemProfReader.deserialize (Start, MemProfOffset))
1331
+ if (GET_VERSION (Header->Version ) >= 8 &&
1332
+ Header->Version & VARIANT_MASK_MEMPROF) {
1333
+ if (Error E = MemProfReader.deserialize (Start, Header->MemProfOffset ))
1341
1334
return E;
1342
1335
}
1343
1336
1344
1337
// BinaryIdOffset field in the header is only valid when the format version
1345
1338
// is higher than 9 (when it was introduced).
1346
- if (GET_VERSION (Header->formatVersion ()) >= 9 ) {
1347
- uint64_t BinaryIdOffset =
1348
- endian::byte_swap<uint64_t , llvm::endianness::little>(
1349
- Header->BinaryIdOffset );
1350
- const unsigned char *Ptr = Start + BinaryIdOffset;
1339
+ if (GET_VERSION (Header->Version ) >= 9 ) {
1340
+ const unsigned char *Ptr = Start + Header->BinaryIdOffset ;
1351
1341
// Read binary ids size.
1352
1342
BinaryIdsSize =
1353
1343
support::endian::readNext<uint64_t , llvm::endianness::little>(Ptr);
@@ -1360,11 +1350,8 @@ Error IndexedInstrProfReader::readHeader() {
1360
1350
" corrupted binary ids" );
1361
1351
}
1362
1352
1363
- if (GET_VERSION (Header->formatVersion ()) >= 12 ) {
1364
- uint64_t VTableNamesOffset =
1365
- endian::byte_swap<uint64_t , llvm::endianness::little>(
1366
- Header->VTableNamesOffset );
1367
- const unsigned char *Ptr = Start + VTableNamesOffset;
1353
+ if (GET_VERSION (Header->Version ) >= 12 ) {
1354
+ const unsigned char *Ptr = Start + Header->VTableNamesOffset ;
1368
1355
1369
1356
CompressedVTableNamesLen =
1370
1357
support::endian::readNext<uint64_t , llvm::endianness::little>(Ptr);
@@ -1376,12 +1363,9 @@ Error IndexedInstrProfReader::readHeader() {
1376
1363
return make_error<InstrProfError>(instrprof_error::truncated);
1377
1364
}
1378
1365
1379
- if (GET_VERSION (Header->formatVersion ()) >= 10 &&
1380
- Header->formatVersion () & VARIANT_MASK_TEMPORAL_PROF) {
1381
- uint64_t TemporalProfTracesOffset =
1382
- endian::byte_swap<uint64_t , llvm::endianness::little>(
1383
- Header->TemporalProfTracesOffset );
1384
- const unsigned char *Ptr = Start + TemporalProfTracesOffset;
1366
+ if (GET_VERSION (Header->Version ) >= 10 &&
1367
+ Header->Version & VARIANT_MASK_TEMPORAL_PROF) {
1368
+ const unsigned char *Ptr = Start + Header->TemporalProfTracesOffset ;
1385
1369
const auto *PtrEnd = (const unsigned char *)DataBuffer->getBufferEnd ();
1386
1370
// Expect at least two 64 bit fields: NumTraces, and TraceStreamSize
1387
1371
if (Ptr + 2 * sizeof (uint64_t ) > PtrEnd)
0 commit comments