[compiler-rt] [llvm] [InstrFDO]Allow indexed profile reader to parse compatible future versions and returns errors for incompatible ones. (PR #88212)
Mingming Liu via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 25 12:22:57 PDT 2024
================
@@ -710,9 +745,28 @@ Error InstrProfWriter::writeImpl(ProfOStream &OS) {
OS.write(0);
uint64_t VTableNamesOffset = OS.tell();
- if (!WritePrevVersion)
+ OS.write(0);
+
+ // Record the offset of 'Header::Size' field.
+ const uint64_t OnDiskHeaderSizeOffset = OS.tell();
+
+ if (!WritePrevVersion) {
+ // Reserve the space for `OnDiskByteSize` to allow back patching later.
+ OS.write(0);
+
+ // Write the minimum compatible version required.
+ OS.write(minProfileReaderVersion());
+ }
+
+ // This is a test-only path to append dummy header fields.
+ // NOTE: please write all other header fields before this one.
+ if (AppendAdditionalHeaderFields)
OS.write(0);
----------------
minglotus-6 wrote:
I wonder if I should move this to a member function `InstrProfWriter::TestOnlyAppendAdditionalHeaaderFields` so people don't need to carefully write real header fields before this line (or spend time debugging what goes wrong).
An alternative (that i'm leaning towards) is to introduce `InstrProfWriter::writeHeader` method to encapsulate the write of header, but with back patching (`InstrProfWriter::writeHeader` records the byte offset to patch after payloads are written), it's a bit of refactoring work so decided to ask for thoughts first.
https://github.com/llvm/llvm-project/pull/88212
More information about the llvm-commits
mailing list