Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[memprof] Remove MemProf format Version 1 #117357

Merged
merged 1 commit into from
Nov 22, 2024

Conversation

kazutakahirata
Copy link
Contributor

This patch removes MemProf format Version 1 now that Version 2 and 3
are working well.

This patch removes MemProf format Version 1 now that Version 2 and 3
are working well.
@llvmbot llvmbot added the PGO Profile Guided Optimizations label Nov 22, 2024
@llvmbot
Copy link
Member

llvmbot commented Nov 22, 2024

@llvm/pr-subscribers-pgo

Author: Kazu Hirata (kazutakahirata)

Changes

This patch removes MemProf format Version 1 now that Version 2 and 3
are working well.


Full diff: https://github.com/llvm/llvm-project/pull/117357.diff

9 Files Affected:

  • (modified) llvm/include/llvm/ProfileData/InstrProfReader.h (+1-1)
  • (modified) llvm/include/llvm/ProfileData/MemProf.h (+1-17)
  • (modified) llvm/lib/ProfileData/InstrProfReader.cpp (+4-30)
  • (modified) llvm/lib/ProfileData/InstrProfWriter.cpp (-37)
  • (modified) llvm/lib/ProfileData/MemProf.cpp (-105)
  • (modified) llvm/test/tools/llvm-profdata/memprof-merge-versions.test (-3)
  • (modified) llvm/tools/llvm-profdata/llvm-profdata.cpp (+1-2)
  • (modified) llvm/unittests/ProfileData/InstrProfTest.cpp (-57)
  • (modified) llvm/unittests/ProfileData/MemProfTest.cpp (-33)
diff --git a/llvm/include/llvm/ProfileData/InstrProfReader.h b/llvm/include/llvm/ProfileData/InstrProfReader.h
index 058b9a1ce02e0b..1fad2343e2c961 100644
--- a/llvm/include/llvm/ProfileData/InstrProfReader.h
+++ b/llvm/include/llvm/ProfileData/InstrProfReader.h
@@ -686,7 +686,7 @@ class IndexedMemProfReader {
   // The number of elements in the radix tree array.
   unsigned RadixTreeSize = 0;
 
-  Error deserializeV12(const unsigned char *Start, const unsigned char *Ptr);
+  Error deserializeV2(const unsigned char *Start, const unsigned char *Ptr);
   Error deserializeV3(const unsigned char *Start, const unsigned char *Ptr);
 
 public:
diff --git a/llvm/include/llvm/ProfileData/MemProf.h b/llvm/include/llvm/ProfileData/MemProf.h
index f97fbd4bd64419..f4f590a4edc9fc 100644
--- a/llvm/include/llvm/ProfileData/MemProf.h
+++ b/llvm/include/llvm/ProfileData/MemProf.h
@@ -25,8 +25,6 @@ struct MemProfRecord;
 
 // The versions of the indexed MemProf format
 enum IndexedVersion : uint64_t {
-  // Version 1: Added a version field to the header.
-  Version1 = 1,
   // Version 2: Added a call stack table.
   Version2 = 2,
   // Version 3: Added a radix tree for call stacks.  Switched to linear IDs for
@@ -34,7 +32,7 @@ enum IndexedVersion : uint64_t {
   Version3 = 3,
 };
 
-constexpr uint64_t MinimumSupportedVersion = Version1;
+constexpr uint64_t MinimumSupportedVersion = Version2;
 constexpr uint64_t MaximumSupportedVersion = Version3;
 
 // Verify that the minimum and maximum satisfy the obvious constraint.
@@ -486,20 +484,6 @@ struct MemProfRecord {
   llvm::SmallVector<std::vector<Frame>> CallSites;
 
   MemProfRecord() = default;
-  MemProfRecord(
-      const IndexedMemProfRecord &Record,
-      llvm::function_ref<const Frame(const FrameId Id)> IdToFrameCallback) {
-    for (const IndexedAllocationInfo &IndexedAI : Record.AllocSites) {
-      AllocSites.emplace_back(IndexedAI, IdToFrameCallback);
-    }
-    for (const ArrayRef<FrameId> Site : Record.CallSites) {
-      std::vector<Frame> Frames;
-      for (const FrameId Id : Site) {
-        Frames.push_back(IdToFrameCallback(Id));
-      }
-      CallSites.push_back(Frames);
-    }
-  }
 
   // Prints out the contents of the memprof record in YAML.
   void print(llvm::raw_ostream &OS) const {
diff --git a/llvm/lib/ProfileData/InstrProfReader.cpp b/llvm/lib/ProfileData/InstrProfReader.cpp
index e43f3ac9f08d49..2e4ce5a2782f7e 100644
--- a/llvm/lib/ProfileData/InstrProfReader.cpp
+++ b/llvm/lib/ProfileData/InstrProfReader.cpp
@@ -1225,8 +1225,8 @@ IndexedInstrProfReader::readSummary(IndexedInstrProf::ProfVersion Version,
   }
 }
 
-Error IndexedMemProfReader::deserializeV12(const unsigned char *Start,
-                                           const unsigned char *Ptr) {
+Error IndexedMemProfReader::deserializeV2(const unsigned char *Start,
+                                          const unsigned char *Ptr) {
   // The value returned from RecordTableGenerator.Emit.
   const uint64_t RecordTableOffset =
       support::endian::readNext<uint64_t, llvm::endianness::little>(Ptr);
@@ -1322,8 +1322,7 @@ Error IndexedMemProfReader::deserialize(const unsigned char *Start,
   const uint64_t FirstWord =
       support::endian::readNext<uint64_t, llvm::endianness::little>(Ptr);
 
-  if (FirstWord == memprof::Version1 || FirstWord == memprof::Version2 ||
-      FirstWord == memprof::Version3) {
+  if (FirstWord == memprof::Version2 || FirstWord == memprof::Version3) {
     // Everything is good.  We can proceed to deserialize the rest.
     Version = static_cast<memprof::IndexedVersion>(FirstWord);
   } else {
@@ -1336,9 +1335,8 @@ Error IndexedMemProfReader::deserialize(const unsigned char *Start,
   }
 
   switch (Version) {
-  case memprof::Version1:
   case memprof::Version2:
-    if (Error E = deserializeV12(Start, Ptr))
+    if (Error E = deserializeV2(Start, Ptr))
       return E;
     break;
   case memprof::Version3:
@@ -1558,25 +1556,6 @@ Expected<InstrProfRecord> IndexedInstrProfReader::getInstrProfRecord(
   return error(instrprof_error::unknown_function);
 }
 
-static Expected<memprof::MemProfRecord>
-getMemProfRecordV0(const memprof::IndexedMemProfRecord &IndexedRecord,
-                   MemProfFrameHashTable &MemProfFrameTable) {
-  memprof::FrameIdConverter<MemProfFrameHashTable> FrameIdConv(
-      MemProfFrameTable);
-
-  memprof::MemProfRecord Record =
-      memprof::MemProfRecord(IndexedRecord, FrameIdConv);
-
-  // Check that all frame ids were successfully converted to frames.
-  if (FrameIdConv.LastUnmappedId) {
-    return make_error<InstrProfError>(instrprof_error::hash_mismatch,
-                                      "memprof frame not found for frame id " +
-                                          Twine(*FrameIdConv.LastUnmappedId));
-  }
-
-  return Record;
-}
-
 static Expected<memprof::MemProfRecord>
 getMemProfRecordV2(const memprof::IndexedMemProfRecord &IndexedRecord,
                    MemProfFrameHashTable &MemProfFrameTable,
@@ -1631,11 +1610,6 @@ IndexedMemProfReader::getMemProfRecord(const uint64_t FuncNameHash) const {
 
   const memprof::IndexedMemProfRecord &IndexedRecord = *Iter;
   switch (Version) {
-  case memprof::Version1:
-    assert(MemProfFrameTable && "MemProfFrameTable must be available");
-    assert(!MemProfCallStackTable &&
-           "MemProfCallStackTable must not be available");
-    return getMemProfRecordV0(IndexedRecord, *MemProfFrameTable);
   case memprof::Version2:
     assert(MemProfFrameTable && "MemProfFrameTable must be available");
     assert(MemProfCallStackTable && "MemProfCallStackTable must be available");
diff --git a/llvm/lib/ProfileData/InstrProfWriter.cpp b/llvm/lib/ProfileData/InstrProfWriter.cpp
index d90629ad57f5b9..725ff9256fd4a0 100644
--- a/llvm/lib/ProfileData/InstrProfWriter.cpp
+++ b/llvm/lib/ProfileData/InstrProfWriter.cpp
@@ -649,41 +649,6 @@ writeMemProfCallStackArray(
   return MemProfCallStackIndexes;
 }
 
-// Write out MemProf Version1 as follows:
-// uint64_t Version (NEW in V1)
-// uint64_t RecordTableOffset = RecordTableGenerator.Emit
-// uint64_t FramePayloadOffset = Offset for the frame payload
-// uint64_t FrameTableOffset = FrameTableGenerator.Emit
-// uint64_t Num schema entries
-// uint64_t Schema entry 0
-// uint64_t Schema entry 1
-// ....
-// uint64_t Schema entry N - 1
-// OnDiskChainedHashTable MemProfRecordData
-// OnDiskChainedHashTable MemProfFrameData
-static Error writeMemProfV1(ProfOStream &OS,
-                            memprof::IndexedMemProfData &MemProfData) {
-  OS.write(memprof::Version1);
-  uint64_t HeaderUpdatePos = OS.tell();
-  OS.write(0ULL); // Reserve space for the memprof record table offset.
-  OS.write(0ULL); // Reserve space for the memprof frame payload offset.
-  OS.write(0ULL); // Reserve space for the memprof frame table offset.
-
-  auto Schema = memprof::getFullSchema();
-  writeMemProfSchema(OS, Schema);
-
-  uint64_t RecordTableOffset =
-      writeMemProfRecords(OS, MemProfData.Records, &Schema, memprof::Version1);
-
-  uint64_t FramePayloadOffset = OS.tell();
-  uint64_t FrameTableOffset = writeMemProfFrames(OS, MemProfData.Frames);
-
-  uint64_t Header[] = {RecordTableOffset, FramePayloadOffset, FrameTableOffset};
-  OS.patch({{HeaderUpdatePos, Header}});
-
-  return Error::success();
-}
-
 // Write out MemProf Version2 as follows:
 // uint64_t Version
 // uint64_t RecordTableOffset = RecordTableGenerator.Emit
@@ -805,8 +770,6 @@ static Error writeMemProf(ProfOStream &OS,
                           memprof::IndexedVersion MemProfVersionRequested,
                           bool MemProfFullSchema) {
   switch (MemProfVersionRequested) {
-  case memprof::Version1:
-    return writeMemProfV1(OS, MemProfData);
   case memprof::Version2:
     return writeMemProfV2(OS, MemProfData, MemProfFullSchema);
   case memprof::Version3:
diff --git a/llvm/lib/ProfileData/MemProf.cpp b/llvm/lib/ProfileData/MemProf.cpp
index 9d5ac748d7975d..9615fdf77eb27e 100644
--- a/llvm/lib/ProfileData/MemProf.cpp
+++ b/llvm/lib/ProfileData/MemProf.cpp
@@ -23,18 +23,6 @@ MemProfSchema getHotColdSchema() {
           Meta::TotalLifetimeAccessDensity};
 }
 
-static size_t serializedSizeV0(const IndexedAllocationInfo &IAI,
-                               const MemProfSchema &Schema) {
-  size_t Size = 0;
-  // The number of frames to serialize.
-  Size += sizeof(uint64_t);
-  // The callstack frame ids.
-  Size += sizeof(FrameId) * IAI.CallStack.size();
-  // The size of the payload.
-  Size += PortableMemInfoBlock::serializedSize(Schema);
-  return Size;
-}
-
 static size_t serializedSizeV2(const IndexedAllocationInfo &IAI,
                                const MemProfSchema &Schema) {
   size_t Size = 0;
@@ -58,8 +46,6 @@ static size_t serializedSizeV3(const IndexedAllocationInfo &IAI,
 size_t IndexedAllocationInfo::serializedSize(const MemProfSchema &Schema,
                                              IndexedVersion Version) const {
   switch (Version) {
-  case Version1:
-    return serializedSizeV0(*this, Schema);
   case Version2:
     return serializedSizeV2(*this, Schema);
   case Version3:
@@ -68,23 +54,6 @@ size_t IndexedAllocationInfo::serializedSize(const MemProfSchema &Schema,
   llvm_unreachable("unsupported MemProf version");
 }
 
-static size_t serializedSizeV1(const IndexedMemProfRecord &Record,
-                               const MemProfSchema &Schema) {
-  // The number of alloc sites to serialize.
-  size_t Result = sizeof(uint64_t);
-  for (const IndexedAllocationInfo &N : Record.AllocSites)
-    Result += N.serializedSize(Schema, Version1);
-
-  // The number of callsites we have information for.
-  Result += sizeof(uint64_t);
-  for (const auto &Frames : Record.CallSites) {
-    // The number of frame ids to serialize.
-    Result += sizeof(uint64_t);
-    Result += Frames.size() * sizeof(FrameId);
-  }
-  return Result;
-}
-
 static size_t serializedSizeV2(const IndexedMemProfRecord &Record,
                                const MemProfSchema &Schema) {
   // The number of alloc sites to serialize.
@@ -116,8 +85,6 @@ static size_t serializedSizeV3(const IndexedMemProfRecord &Record,
 size_t IndexedMemProfRecord::serializedSize(const MemProfSchema &Schema,
                                             IndexedVersion Version) const {
   switch (Version) {
-  case Version1:
-    return serializedSizeV1(*this, Schema);
   case Version2:
     return serializedSizeV2(*this, Schema);
   case Version3:
@@ -126,29 +93,6 @@ size_t IndexedMemProfRecord::serializedSize(const MemProfSchema &Schema,
   llvm_unreachable("unsupported MemProf version");
 }
 
-static void serializeV1(const IndexedMemProfRecord &Record,
-                        const MemProfSchema &Schema, raw_ostream &OS) {
-  using namespace support;
-
-  endian::Writer LE(OS, llvm::endianness::little);
-
-  LE.write<uint64_t>(Record.AllocSites.size());
-  for (const IndexedAllocationInfo &N : Record.AllocSites) {
-    LE.write<uint64_t>(N.CallStack.size());
-    for (const FrameId &Id : N.CallStack)
-      LE.write<FrameId>(Id);
-    N.Info.serialize(Schema, OS);
-  }
-
-  // Related contexts.
-  LE.write<uint64_t>(Record.CallSites.size());
-  for (const auto &Frames : Record.CallSites) {
-    LE.write<uint64_t>(Frames.size());
-    for (const FrameId &Id : Frames)
-      LE.write<FrameId>(Id);
-  }
-}
-
 static void serializeV2(const IndexedMemProfRecord &Record,
                         const MemProfSchema &Schema, raw_ostream &OS) {
   using namespace support;
@@ -195,9 +139,6 @@ void IndexedMemProfRecord::serialize(
     llvm::DenseMap<CallStackId, LinearCallStackId> *MemProfCallStackIndexes)
     const {
   switch (Version) {
-  case Version1:
-    serializeV1(*this, Schema, OS);
-    return;
   case Version2:
     serializeV2(*this, Schema, OS);
     return;
@@ -208,50 +149,6 @@ void IndexedMemProfRecord::serialize(
   llvm_unreachable("unsupported MemProf version");
 }
 
-static IndexedMemProfRecord deserializeV1(const MemProfSchema &Schema,
-                                          const unsigned char *Ptr) {
-  using namespace support;
-
-  IndexedMemProfRecord Record;
-
-  // Read the meminfo nodes.
-  const uint64_t NumNodes =
-      endian::readNext<uint64_t, llvm::endianness::little>(Ptr);
-  for (uint64_t I = 0; I < NumNodes; I++) {
-    IndexedAllocationInfo Node;
-    const uint64_t NumFrames =
-        endian::readNext<uint64_t, llvm::endianness::little>(Ptr);
-    for (uint64_t J = 0; J < NumFrames; J++) {
-      const FrameId Id =
-          endian::readNext<FrameId, llvm::endianness::little>(Ptr);
-      Node.CallStack.push_back(Id);
-    }
-    Node.CSId = hashCallStack(Node.CallStack);
-    Node.Info.deserialize(Schema, Ptr);
-    Ptr += PortableMemInfoBlock::serializedSize(Schema);
-    Record.AllocSites.push_back(Node);
-  }
-
-  // Read the callsite information.
-  const uint64_t NumCtxs =
-      endian::readNext<uint64_t, llvm::endianness::little>(Ptr);
-  for (uint64_t J = 0; J < NumCtxs; J++) {
-    const uint64_t NumFrames =
-        endian::readNext<uint64_t, llvm::endianness::little>(Ptr);
-    llvm::SmallVector<FrameId> Frames;
-    Frames.reserve(NumFrames);
-    for (uint64_t K = 0; K < NumFrames; K++) {
-      const FrameId Id =
-          endian::readNext<FrameId, llvm::endianness::little>(Ptr);
-      Frames.push_back(Id);
-    }
-    Record.CallSites.push_back(Frames);
-    Record.CallSiteIds.push_back(hashCallStack(Frames));
-  }
-
-  return Record;
-}
-
 static IndexedMemProfRecord deserializeV2(const MemProfSchema &Schema,
                                           const unsigned char *Ptr) {
   using namespace support;
@@ -324,8 +221,6 @@ IndexedMemProfRecord::deserialize(const MemProfSchema &Schema,
                                   const unsigned char *Ptr,
                                   IndexedVersion Version) {
   switch (Version) {
-  case Version1:
-    return deserializeV1(Schema, Ptr);
   case Version2:
     return deserializeV2(Schema, Ptr);
   case Version3:
diff --git a/llvm/test/tools/llvm-profdata/memprof-merge-versions.test b/llvm/test/tools/llvm-profdata/memprof-merge-versions.test
index 722ef43484e7e9..0a658720162593 100644
--- a/llvm/test/tools/llvm-profdata/memprof-merge-versions.test
+++ b/llvm/test/tools/llvm-profdata/memprof-merge-versions.test
@@ -7,9 +7,6 @@ RUN: echo "1" >> %t.proftext
 RUN: echo "1" >> %t.proftext
 
 To update the inputs used below run Inputs/update_memprof_inputs.sh /path/to/updated/clang
-RUN: llvm-profdata merge %t.proftext %p/Inputs/basic.memprofraw --memprof-version=1 --profiled-binary %p/Inputs/basic.memprofexe -o %t.prof.v1
-RUN: llvm-profdata show %t.prof.v1 | FileCheck %s
-
 RUN: llvm-profdata merge %t.proftext %p/Inputs/basic.memprofraw --memprof-version=2 --profiled-binary %p/Inputs/basic.memprofexe -o %t.prof.v2
 RUN: llvm-profdata show %t.prof.v2 | FileCheck %s
 
diff --git a/llvm/tools/llvm-profdata/llvm-profdata.cpp b/llvm/tools/llvm-profdata/llvm-profdata.cpp
index 7641a80129de35..2acf1cc34b2d8e 100644
--- a/llvm/tools/llvm-profdata/llvm-profdata.cpp
+++ b/llvm/tools/llvm-profdata/llvm-profdata.cpp
@@ -333,8 +333,7 @@ cl::opt<memprof::IndexedVersion> MemProfVersionRequested(
     "memprof-version", cl::Hidden, cl::sub(MergeSubcommand),
     cl::desc("Specify the version of the memprof format to use"),
     cl::init(memprof::Version3),
-    cl::values(clEnumValN(memprof::Version1, "1", "version 1"),
-               clEnumValN(memprof::Version2, "2", "version 2"),
+    cl::values(clEnumValN(memprof::Version2, "2", "version 2"),
                clEnumValN(memprof::Version3, "3", "version 3")));
 
 cl::opt<bool> MemProfFullSchema(
diff --git a/llvm/unittests/ProfileData/InstrProfTest.cpp b/llvm/unittests/ProfileData/InstrProfTest.cpp
index 8bd39fd71266af..f366b228e63512 100644
--- a/llvm/unittests/ProfileData/InstrProfTest.cpp
+++ b/llvm/unittests/ProfileData/InstrProfTest.cpp
@@ -394,21 +394,6 @@ MemInfoBlock makePartialMIB() {
   return MIB;
 }
 
-IndexedMemProfRecord makeRecord(
-    std::initializer_list<std::initializer_list<::llvm::memprof::FrameId>>
-        AllocFrames,
-    std::initializer_list<std::initializer_list<::llvm::memprof::FrameId>>
-        CallSiteFrames,
-    const MemInfoBlock &Block = makeFullMIB()) {
-  llvm::memprof::IndexedMemProfRecord MR;
-  for (const auto &Frames : AllocFrames)
-    MR.AllocSites.emplace_back(Frames, llvm::memprof::hashCallStack(Frames),
-                               Block);
-  for (const auto &Frames : CallSiteFrames)
-    MR.CallSites.push_back(Frames);
-  return MR;
-}
-
 IndexedMemProfRecord
 makeRecordV2(std::initializer_list<::llvm::memprof::CallStackId> AllocFrames,
              std::initializer_list<::llvm::memprof::CallStackId> CallSiteFrames,
@@ -456,48 +441,6 @@ MATCHER_P(EqualsRecord, Want, "") {
   return true;
 }
 
-TEST_F(InstrProfTest, test_memprof_v0) {
-  ASSERT_THAT_ERROR(Writer.mergeProfileKind(InstrProfKind::MemProf),
-                    Succeeded());
-
-  const IndexedMemProfRecord IndexedMR = makeRecord(
-      /*AllocFrames=*/
-      {
-          {0, 1},
-          {2, 3},
-      },
-      /*CallSiteFrames=*/{
-          {4, 5},
-      });
-
-  memprof::IndexedMemProfData MemProfData;
-  MemProfData.Frames = getFrameMapping();
-  MemProfData.Records.try_emplace(0x9999, IndexedMR);
-  Writer.addMemProfData(MemProfData, Err);
-
-  auto Profile = Writer.writeBuffer();
-  readProfile(std::move(Profile));
-
-  auto RecordOr = Reader->getMemProfRecord(0x9999);
-  ASSERT_THAT_ERROR(RecordOr.takeError(), Succeeded());
-  const memprof::MemProfRecord &Record = RecordOr.get();
-
-  std::optional<memprof::FrameId> LastUnmappedFrameId;
-  auto IdToFrameCallback = [&](const memprof::FrameId Id) {
-    auto Iter = MemProfData.Frames.find(Id);
-    if (Iter == MemProfData.Frames.end()) {
-      LastUnmappedFrameId = Id;
-      return memprof::Frame(0, 0, 0, false);
-    }
-    return Iter->second;
-  };
-
-  const memprof::MemProfRecord WantRecord(IndexedMR, IdToFrameCallback);
-  ASSERT_EQ(LastUnmappedFrameId, std::nullopt)
-      << "could not map frame id: " << *LastUnmappedFrameId;
-  EXPECT_THAT(WantRecord, EqualsRecord(Record));
-}
-
 TEST_F(InstrProfTest, test_memprof_v2_full_schema) {
   const MemInfoBlock MIB = makeFullMIB();
 
diff --git a/llvm/unittests/ProfileData/MemProfTest.cpp b/llvm/unittests/ProfileData/MemProfTest.cpp
index 79b644dc5a528d..c3f35e41b5fc74 100644
--- a/llvm/unittests/ProfileData/MemProfTest.cpp
+++ b/llvm/unittests/ProfileData/MemProfTest.cpp
@@ -268,39 +268,6 @@ TEST(MemProf, PortableWrapper) {
   EXPECT_EQ(3UL, ReadBlock.getAllocCpuId());
 }
 
-TEST(MemProf, RecordSerializationRoundTripVersion1) {
-  const auto Schema = llvm::memprof::getFullSchema();
-
-  MemInfoBlock Info(/*size=*/16, /*access_count=*/7, /*alloc_timestamp=*/1000,
-                    /*dealloc_timestamp=*/2000, /*alloc_cpu=*/3,
-                    /*dealloc_cpu=*/4, /*Histogram=*/0, /*HistogramSize=*/0);
-
-  llvm::SmallVector<llvm::SmallVector<FrameId>> AllocCallStacks = {
-      {0x123, 0x345}, {0x123, 0x567}};
-
-  llvm::SmallVector<llvm::SmallVector<FrameId>> CallSites = {{0x333, 0x777}};
-
-  IndexedMemProfRecord Record;
-  for (const auto &ACS : AllocCallStacks) {
-    // Use the same info block for both allocation sites.
-    Record.AllocSites.emplace_back(ACS, llvm::memprof::hashCallStack(ACS),
-                                   Info);
-  }
-  Record.CallSites.assign(CallSites);
-  for (const auto &CS : CallSites)
-    Record.CallSiteIds.push_back(llvm::memprof::hashCallStack(CS));
-
-  std::string Buffer;
-  llvm::raw_string_ostream OS(Buffer);
-  Record.serialize(Schema, OS, llvm::memprof::Version1);
-
-  const IndexedMemProfRecord GotRecord = IndexedMemProfRecord::deserialize(
-      Schema, reinterpret_cast<const unsigned char *>(Buffer.data()),
-      llvm::memprof::Version1);
-
-  EXPECT_EQ(Record, GotRecord);
-}
-
 TEST(MemProf, RecordSerializationRoundTripVerion2) {
   const auto Schema = llvm::memprof::getFullSchema();
 

@kazutakahirata kazutakahirata merged commit ad2bdd8 into llvm:main Nov 22, 2024
7 of 10 checks passed
@kazutakahirata kazutakahirata deleted the memprof_remove_version_1 branch November 22, 2024 19:53
@llvm-ci
Copy link
Collaborator

llvm-ci commented Nov 22, 2024

LLVM Buildbot has detected a new failure on builder llvm-clang-x86_64-expensive-checks-debian running on gribozavr4 while building llvm at step 5 "build-unified-tree".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/16/builds/9436

Here is the relevant piece of the build log for the reference
Step 5 (build-unified-tree) failure: build (failure)
...
9.984 [905/43/3055] Building CXX object lib/Target/AArch64/MCTargetDesc/CMakeFiles/LLVMAArch64Desc.dir/AArch64MCCodeEmitter.cpp.o
9.984 [905/42/3056] Building CXX object lib/Target/AArch64/Utils/CMakeFiles/LLVMAArch64Utils.dir/AArch64BaseInfo.cpp.o
9.987 [904/42/3057] Building CXX object lib/Target/AArch64/MCTargetDesc/CMakeFiles/LLVMAArch64Desc.dir/AArch64WinCOFFObjectWriter.cpp.o
9.990 [904/41/3058] Building CXX object lib/Target/AArch64/MCTargetDesc/CMakeFiles/LLVMAArch64Desc.dir/AArch64MCTargetDesc.cpp.o
9.991 [904/40/3059] Linking CXX static library lib/libLLVMAArch64Utils.a
9.994 [903/40/3060] Building CXX object tools/llvm-exegesis/lib/AArch64/CMakeFiles/LLVMExegesisAArch64.dir/Target.cpp.o
10.012 [903/39/3061] Linking CXX static library lib/libLLVMAArch64Desc.a
10.018 [902/39/3062] Linking CXX static library lib/libLLVMAArch64Disassembler.a
10.254 [902/38/3063] Building X86GenSubtargetInfo.inc...
10.438 [902/37/3064] Building CXX object lib/ProfileData/CMakeFiles/LLVMProfileData.dir/InstrProfReader.cpp.o
FAILED: lib/ProfileData/CMakeFiles/LLVMProfileData.dir/InstrProfReader.cpp.o 
CCACHE_CPP2=yes CCACHE_HASHDIR=yes /usr/bin/ccache /usr/bin/clang++ -DEXPENSIVE_CHECKS -DGTEST_HAS_RTTI=0 -D_DEBUG -D_GLIBCXX_ASSERTIONS -D_GLIBCXX_DEBUG -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/b/1/llvm-clang-x86_64-expensive-checks-debian/build/lib/ProfileData -I/b/1/llvm-clang-x86_64-expensive-checks-debian/llvm-project/llvm/lib/ProfileData -I/b/1/llvm-clang-x86_64-expensive-checks-debian/build/include -I/b/1/llvm-clang-x86_64-expensive-checks-debian/llvm-project/llvm/include -U_GLIBCXX_DEBUG -fPIC -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -O3 -DNDEBUG  -fno-exceptions -funwind-tables -fno-rtti -UNDEBUG -std=c++17 -MD -MT lib/ProfileData/CMakeFiles/LLVMProfileData.dir/InstrProfReader.cpp.o -MF lib/ProfileData/CMakeFiles/LLVMProfileData.dir/InstrProfReader.cpp.o.d -o lib/ProfileData/CMakeFiles/LLVMProfileData.dir/InstrProfReader.cpp.o -c /b/1/llvm-clang-x86_64-expensive-checks-debian/llvm-project/llvm/lib/ProfileData/InstrProfReader.cpp
/b/1/llvm-clang-x86_64-expensive-checks-debian/llvm-project/llvm/lib/ProfileData/InstrProfReader.cpp:1355:27: error: no member named 'Version1' in namespace 'llvm::memprof'
  if (Version <= memprof::Version1)
                 ~~~~~~~~~^
1 error generated.
10.535 [902/36/3065] Building CXX object lib/ProfileData/CMakeFiles/LLVMProfileData.dir/MemProf.cpp.o
11.865 [902/35/3066] Building X86GenInstrInfo.inc...
12.067 [902/34/3067] Building RISCVGenInstrInfo.inc...
13.151 [902/33/3068] Building CXX object lib/ProfileData/CMakeFiles/LLVMProfileData.dir/InstrProf.cpp.o
13.235 [902/32/3069] Building RISCVGenGlobalISel.inc...
13.263 [902/31/3070] Building AMDGPUGenMCPseudoLowering.inc...
13.618 [902/30/3071] Building CXX object lib/MC/MCParser/CMakeFiles/LLVMMCParser.dir/AsmParser.cpp.o
13.849 [902/29/3072] Building AMDGPUGenRegBankGICombiner.inc...
14.079 [902/28/3073] Building AMDGPUGenCallingConv.inc...
14.128 [902/27/3074] Building CXX object lib/ProfileData/CMakeFiles/LLVMProfileData.dir/InstrProfWriter.cpp.o
14.232 [902/26/3075] Building AMDGPUGenPostLegalizeGICombiner.inc...
14.315 [902/25/3076] Building AMDGPUGenPreLegalizeGICombiner.inc...
14.452 [902/24/3077] Building CXX object lib/Transforms/Instrumentation/CMakeFiles/LLVMInstrumentation.dir/MemProfiler.cpp.o
14.462 [902/23/3078] Building AMDGPUGenMCCodeEmitter.inc...
14.680 [902/22/3079] Building CXX object lib/ProfileData/CMakeFiles/LLVMProfileData.dir/MemProfReader.cpp.o
14.730 [902/21/3080] Building CXX object tools/llvm-cov/CMakeFiles/llvm-cov.dir/CodeCoverage.cpp.o
15.073 [902/20/3081] Building AMDGPUGenDisassemblerTables.inc...
15.079 [902/19/3082] Building CXX object lib/ProfileData/Coverage/CMakeFiles/LLVMCoverage.dir/CoverageMapping.cpp.o
15.300 [902/18/3083] Building AMDGPUGenSearchableTables.inc...
15.401 [902/17/3084] Building RISCVGenDAGISel.inc...
15.861 [902/16/3085] Building AMDGPUGenSubtargetInfo.inc...
18.450 [902/15/3086] Building CXX object lib/Transforms/Instrumentation/CMakeFiles/LLVMInstrumentation.dir/PGOInstrumentation.cpp.o
19.218 [902/14/3087] Building CXX object lib/CodeGen/AsmPrinter/CMakeFiles/LLVMAsmPrinter.dir/AsmPrinter.cpp.o
20.373 [902/13/3088] Building RISCVGenSubtargetInfo.inc...
21.169 [902/12/3089] Building CXX object tools/llvm-profdata/CMakeFiles/llvm-profdata.dir/llvm-profdata.cpp.o
21.394 [902/11/3090] Building CXX object lib/LTO/CMakeFiles/LLVMLTO.dir/LTO.cpp.o
23.452 [902/10/3091] Building X86GenAsmMatcher.inc...
24.791 [902/9/3092] Building AMDGPUGenAsmWriter.inc...
25.174 [902/8/3093] Building AMDGPUGenGlobalISel.inc...
25.414 [902/7/3094] Building AMDGPUGenDAGISel.inc...
25.438 [902/6/3095] Building CXX object lib/Passes/CMakeFiles/LLVMPasses.dir/PassBuilderPipelines.cpp.o
28.900 [902/5/3096] Building AMDGPUGenInstrInfo.inc...
29.645 [902/4/3097] Building AMDGPUGenRegisterInfo.inc...

@vvereschaka
Copy link
Contributor

Hi @kazutakahirata,

There is the same problem on llvm-clang-x86_64-expensive-checks-ubuntu builder.

/home/buildbot/worker/as-builder-4/ramdisk/expensive-checks/llvm-project/llvm/lib/ProfileData/InstrProfReader.cpp: In member function ‘llvm::Error llvm::IndexedMemProfReader::deserialize(const unsigned char*, uint64_t)’:
/home/buildbot/worker/as-builder-4/ramdisk/expensive-checks/llvm-project/llvm/lib/ProfileData/InstrProfReader.cpp:1355:27: error: ‘Version1’ is not a member of ‘llvm::memprof’; did you mean ‘Version3’?
 1355 |   if (Version <= memprof::Version1)
      |                           ^~~~~~~~
      |                           Version3

@kazutakahirata
Copy link
Contributor Author

Hi @kazutakahirata,

There is the same problem on llvm-clang-x86_64-expensive-checks-ubuntu builder.

/home/buildbot/worker/as-builder-4/ramdisk/expensive-checks/llvm-project/llvm/lib/ProfileData/InstrProfReader.cpp: In member function ‘llvm::Error llvm::IndexedMemProfReader::deserialize(const unsigned char*, uint64_t)’:
/home/buildbot/worker/as-builder-4/ramdisk/expensive-checks/llvm-project/llvm/lib/ProfileData/InstrProfReader.cpp:1355:27: error: ‘Version1’ is not a member of ‘llvm::memprof’; did you mean ‘Version3’?
 1355 |   if (Version <= memprof::Version1)
      |                           ^~~~~~~~
      |                           Version3

Thank you for bringing this to my attention. I'll fix that right away.

@kazutakahirata
Copy link
Contributor Author

@vvereschaka Fixed with a0153ea. Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PGO Profile Guided Optimizations
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants