[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 15:42:50 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;
----------------
minglotus-6 wrote:
Thanks for the review @snehasish !
Before making changes for the other comments, just a quick question on the return value: the subsequent patch for partial forward compatibility (https://github.com/llvm/llvm-project/pull/88212) needs header byte size (for reader to locate the end of the header fields), and `InstrProfWriter::writeHeader` is the function that has the header byte size information.
To make the diff smaller for the subsequent patch, I wonder if returning `std::pair<uint64_t /* ByteSize*/, HeaderFieldOffsets>` sounds good.
https://github.com/llvm/llvm-project/pull/90142
More information about the llvm-commits
mailing list