[llvm] [memprof] Add a version field to MemProf (PR #85344)

Snehasish Kumar via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 14 19:05:04 PDT 2024


================
@@ -1230,6 +1230,15 @@ Error IndexedInstrProfReader::readHeader() {
             Header->MemProfOffset);
 
     const unsigned char *Ptr = Start + MemProfOffset;
+
+    const uint64_t MemProfVersion =
+        support::endian::readNext<uint64_t, llvm::endianness::little,
+                                  unaligned>(Ptr);
+    if (MemProfVersion != IndexedInstrProf::MemProfVersion) {
+      return make_error<InstrProfError>(instrprof_error::unsupported_version,
+                                        "unsupported MemProf version");
----------------
snehasish wrote:

It would be good to include the expected and actual versions in the error message.

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


More information about the llvm-commits mailing list