Lines Matching +full:hot +full:- +full:swap
1 //===- InstrProfReader.cpp - Instrumented profiling reader ----------------===//
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
12 //===----------------------------------------------------------------------===//
73 auto BufferOrErr = Filename.str() == "-" ? MemoryBuffer::getSTDIN() in setupMemoryBuffer()
89 /// Raw profiles are in host-endian format, and indexed profiles are in
90 /// little-endian format. So, this function takes an argument indicating the
111 size_t Remaining = BIEnd - BI; in readBinaryIdsInternal()
123 Remaining = BIEnd - BI; in readBinaryIdsInternal()
169 if (Buffer->getBufferSize() == 0) in create()
246 while (Line->starts_with(":")) { in readHeader()
247 StringRef Str = Line->substr(1); in readHeader()
282 if (Line->getAsInteger(0, NumTraces)) in readTemporalProfTraceData()
288 if (Line->getAsInteger(0, TemporalProfTraceStreamSize)) in readTemporalProfTraceData()
296 if (Line->getAsInteger(0, Trace.Weight)) in readTemporalProfTraceData()
303 Line->split(FuncNames, ",", /*MaxSplit=*/-1, /*KeepEmpty=*/false); in readTemporalProfTraceData()
331 if (Line->getAsInteger(10, NumValueKinds)) { in readValueProfileData()
356 std::pair<StringRef, StringRef> VD = Line->rsplit(':'); in readValueProfileData()
362 if (Error E = Symtab->addFuncName(VD.first)) in readValueProfileData()
370 if (Error E = Symtab->addVTableName(VD.first)) in readValueProfileData()
394 while (!Line.is_at_end() && (Line->empty() || Line->starts_with("#"))) in readNextRecord()
403 if (Error E = Symtab->addFuncName(Record.Name)) in readNextRecord()
409 if ((Line++)->getAsInteger(0, Record.Hash)) in readNextRecord()
417 if ((Line++)->getAsInteger(10, NumCounters)) in readNextRecord()
430 if ((Line++)->getAsInteger(10, Count)) in readNextRecord()
436 if (Line->starts_with("$")) { in readNextRecord()
440 if ((Line++)->drop_front(1).trim().getAsInteger(0, NumBitmapBytes)) in readNextRecord()
450 if ((Line++)->getAsInteger(0, BitmapByte)) in readNextRecord()
503 if (DataBuffer->getBufferSize() < sizeof(RawInstrProf::Header)) in readHeader()
506 DataBuffer->getBufferStart()); in readHeader()
507 ShouldSwapBytes = Header->Magic != RawInstrProf::getMagic<IntPtrT>(); in readHeader()
513 const char *End = DataBuffer->getBufferEnd(); in readNextHeader()
531 if (Magic != swap(RawInstrProf::getMagic<IntPtrT>())) in readNextHeader()
541 if (Error E = Symtab.create(StringRef(NamesStart, NamesEnd - NamesStart), in createSymtab()
542 StringRef(VNamesStart, VNamesEnd - VNamesStart))) in createSymtab()
545 const IntPtrT FPtr = swap(I->FunctionPointer); in createSymtab()
548 Symtab.mapAddress(FPtr, swap(I->NameRef)); in createSymtab()
554 const IntPtrT VPtr = swap(I->VTablePointer); in createSymtab()
559 // VPtr is of type uint32_t or uint64_t so 'VPtr + I->VTableSize' marks in createSymtab()
561 Symtab.mapVTableAddress(VPtr, VPtr + swap(I->VTableSize), in createSymtab()
562 swap(I->VTableNameHash)); in createSymtab()
571 Version = swap(Header.Version); in readHeader()
581 uint64_t BinaryIdSize = swap(Header.BinaryIdsSize); in readHeader()
586 const uint8_t *BufferEnd = (const uint8_t *)DataBuffer->getBufferEnd(); in readHeader()
596 CountersDelta = swap(Header.CountersDelta); in readHeader()
597 BitmapDelta = swap(Header.BitmapDelta); in readHeader()
598 NamesDelta = swap(Header.NamesDelta); in readHeader()
599 auto NumData = swap(Header.NumData); in readHeader()
600 auto PaddingBytesBeforeCounters = swap(Header.PaddingBytesBeforeCounters); in readHeader()
601 auto CountersSize = swap(Header.NumCounters) * getCounterTypeSize(); in readHeader()
602 auto PaddingBytesAfterCounters = swap(Header.PaddingBytesAfterCounters); in readHeader()
603 auto NumBitmapBytes = swap(Header.NumBitmapBytes); in readHeader()
604 auto PaddingBytesAfterBitmapBytes = swap(Header.PaddingBytesAfterBitmapBytes); in readHeader()
605 auto NamesSize = swap(Header.NamesSize); in readHeader()
606 auto VTableNameSize = swap(Header.VNamesSize); in readHeader()
607 auto NumVTables = swap(Header.NumVTables); in readHeader()
608 ValueKindLast = swap(Header.ValueKindLast); in readHeader()
633 if (Start + ValueDataOffset > DataBuffer->getBufferEnd()) in readHeader()
642 Data = Correlator->getDataPointer(); in readHeader()
643 DataEnd = Data + Correlator->getDataSize(); in readHeader()
644 NamesStart = Correlator->getNamesPointer(); in readHeader()
645 NamesEnd = NamesStart + Correlator->getNamesSize(); in readHeader()
676 Record.Name = getName(Data->NameRef); in readName()
682 Record.Hash = swap(Data->FuncHash); in readFuncHash()
689 uint32_t NumCounters = swap(Data->NumCounters); in readRawCounts()
693 ptrdiff_t CounterBaseOffset = swap(Data->CounterPtr) - CountersDelta; in readRawCounts()
699 if (CounterBaseOffset >= CountersEnd - CountersStart) in readRawCounts()
703 Twine(CountersEnd - CountersStart - 1)) in readRawCounts()
707 (CountersEnd - (CountersStart + CounterBaseOffset)) / in readRawCounts()
722 uint64_t TimestampValue = swap(*reinterpret_cast<const uint64_t *>(Ptr)); in readRawCounts()
726 swap(Data->NameRef)); in readRawCounts()
742 uint64_t CounterValue = swap(*reinterpret_cast<const uint64_t *>(Ptr)); in readRawCounts()
756 uint32_t NumBitmapBytes = swap(Data->NumBitmapBytes); in readRawBitmapBytes()
767 ptrdiff_t BitmapOffset = swap(Data->BitmapPtr) - BitmapDelta; in readRawBitmapBytes()
773 if (BitmapOffset >= BitmapEnd - BitmapStart) in readRawBitmapBytes()
777 Twine(BitmapEnd - BitmapStart - 1)) in readRawBitmapBytes()
781 (BitmapEnd - (BitmapStart + BitmapOffset)) / sizeof(uint8_t); in readRawBitmapBytes()
791 Record.BitmapBytes.push_back(swap(*Ptr)); in readRawBitmapBytes()
802 // Need to match the logic in value profile dumper code in compiler-rt: in readValueProfilingData()
805 NumValueKinds += (Data->NumValueSites[I] != 0); in readValueProfilingData()
812 ValueDataStart, (const unsigned char *)DataBuffer->getBufferEnd(), in readValueProfilingData()
821 VDataPtrOrErr.get()->deserializeTo(Record, Symtab.get()); in readValueProfilingData()
822 CurValueDataSize = VDataPtrOrErr.get()->getSize(); in readValueProfilingData()
863 BinaryIds.insert(BinaryIds.begin(), this->BinaryIds.begin(), in readBinaryIds()
864 this->BinaryIds.end()); in readBinaryIds()
898 VDataPtrOrErr.get()->deserializeTo(DataBuffer.back(), nullptr); in readValueProfilingData()
899 D += VDataPtrOrErr.get()->TotalSize; in readValueProfilingData()
924 uint64_t CountsSize = N / sizeof(uint64_t) - 1; in ReadData()
973 auto Iter = HashTable->find(FuncName); in getRecords()
974 if (Iter == HashTable->end()) in getRecords()
1009 RecordIterator = HashTable->data_begin(); in InstrProfReaderIndex()
1065 Out.reserve(OrigName.size() + Replacement.size() - ExtractedName.size()); in reconstituteName()
1074 for (StringRef Name : Underlying.HashTable->keys()) { in populateRemappings()
1107 return Err->get() == instrprof_error::unknown_function in getRecords()
1128 /// FIXME: Can we store a location within the on-disk hash table instead of
1157 SummaryInLE->NumSummaryFields); in readSummary()
1159 SummaryInLE->NumCutoffEntries); in readSummary()
1171 for (unsigned I = 0; I < SummaryData->NumCutoffEntries; I++) { in readSummary()
1172 const IndexedInstrProf::Summary::Entry &Ent = SummaryData->getEntry(I); in readSummary()
1177 UseCS ? this->CS_Summary : this->Summary; in readSummary()
1182 DetailedSummary, SummaryData->get(Summary::TotalBlockCount), in readSummary()
1183 SummaryData->get(Summary::MaxBlockCount), in readSummary()
1184 SummaryData->get(Summary::MaxInternalBlockCount), in readSummary()
1185 SummaryData->get(Summary::MaxFunctionCount), in readSummary()
1186 SummaryData->get(Summary::TotalNumBlocks), in readSummary()
1187 SummaryData->get(Summary::TotalNumFunctions)); in readSummary()
1191 // an empty summary, which will not result in accurate hot/cold detection. in readSummary()
1291 // Read the first 64-bit word, which may be RecordTableOffset in in deserialize()
1337 for (const auto &Record : MemProfRecordTable->data()) in deserialize()
1348 (const unsigned char *)DataBuffer->getBufferStart(); in readHeader()
1350 if ((const unsigned char *)DataBuffer->getBufferEnd() - Cur < 24) in readHeader()
1358 Cur += Header->size(); in readHeader()
1360 Cur = readSummary((IndexedInstrProf::ProfVersion)Header->Version, Cur, in readHeader()
1362 if (Header->Version & VARIANT_MASK_CSIR_PROF) in readHeader()
1363 Cur = readSummary((IndexedInstrProf::ProfVersion)Header->Version, Cur, in readHeader()
1367 static_cast<IndexedInstrProf::HashT>(Header->HashType); in readHeader()
1373 Start + Header->HashOffset, Cur, Start, HashType, Header->Version); in readHeader()
1377 if (Header->getIndexedProfileVersion() >= 8 && in readHeader()
1378 Header->Version & VARIANT_MASK_MEMPROF) { in readHeader()
1379 if (Error E = MemProfReader.deserialize(Start, Header->MemProfOffset)) in readHeader()
1385 if (Header->getIndexedProfileVersion() >= 9) { in readHeader()
1386 const unsigned char *Ptr = Start + Header->BinaryIdOffset; in readHeader()
1394 if (Ptr > (const unsigned char *)DataBuffer->getBufferEnd()) in readHeader()
1399 if (Header->getIndexedProfileVersion() >= 12) { in readHeader()
1400 const unsigned char *Ptr = Start + Header->VTableNamesOffset; in readHeader()
1408 if (VTableNamePtr > (const char *)DataBuffer->getBufferEnd()) in readHeader()
1414 if (Header->getIndexedProfileVersion() >= 10 && in readHeader()
1415 Header->Version & VARIANT_MASK_TEMPORAL_PROF) { in readHeader()
1416 const unsigned char *Ptr = Start + Header->TemporalProfTracesOffset; in readHeader()
1417 const auto *PtrEnd = (const unsigned char *)DataBuffer->getBufferEnd(); in readHeader()
1451 if (Error E = Remapper->populateRemappings()) in readHeader()
1467 if (Error E = NewSymtab->initVTableNamesFromCompressedStrings(VTableName)) { in getSymtab()
1473 if (Error E = Index->populateSymtab(*NewSymtab)) { in getSymtab()
1487 auto Err = Remapper->getRecords(FuncName, Data); in getInstrProfRecord()
1492 handleErrors(std::move(Err), [&](const InstrProfError &IE) -> Error { in getInstrProfRecord()
1495 if (auto Err = Remapper->getRecords(DeprecatedFuncName, Data)) in getInstrProfRecord()
1510 if (CountValue == (uint64_t)-1) in getInstrProfRecord()
1512 // Handle overflow -- if that happens, return max. in getInstrProfRecord()
1513 if (std::numeric_limits<uint64_t>::max() - CountValue <= ValueSum) in getInstrProfRecord()
1605 auto Iter = MemProfRecordTable->find(FuncNameHash); in getMemProfRecord()
1606 if (Iter == MemProfRecordTable->end()) in getMemProfRecord()
1666 size_t N = std::min(E - I, sizeof(W)); in getFunctionBitmap()
1682 Error E = Index->getRecords(Data); in readNextRecord()
1688 Index->advanceToNextKey(); in readNextRecord()