[llvm] [nfc][InstrFDO]Encapsulate header writes in a class member function (PR #90142)
Mingming Liu via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 29 18:08:04 PDT 2024
================
@@ -612,30 +596,57 @@ Error InstrProfWriter::writeImpl(ProfOStream &OS) {
OS.write(reinterpret_cast<uint64_t *>(&Header)[I]);
// Save the location of Header.HashOffset field in \c OS.
- uint64_t HashTableStartFieldOffset = OS.tell();
+ Offsets.HashTableStartFieldOffset = OS.tell();
// Reserve the space for HashOffset field.
OS.write(0);
// Save the location of MemProf profile data. This is stored in two parts as
// the schema and as a separate on-disk chained hashtable.
- uint64_t MemProfSectionOffset = OS.tell();
+ Offsets.MemProfSectionOffset = OS.tell();
// Reserve space for the MemProf table field to be patched later if this
// profile contains memory profile information.
OS.write(0);
// Save the location of binary ids section.
- uint64_t BinaryIdSectionOffset = OS.tell();
+ Offsets.BinaryIdSectionOffset = OS.tell();
// Reserve space for the BinaryIdOffset field to be patched later if this
// profile contains binary ids.
OS.write(0);
- uint64_t TemporalProfTracesOffset = OS.tell();
+ Offsets.TemporalProfTracesOffset = OS.tell();
OS.write(0);
- uint64_t VTableNamesOffset = OS.tell();
+ Offsets.VTableNamesOffset = OS.tell();
if (!WritePrevVersion)
OS.write(0);
+ return OS.tell() - StartOffset;
+}
+
+Error InstrProfWriter::writeImpl(ProfOStream &OS) {
+ using namespace IndexedInstrProf;
+ using namespace support;
+
+ OnDiskChainedHashTableGenerator<InstrProfRecordWriterTrait> Generator;
+
+ InstrProfSummaryBuilder ISB(ProfileSummaryBuilder::DefaultCutoffs);
+ InfoObj->SummaryBuilder = &ISB;
+ InstrProfSummaryBuilder CSISB(ProfileSummaryBuilder::DefaultCutoffs);
+ InfoObj->CSSummaryBuilder = &CSISB;
+
+ // Populate the hash table generator.
+ SmallVector<std::pair<StringRef, const ProfilingData *>, 0> OrderedData;
----------------
minglotus-6 wrote:
done.
https://github.com/llvm/llvm-project/pull/90142
More information about the llvm-commits
mailing list