diff --git a/llvm/include/llvm/ProfileData/InstrProfReader.h b/llvm/include/llvm/ProfileData/InstrProfReader.h index f1010b312ee56..2ad27b9925038 100644 --- a/llvm/include/llvm/ProfileData/InstrProfReader.h +++ b/llvm/include/llvm/ProfileData/InstrProfReader.h @@ -490,7 +490,7 @@ class RawInstrProfReader : public InstrProfReader { } StringRef getName(uint64_t NameRef) const { - return Symtab->getFuncOrVarName(swap(NameRef)); + return Symtab->getFuncOrVarName(Correlator ? NameRef : swap(NameRef)); } int getCounterTypeSize() const { diff --git a/llvm/lib/ProfileData/InstrProfCorrelator.cpp b/llvm/lib/ProfileData/InstrProfCorrelator.cpp index d92107f93dc56..8034cab5bd3f5 100644 --- a/llvm/lib/ProfileData/InstrProfCorrelator.cpp +++ b/llvm/lib/ProfileData/InstrProfCorrelator.cpp @@ -291,7 +291,7 @@ void InstrProfCorrelatorImpl::addDataProbe(uint64_t NameRef, maybeSwap(CFGHash), // In this mode, CounterPtr actually stores the section relative address // of the counter. - maybeSwap(CounterOffset), + CounterOffset, // TODO: MC/DC is not yet supported. /*BitmapOffset=*/maybeSwap(0), maybeSwap(FunctionPtr), diff --git a/llvm/lib/ProfileData/InstrProfReader.cpp b/llvm/lib/ProfileData/InstrProfReader.cpp index 4075b513c218d..b2cf592ee69d2 100644 --- a/llvm/lib/ProfileData/InstrProfReader.cpp +++ b/llvm/lib/ProfileData/InstrProfReader.cpp @@ -553,10 +553,11 @@ Error RawInstrProfReader::createSymtab(InstrProfSymtab &Symtab) { StringRef(VNamesStart, VNamesEnd - VNamesStart))) return error(std::move(E)); for (const RawInstrProf::ProfileData *I = Data; I != DataEnd; ++I) { - const IntPtrT FPtr = swap(I->FunctionPointer); + const IntPtrT FPtr = + Correlator ? I->FunctionPointer : swap(I->FunctionPointer); if (!FPtr) continue; - Symtab.mapAddress(FPtr, swap(I->NameRef)); + Symtab.mapAddress(FPtr, Correlator ? I->NameRef : swap(I->NameRef)); } if (VTableBegin != nullptr && VTableEnd != nullptr) { @@ -711,18 +712,20 @@ Error RawInstrProfReader::readName(NamedInstrProfRecord &Record) { template Error RawInstrProfReader::readFuncHash(NamedInstrProfRecord &Record) { - Record.Hash = swap(Data->FuncHash); + Record.Hash = Correlator ? Data->FuncHash : swap(Data->FuncHash); return success(); } template Error RawInstrProfReader::readRawCounts( InstrProfRecord &Record) { - uint32_t NumCounters = swap(Data->NumCounters); + uint32_t NumCounters = + Correlator ? Data->NumCounters : swap(Data->NumCounters); if (NumCounters == 0) return error(instrprof_error::malformed, "number of counters is zero"); - ptrdiff_t CounterBaseOffset = swap(Data->CounterPtr) - CountersDelta; + ptrdiff_t CounterBaseOffset = + Correlator ? Data->CounterPtr : swap(Data->CounterPtr) - CountersDelta; if (CounterBaseOffset < 0) return error( instrprof_error::malformed, @@ -754,8 +757,8 @@ Error RawInstrProfReader::readRawCounts( uint64_t TimestampValue = swap(*reinterpret_cast(Ptr)); if (TimestampValue != 0 && TimestampValue != std::numeric_limits::max()) { - TemporalProfTimestamps.emplace_back(TimestampValue, - swap(Data->NameRef)); + TemporalProfTimestamps.emplace_back( + TimestampValue, Correlator ? Data->NameRef : swap(Data->NameRef)); TemporalProfTraceStreamSize = 1; } if (hasSingleByteCoverage()) { @@ -785,7 +788,8 @@ Error RawInstrProfReader::readRawCounts( template Error RawInstrProfReader::readRawBitmapBytes(InstrProfRecord &Record) { - uint32_t NumBitmapBytes = swap(Data->NumBitmapBytes); + uint32_t NumBitmapBytes = + Correlator ? Data->NumBitmapBytes : swap(Data->NumBitmapBytes); Record.BitmapBytes.clear(); Record.BitmapBytes.reserve(NumBitmapBytes); @@ -796,7 +800,8 @@ Error RawInstrProfReader::readRawBitmapBytes(InstrProfRecord &Record) { return success(); // BitmapDelta decreases as we advance to the next data record. - ptrdiff_t BitmapOffset = swap(Data->BitmapPtr) - BitmapDelta; + ptrdiff_t BitmapOffset = + Correlator ? Data->BitmapPtr : swap(Data->BitmapPtr) - BitmapDelta; if (BitmapOffset < 0) return error( instrprof_error::malformed,