[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 15:52:30 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:

sounds good. I sent out https://github.com/llvm/llvm-project/pull/90142 to add `InstrProfWriter::writeHeader` and will make it a parent of this patch.

https://github.com/llvm/llvm-project/pull/88212


More information about the llvm-commits mailing list