Skip to content

Conversation

@snehasish
Copy link

Reverts #147854

Test failure when building with gcc.
https://lab.llvm.org/buildbot/#/builders/174/builds/21989

@llvmbot llvmbot added compiler-rt PGO Profile Guided Optimizations labels Jul 30, 2025
@llvmbot
Copy link
Member

llvmbot commented Jul 30, 2025

@llvm/pr-subscribers-pgo

Author: Snehasish Kumar (snehasish)

Changes

Reverts llvm/llvm-project#147854

Test failure when building with gcc.
https://lab.llvm.org/buildbot/#/builders/174/builds/21989


Patch is 25.40 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/151382.diff

30 Files Affected:

  • (modified) compiler-rt/include/profile/MemProfData.inc (+3-37)
  • (modified) compiler-rt/lib/memprof/memprof_rawprofile.cpp (+6-9)
  • (modified) compiler-rt/lib/memprof/tests/CMakeLists.txt (-1)
  • (removed) compiler-rt/lib/memprof/tests/histogram_encoding.cpp (-35)
  • (removed) compiler-rt/test/memprof/TestCases/memprof_histogram_uint8.cpp (-37)
  • (modified) llvm/include/llvm/ProfileData/MemProfData.inc (+3-37)
  • (modified) llvm/lib/ProfileData/MemProfReader.cpp (+10-28)
  • (modified) llvm/test/tools/llvm-profdata/Inputs/basic-histogram.memprofexe ()
  • (modified) llvm/test/tools/llvm-profdata/Inputs/basic-histogram.memprofraw ()
  • (modified) llvm/test/tools/llvm-profdata/Inputs/basic.memprofexe ()
  • (modified) llvm/test/tools/llvm-profdata/Inputs/basic.memprofraw ()
  • (removed) llvm/test/tools/llvm-profdata/Inputs/basic_v4.memprofexe ()
  • (removed) llvm/test/tools/llvm-profdata/Inputs/basic_v4.memprofraw ()
  • (modified) llvm/test/tools/llvm-profdata/Inputs/buildid.memprofexe ()
  • (modified) llvm/test/tools/llvm-profdata/Inputs/buildid.memprofraw ()
  • (modified) llvm/test/tools/llvm-profdata/Inputs/inline.memprofexe ()
  • (modified) llvm/test/tools/llvm-profdata/Inputs/inline.memprofraw ()
  • (modified) llvm/test/tools/llvm-profdata/Inputs/multi.memprofexe ()
  • (modified) llvm/test/tools/llvm-profdata/Inputs/multi.memprofraw ()
  • (modified) llvm/test/tools/llvm-profdata/Inputs/padding-histogram.memprofexe ()
  • (modified) llvm/test/tools/llvm-profdata/Inputs/padding-histogram.memprofraw ()
  • (modified) llvm/test/tools/llvm-profdata/Inputs/pic.memprofexe ()
  • (modified) llvm/test/tools/llvm-profdata/Inputs/pic.memprofraw ()
  • (modified) llvm/test/tools/llvm-profdata/memprof-basic-histogram.test (+2-2)
  • (modified) llvm/test/tools/llvm-profdata/memprof-basic.test (+2-2)
  • (removed) llvm/test/tools/llvm-profdata/memprof-basic_v4.test (-102)
  • (modified) llvm/test/tools/llvm-profdata/memprof-inline.test (+1-1)
  • (modified) llvm/test/tools/llvm-profdata/memprof-multi.test (+1-1)
  • (modified) llvm/test/tools/llvm-profdata/memprof-padding-histogram.test (+2-2)
  • (modified) llvm/test/tools/llvm-profdata/memprof-pic.test (+2-2)
diff --git a/compiler-rt/include/profile/MemProfData.inc b/compiler-rt/include/profile/MemProfData.inc
index 26badddae6f3a..3f785bd23fce3 100644
--- a/compiler-rt/include/profile/MemProfData.inc
+++ b/compiler-rt/include/profile/MemProfData.inc
@@ -33,10 +33,11 @@
    (uint64_t)'o' << 24 | (uint64_t)'f' << 16 | (uint64_t)'r' << 8 | (uint64_t)129)
 
 // The version number of the raw binary format.
-#define MEMPROF_RAW_VERSION 5ULL
+#define MEMPROF_RAW_VERSION 4ULL
 
 // Currently supported versions.
-#define MEMPROF_RAW_SUPPORTED_VERSIONS {3ULL, 4ULL, 5ULL}
+#define MEMPROF_RAW_SUPPORTED_VERSIONS                                         \
+  { 3ULL, 4ULL }
 
 #define MEMPROF_V3_MIB_SIZE 132ULL;
 
@@ -228,41 +229,6 @@ void Merge(const MemInfoBlock &newMIB) {
 } __attribute__((__packed__));
 #endif
 
-constexpr int MantissaBits = 12;
-constexpr int ExponentBits = 4;
-constexpr uint16_t MaxMantissa = (1U << MantissaBits) - 1;
-constexpr uint16_t MaxExponent = (1U << ExponentBits) - 1;
-constexpr uint64_t MaxRepresentableValue = static_cast<uint64_t>(MaxMantissa)
-                                           << MaxExponent;
-
-// Encodes a 64-bit unsigned integer into a 16-bit scaled integer format.
-inline uint16_t encodeHistogramCount(uint64_t Count) {
-  if (Count == 0)
-    return 0;
-
-  if (Count > MaxRepresentableValue)
-    Count = MaxRepresentableValue;
-
-  if (Count <= MaxMantissa)
-    return Count;
-
-  uint64_t M = Count;
-  uint16_t E = 0;
-  while (M > MaxMantissa) {
-    M = (M + 1) >> 1;
-    E++;
-  }
-  return (E << MantissaBits) | static_cast<uint16_t>(M);
-}
-
-// Decodes a 16-bit scaled integer and returns the
-// decoded 64-bit unsigned integer.
-inline uint64_t decodeHistogramCount(uint16_t EncodedValue) {
-  const uint16_t E = EncodedValue >> MantissaBits;
-  const uint16_t M = EncodedValue & MaxMantissa;
-  return static_cast<uint64_t>(M) << E;
-}
-
 } // namespace memprof
 } // namespace llvm
 
diff --git a/compiler-rt/lib/memprof/memprof_rawprofile.cpp b/compiler-rt/lib/memprof/memprof_rawprofile.cpp
index f909d78f5f36a..a897648584828 100644
--- a/compiler-rt/lib/memprof/memprof_rawprofile.cpp
+++ b/compiler-rt/lib/memprof/memprof_rawprofile.cpp
@@ -19,7 +19,6 @@ using ::__sanitizer::Vector;
 using ::llvm::memprof::MemInfoBlock;
 using SegmentEntry = ::llvm::memprof::SegmentEntry;
 using Header = ::llvm::memprof::Header;
-using ::llvm::memprof::encodeHistogramCount;
 
 namespace {
 template <class T> char *WriteBytes(const T &Pod, char *Buffer) {
@@ -170,15 +169,13 @@ void SerializeMIBInfoToBuffer(MIBMapTy &MIBMap, const Vector<u64> &StackIds,
     // FIXME: We unnecessarily serialize the AccessHistogram pointer. Adding a
     // serialization schema will fix this issue. See also FIXME in
     // deserialization.
-    auto &MIB = (*h)->mib;
-    Ptr = WriteBytes(MIB, Ptr);
-    for (u64 j = 0; j < MIB.AccessHistogramSize; ++j) {
-      u16 HistogramEntry =
-          encodeHistogramCount(((u64 *)(MIB.AccessHistogram))[j]);
+    Ptr = WriteBytes((*h)->mib, Ptr);
+    for (u64 j = 0; j < (*h)->mib.AccessHistogramSize; ++j) {
+      u64 HistogramEntry = ((u64 *)((*h)->mib.AccessHistogram))[j];
       Ptr = WriteBytes(HistogramEntry, Ptr);
     }
-    if (MIB.AccessHistogramSize > 0) {
-      InternalFree((void *)MIB.AccessHistogram);
+    if ((*h)->mib.AccessHistogramSize > 0) {
+      InternalFree((void *)((*h)->mib.AccessHistogram));
     }
   }
   CHECK(ExpectedNumBytes >= static_cast<u64>(Ptr - Buffer) &&
@@ -252,7 +249,7 @@ u64 SerializeToRawProfile(MIBMapTy &MIBMap, ArrayRef<LoadedModule> Modules,
       },
       reinterpret_cast<void *>(&TotalAccessHistogramEntries));
   const u64 NumHistogramBytes =
-      RoundUpTo(TotalAccessHistogramEntries * sizeof(uint16_t), 8);
+      RoundUpTo(TotalAccessHistogramEntries * sizeof(uint64_t), 8);
 
   const u64 NumStackBytes = RoundUpTo(StackSizeBytes(StackIds), 8);
 
diff --git a/compiler-rt/lib/memprof/tests/CMakeLists.txt b/compiler-rt/lib/memprof/tests/CMakeLists.txt
index 1603d47d019ed..0b5c302a4ce5d 100644
--- a/compiler-rt/lib/memprof/tests/CMakeLists.txt
+++ b/compiler-rt/lib/memprof/tests/CMakeLists.txt
@@ -26,7 +26,6 @@ set(MEMPROF_SOURCES
   ../memprof_rawprofile.cpp)
 
 set(MEMPROF_UNITTESTS
-  histogram_encoding.cpp
   rawprofile.cpp
   driver.cpp)
 
diff --git a/compiler-rt/lib/memprof/tests/histogram_encoding.cpp b/compiler-rt/lib/memprof/tests/histogram_encoding.cpp
deleted file mode 100644
index be20595ca6df9..0000000000000
--- a/compiler-rt/lib/memprof/tests/histogram_encoding.cpp
+++ /dev/null
@@ -1,35 +0,0 @@
-#include <cstdint>
-#include <vector>
-
-#include "profile/MemProfData.inc"
-#include "gtest/gtest.h"
-
-namespace llvm {
-namespace memprof {
-namespace {
-TEST(MemProf, F16EncodeDecode) {
-  const std::vector<uint64_t> TestCases = {
-      0, 100, 4095, 4096, 5000, 8191, 65535, 1000000, 134213640, 200000000,
-  };
-
-  for (const uint64_t TestCase : TestCases) {
-    const uint16_t Encoded = encodeHistogramCount(TestCase);
-    const uint64_t Decoded = decodeHistogramCount(Encoded);
-
-    const uint64_t MaxRepresentable = static_cast<uint64_t>(MaxMantissa)
-                                      << MaxExponent;
-
-    if (TestCase >= MaxRepresentable) {
-      EXPECT_EQ(Decoded, MaxRepresentable);
-    } else if (TestCase <= MaxMantissa) {
-      EXPECT_EQ(Decoded, TestCase);
-    } else {
-      // The decoded value should be close to the original value.
-      // The error should be less than 1/1024 for larger numbers.
-      EXPECT_NEAR(Decoded, TestCase, static_cast<double>(TestCase) / 1024.0);
-    }
-  }
-}
-} // namespace
-} // namespace memprof
-} // namespace llvm
diff --git a/compiler-rt/test/memprof/TestCases/memprof_histogram_uint8.cpp b/compiler-rt/test/memprof/TestCases/memprof_histogram_uint8.cpp
deleted file mode 100644
index 98fceba6b4983..0000000000000
--- a/compiler-rt/test/memprof/TestCases/memprof_histogram_uint8.cpp
+++ /dev/null
@@ -1,37 +0,0 @@
-// Test the histogram support in memprof using the text format output.
-// Shadow memory counters per object are limited to 8b. In memory counters
-// aggregating counts across multiple objects are 64b.
-
-// RUN: %clangxx_memprof -O0 -mllvm -memprof-histogram -mllvm -memprof-use-callbacks=true %s -o %t && %env_memprof_opts=print_text=1:histogram=1:log_path=stdout %run %t 2>&1 | FileCheck %s
-
-#include <stdio.h>
-#include <stdlib.h>
-
-int main() {
-  // Allocate memory that will create a histogram
-  char *buffer = (char *)malloc(1024);
-  if (!buffer)
-    return 1;
-
-  for (int i = 0; i < 10; ++i) {
-    // Access every 8th byte (since shadow granularity is 8b.
-    buffer[i * 8] = 'A';
-  }
-
-  for (int j = 0; j < 200; ++j) {
-    buffer[8] = 'B'; // Count = previous count + 200
-  }
-
-  for (int j = 0; j < 400; ++j) {
-    buffer[16] = 'B'; // Count is saturated at 255
-  }
-
-  // Free the memory to trigger MIB creation with histogram
-  free(buffer);
-
-  printf("Test completed successfully\n");
-  return 0;
-}
-
-// CHECK: AccessCountHistogram[128]: 1 201 255 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
-// CHECK: Test completed successfully
diff --git a/llvm/include/llvm/ProfileData/MemProfData.inc b/llvm/include/llvm/ProfileData/MemProfData.inc
index 26badddae6f3a..3f785bd23fce3 100644
--- a/llvm/include/llvm/ProfileData/MemProfData.inc
+++ b/llvm/include/llvm/ProfileData/MemProfData.inc
@@ -33,10 +33,11 @@
    (uint64_t)'o' << 24 | (uint64_t)'f' << 16 | (uint64_t)'r' << 8 | (uint64_t)129)
 
 // The version number of the raw binary format.
-#define MEMPROF_RAW_VERSION 5ULL
+#define MEMPROF_RAW_VERSION 4ULL
 
 // Currently supported versions.
-#define MEMPROF_RAW_SUPPORTED_VERSIONS {3ULL, 4ULL, 5ULL}
+#define MEMPROF_RAW_SUPPORTED_VERSIONS                                         \
+  { 3ULL, 4ULL }
 
 #define MEMPROF_V3_MIB_SIZE 132ULL;
 
@@ -228,41 +229,6 @@ void Merge(const MemInfoBlock &newMIB) {
 } __attribute__((__packed__));
 #endif
 
-constexpr int MantissaBits = 12;
-constexpr int ExponentBits = 4;
-constexpr uint16_t MaxMantissa = (1U << MantissaBits) - 1;
-constexpr uint16_t MaxExponent = (1U << ExponentBits) - 1;
-constexpr uint64_t MaxRepresentableValue = static_cast<uint64_t>(MaxMantissa)
-                                           << MaxExponent;
-
-// Encodes a 64-bit unsigned integer into a 16-bit scaled integer format.
-inline uint16_t encodeHistogramCount(uint64_t Count) {
-  if (Count == 0)
-    return 0;
-
-  if (Count > MaxRepresentableValue)
-    Count = MaxRepresentableValue;
-
-  if (Count <= MaxMantissa)
-    return Count;
-
-  uint64_t M = Count;
-  uint16_t E = 0;
-  while (M > MaxMantissa) {
-    M = (M + 1) >> 1;
-    E++;
-  }
-  return (E << MantissaBits) | static_cast<uint16_t>(M);
-}
-
-// Decodes a 16-bit scaled integer and returns the
-// decoded 64-bit unsigned integer.
-inline uint64_t decodeHistogramCount(uint16_t EncodedValue) {
-  const uint16_t E = EncodedValue >> MantissaBits;
-  const uint16_t M = EncodedValue & MaxMantissa;
-  return static_cast<uint64_t>(M) << E;
-}
-
 } // namespace memprof
 } // namespace llvm
 
diff --git a/llvm/lib/ProfileData/MemProfReader.cpp b/llvm/lib/ProfileData/MemProfReader.cpp
index 9db699712d6f3..235b1347e0077 100644
--- a/llvm/lib/ProfileData/MemProfReader.cpp
+++ b/llvm/lib/ProfileData/MemProfReader.cpp
@@ -135,7 +135,7 @@ readMemInfoBlocksV3(const char *Ptr) {
 }
 
 llvm::SmallVector<std::pair<uint64_t, MemInfoBlock>>
-readMemInfoBlocksCommon(const char *Ptr, bool IsHistogramEncoded = false) {
+readMemInfoBlocksV4(const char *Ptr) {
   using namespace support;
 
   const uint64_t NumItemsToRead =
@@ -145,43 +145,27 @@ readMemInfoBlocksCommon(const char *Ptr, bool IsHistogramEncoded = false) {
   for (uint64_t I = 0; I < NumItemsToRead; I++) {
     const uint64_t Id =
         endian::readNext<uint64_t, llvm::endianness::little, unaligned>(Ptr);
-
+    // We cheat a bit here and remove the const from cast to set the
+    // Histogram Pointer to newly allocated buffer.
     MemInfoBlock MIB = *reinterpret_cast<const MemInfoBlock *>(Ptr);
+
+    // Only increment by size of MIB since readNext implicitly increments.
     Ptr += sizeof(MemInfoBlock);
 
     if (MIB.AccessHistogramSize > 0) {
-      // The in-memory representation uses uint64_t for histogram entries.
       MIB.AccessHistogram =
           (uintptr_t)malloc(MIB.AccessHistogramSize * sizeof(uint64_t));
-      for (uint64_t J = 0; J < MIB.AccessHistogramSize; J++) {
-        if (!IsHistogramEncoded) {
-          ((uint64_t *)MIB.AccessHistogram)[J] =
-              endian::readNext<uint64_t, llvm::endianness::little, unaligned>(
-                  Ptr);
-        } else {
-          // The encoded on-disk format (V5 onwards) uses uint16_t.
-          const uint16_t Val =
-              endian::readNext<uint16_t, llvm::endianness::little, unaligned>(
-                  Ptr);
-          ((uint64_t *)MIB.AccessHistogram)[J] = decodeHistogramCount(Val);
-        }
-      }
+    }
+
+    for (uint64_t J = 0; J < MIB.AccessHistogramSize; J++) {
+      ((uint64_t *)MIB.AccessHistogram)[J] =
+          endian::readNext<uint64_t, llvm::endianness::little, unaligned>(Ptr);
     }
     Items.push_back({Id, MIB});
   }
   return Items;
 }
 
-llvm::SmallVector<std::pair<uint64_t, MemInfoBlock>>
-readMemInfoBlocksV4(const char *Ptr) {
-  return readMemInfoBlocksCommon(Ptr);
-}
-
-llvm::SmallVector<std::pair<uint64_t, MemInfoBlock>>
-readMemInfoBlocksV5(const char *Ptr) {
-  return readMemInfoBlocksCommon(Ptr, /*IsHistogramEncoded=*/true);
-}
-
 CallStackMap readStackInfo(const char *Ptr) {
   using namespace support;
 
@@ -674,8 +658,6 @@ RawMemProfReader::readMemInfoBlocks(const char *Ptr) {
     return readMemInfoBlocksV3(Ptr);
   if (MemprofRawVersion == 4ULL)
     return readMemInfoBlocksV4(Ptr);
-  if (MemprofRawVersion == 5ULL)
-    return readMemInfoBlocksV5(Ptr);
   llvm_unreachable(
       "Panic: Unsupported version number when reading MemInfoBlocks");
 }
diff --git a/llvm/test/tools/llvm-profdata/Inputs/basic-histogram.memprofexe b/llvm/test/tools/llvm-profdata/Inputs/basic-histogram.memprofexe
index fc530a4e07650..f69c0b12a89eb 100755
Binary files a/llvm/test/tools/llvm-profdata/Inputs/basic-histogram.memprofexe and b/llvm/test/tools/llvm-profdata/Inputs/basic-histogram.memprofexe differ
diff --git a/llvm/test/tools/llvm-profdata/Inputs/basic-histogram.memprofraw b/llvm/test/tools/llvm-profdata/Inputs/basic-histogram.memprofraw
index d4920769a5c08..ed679dc49c53b 100644
Binary files a/llvm/test/tools/llvm-profdata/Inputs/basic-histogram.memprofraw and b/llvm/test/tools/llvm-profdata/Inputs/basic-histogram.memprofraw differ
diff --git a/llvm/test/tools/llvm-profdata/Inputs/basic.memprofexe b/llvm/test/tools/llvm-profdata/Inputs/basic.memprofexe
index 8810ee1090869..14cbfeb88eaf8 100755
Binary files a/llvm/test/tools/llvm-profdata/Inputs/basic.memprofexe and b/llvm/test/tools/llvm-profdata/Inputs/basic.memprofexe differ
diff --git a/llvm/test/tools/llvm-profdata/Inputs/basic.memprofraw b/llvm/test/tools/llvm-profdata/Inputs/basic.memprofraw
index 6943c18c74792..c3ac49e8079e9 100644
Binary files a/llvm/test/tools/llvm-profdata/Inputs/basic.memprofraw and b/llvm/test/tools/llvm-profdata/Inputs/basic.memprofraw differ
diff --git a/llvm/test/tools/llvm-profdata/Inputs/basic_v4.memprofexe b/llvm/test/tools/llvm-profdata/Inputs/basic_v4.memprofexe
deleted file mode 100755
index 14cbfeb88eaf8..0000000000000
Binary files a/llvm/test/tools/llvm-profdata/Inputs/basic_v4.memprofexe and /dev/null differ
diff --git a/llvm/test/tools/llvm-profdata/Inputs/basic_v4.memprofraw b/llvm/test/tools/llvm-profdata/Inputs/basic_v4.memprofraw
deleted file mode 100644
index c3ac49e8079e9..0000000000000
Binary files a/llvm/test/tools/llvm-profdata/Inputs/basic_v4.memprofraw and /dev/null differ
diff --git a/llvm/test/tools/llvm-profdata/Inputs/buildid.memprofexe b/llvm/test/tools/llvm-profdata/Inputs/buildid.memprofexe
index 4ab80401496fe..1b4db88d8186d 100755
Binary files a/llvm/test/tools/llvm-profdata/Inputs/buildid.memprofexe and b/llvm/test/tools/llvm-profdata/Inputs/buildid.memprofexe differ
diff --git a/llvm/test/tools/llvm-profdata/Inputs/buildid.memprofraw b/llvm/test/tools/llvm-profdata/Inputs/buildid.memprofraw
index c6aec8d0b59e1..e959e7679f56c 100644
Binary files a/llvm/test/tools/llvm-profdata/Inputs/buildid.memprofraw and b/llvm/test/tools/llvm-profdata/Inputs/buildid.memprofraw differ
diff --git a/llvm/test/tools/llvm-profdata/Inputs/inline.memprofexe b/llvm/test/tools/llvm-profdata/Inputs/inline.memprofexe
index 5af6c81f07fad..2822f2fa20434 100755
Binary files a/llvm/test/tools/llvm-profdata/Inputs/inline.memprofexe and b/llvm/test/tools/llvm-profdata/Inputs/inline.memprofexe differ
diff --git a/llvm/test/tools/llvm-profdata/Inputs/inline.memprofraw b/llvm/test/tools/llvm-profdata/Inputs/inline.memprofraw
index 8958af941c59d..05deb2e963a27 100644
Binary files a/llvm/test/tools/llvm-profdata/Inputs/inline.memprofraw and b/llvm/test/tools/llvm-profdata/Inputs/inline.memprofraw differ
diff --git a/llvm/test/tools/llvm-profdata/Inputs/multi.memprofexe b/llvm/test/tools/llvm-profdata/Inputs/multi.memprofexe
index e9ec22cc96708..22c6136f3dda8 100755
Binary files a/llvm/test/tools/llvm-profdata/Inputs/multi.memprofexe and b/llvm/test/tools/llvm-profdata/Inputs/multi.memprofexe differ
diff --git a/llvm/test/tools/llvm-profdata/Inputs/multi.memprofraw b/llvm/test/tools/llvm-profdata/Inputs/multi.memprofraw
index 3952768d44c68..364aa1cefdd73 100644
Binary files a/llvm/test/tools/llvm-profdata/Inputs/multi.memprofraw and b/llvm/test/tools/llvm-profdata/Inputs/multi.memprofraw differ
diff --git a/llvm/test/tools/llvm-profdata/Inputs/padding-histogram.memprofexe b/llvm/test/tools/llvm-profdata/Inputs/padding-histogram.memprofexe
index e50f66341ec44..34db7e784208c 100755
Binary files a/llvm/test/tools/llvm-profdata/Inputs/padding-histogram.memprofexe and b/llvm/test/tools/llvm-profdata/Inputs/padding-histogram.memprofexe differ
diff --git a/llvm/test/tools/llvm-profdata/Inputs/padding-histogram.memprofraw b/llvm/test/tools/llvm-profdata/Inputs/padding-histogram.memprofraw
index df6fcb10cd4fe..7a7d3a6460aed 100644
Binary files a/llvm/test/tools/llvm-profdata/Inputs/padding-histogram.memprofraw and b/llvm/test/tools/llvm-profdata/Inputs/padding-histogram.memprofraw differ
diff --git a/llvm/test/tools/llvm-profdata/Inputs/pic.memprofexe b/llvm/test/tools/llvm-profdata/Inputs/pic.memprofexe
index 63eea4438dad8..f7d172314de6d 100755
Binary files a/llvm/test/tools/llvm-profdata/Inputs/pic.memprofexe and b/llvm/test/tools/llvm-profdata/Inputs/pic.memprofexe differ
diff --git a/llvm/test/tools/llvm-profdata/Inputs/pic.memprofraw b/llvm/test/tools/llvm-profdata/Inputs/pic.memprofraw
index b6a733af50f5d..0920028b55840 100644
Binary files a/llvm/test/tools/llvm-profdata/Inputs/pic.memprofraw and b/llvm/test/tools/llvm-profdata/Inputs/pic.memprofraw differ
diff --git a/llvm/test/tools/llvm-profdata/memprof-basic-histogram.test b/llvm/test/tools/llvm-profdata/memprof-basic-histogram.test
index ce534db77f4f4..3d30a627bdd79 100644
--- a/llvm/test/tools/llvm-profdata/memprof-basic-histogram.test
+++ b/llvm/test/tools/llvm-profdata/memprof-basic-histogram.test
@@ -7,7 +7,7 @@ We expect 5 MIBs, each with different AccessHistogramValues.
 
 CHECK: MemprofProfile:
 CHECK-NEXT:   Summary:
-CHECK-NEXT:     Version: 5
+CHECK-NEXT:     Version: 4
 CHECK-NEXT:     NumSegments: {{[0-9]+}}
 CHECK-NEXT:     NumMibInfo: 5
 CHECK-NEXT:     NumAllocFunctions: 3
@@ -241,4 +241,4 @@ CHECK-NEXT:         MinLifetimeAccessDensity: 56000
 CHECK-NEXT:         MaxLifetimeAccessDensity: 56000
 CHECK-NEXT:         AccessHistogramSize: 8
 CHECK-NEXT:         AccessHistogram: {{[0-9]+}}
-CHECK-NEXT:         AccessHistogramValues: 168 147 126 105 84 63 42 21
+CHECK-NEXT:         AccessHistogramValues: 168 147 126 105 84 63 42 21
\ No newline at end of file
diff --git a/llvm/test/tools/llvm-profdata/memprof-basic.test b/llvm/test/tools/llvm-profdata/memprof-basic.test
index 81550ebce40d3..e15df50bc1657 100644
--- a/llvm/test/tools/llvm-profdata/memprof-basic.test
+++ b/llvm/test/tools/llvm-profdata/memprof-basic.test
@@ -8,7 +8,7 @@ additional allocations which do not originate from the main binary are pruned.
 
 CHECK:  MemprofProfile:
 CHECK-NEXT:   Summary:
-CHECK-NEXT:     Version: 5
+CHECK-NEXT:     Version: 4
 CHECK-NEXT:     NumSegments: {{[0-9]+}}
 CHECK-NEXT:     NumMibInfo: 2
 CHECK-NEXT:     NumAllocFunctions: 1
@@ -96,4 +96,4 @@ CHECK-NEXT:         TotalLifetimeAccessDensity: 20000
 CHECK-NEXT:         MinLifetimeAccessDensity: 20000
 CHECK-NEXT:         MaxLifetimeAccessDensity: 20000
 CHECK-NEXT:         AccessHistogramSize: 0
-CHECK-NEXT:         AccessHistogram: 0
+CHECK-NEXT:         AccessHistogram: 0
\ No newline at end of file
diff --git a/llvm/test/tools/llvm-profdata/memprof-basic_v4.test b/llvm/test/tools/llvm-profdata/memprof-basic_v4.test
deleted file mode 100644
index 79d4fe2167922..0000000000000
--- a/llvm/test/tools/llvm-profdata/memprof-basic_v4.test
+++ /dev/null
@@ -1,102 +0,0 @@
-REQUIRES: x86_64-linux
-
-This is a copy of memprof-basic.test with slight changes to check that we can still read v3 of memprofraw.
-
-Inputs cannot and should not be updated.
-
-RUN: llvm-profdata show --memory %p/Inputs/basic_v4.memprofraw --profiled-binary %p/Inputs/basic_v4.memprofexe -o - | FileCheck %s
-
-We expect 2 MIB entries, 1 each for the malloc calls in the program. Any
-additional allocations which do not originate from the main binary are pruned.
-
-CHECK:  MemprofProfile:
-CHECK-NEXT:   Summary:
-CHECK-NEXT:     Version: 4
-CHECK-NEXT:     NumSegments: {{[0-9]+}}
-CHECK-NEXT:     NumMibInfo: 2
-CHECK-NEXT:     NumAllocFunctions: 1
-CHECK-NEXT:     NumStackOffsets: 2
-CHECK-NEXT:   Segments:
-CHECK-NEXT:   -
-CHECK-NEXT:     BuildId: {{[[:xdigit:]]+}}
-CHECK-NEXT:     Start: 0x{{[[:xdigit:]]+}}
-CHECK-NEXT:     End: 0x{{[[:xdigit:]]+}}
-CHECK-NEXT:     Offset: 0x{{[[:xdigit:]]+}}
-CHECK-NEXT:   -
-
-CHECK:   Records:
-CHECK-NEXT:   -
-CHECK-NEXT:     FunctionGUID: {{[0-9]+}}
-CHECK-NEXT:     AllocSites:
-CHECK-NEXT:     -
-CHECK-NEXT:       Callstack:
-CHECK-NEXT:       -
-CHECK-NEXT:         Function: {{[0-9]+}}
-CHECK-NEXT:         SymbolName: main
-CHECK-NEXT:         LineOffset: 1
-CHECK-NEXT:         Column: 21
-CHECK-NEXT:         Inline: 0
-CHECK-NEXT:       MemInfoBlock:
-CHECK-NEXT:         AllocCount: 1
-CH...
[truncated]

@snehasish snehasish merged commit 24f9482 into main Jul 30, 2025
9 of 12 checks passed
@snehasish snehasish deleted the revert-147854-users/snehasish/07-08-draft_changes_to_trim_the_histogram_raw_profile_format branch July 30, 2025 19:36
@llvm-ci
Copy link
Collaborator

llvm-ci commented Jul 30, 2025

LLVM Buildbot has detected a new failure on builder clang-hip-vega20 running on hip-vega20-0 while building compiler-rt,llvm at step 3 "annotate".

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

Here is the relevant piece of the build log for the reference
Step 3 (annotate) failure: '../llvm-zorg/zorg/buildbot/builders/annotated/hip-build.sh --jobs=' (failure)
...
[57/59] Linking CXX executable External/HIP/cmath-hip-6.3.0
[58/59] Building CXX object External/HIP/CMakeFiles/TheNextWeek-hip-6.3.0.dir/workload/ray-tracing/TheNextWeek/main.cc.o
[59/59] Linking CXX executable External/HIP/TheNextWeek-hip-6.3.0
@@@BUILD_STEP Testing HIP test-suite@@@
+ build_step 'Testing HIP test-suite'
+ echo '@@@BUILD_STEP Testing HIP test-suite@@@'
+ ninja check-hip-simple
[0/1] cd /home/botworker/bbot/clang-hip-vega20/botworker/clang-hip-vega20/test-suite-build/External/HIP && /home/botworker/bbot/clang-hip-vega20/botworker/clang-hip-vega20/llvm/bin/llvm-lit -sv array-hip-6.3.0.test empty-hip-6.3.0.test with-fopenmp-hip-6.3.0.test saxpy-hip-6.3.0.test memmove-hip-6.3.0.test split-kernel-args-hip-6.3.0.test builtin-logb-scalbn-hip-6.3.0.test TheNextWeek-hip-6.3.0.test algorithm-hip-6.3.0.test cmath-hip-6.3.0.test complex-hip-6.3.0.test math_h-hip-6.3.0.test new-hip-6.3.0.test blender.test
-- Testing: 14 tests, 14 workers --
Testing:  0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90
FAIL: test-suite :: External/HIP/blender.test (14 of 14)
******************** TEST 'test-suite :: External/HIP/blender.test' FAILED ********************

/home/botworker/bbot/clang-hip-vega20/botworker/clang-hip-vega20/test-suite-build/tools/timeit-target --timeout 7200 --limit-core 0 --limit-cpu 7200 --limit-file-size 209715200 --limit-rss-size 838860800 --append-exitstatus --redirect-output /home/botworker/bbot/clang-hip-vega20/botworker/clang-hip-vega20/test-suite-build/External/HIP/Output/blender.test.out --redirect-input /dev/null --summary /home/botworker/bbot/clang-hip-vega20/botworker/clang-hip-vega20/test-suite-build/External/HIP/Output/blender.test.time /bin/bash test_blender.sh
/bin/bash verify_blender.sh /home/botworker/bbot/clang-hip-vega20/botworker/clang-hip-vega20/test-suite-build/External/HIP/Output/blender.test.out
Begin Blender test.
TEST_SUITE_HIP_ROOT=/opt/botworker/llvm/External/hip
Render /opt/botworker/llvm/External/hip/Blender_Scenes/290skydemo_release.blend
Blender 4.1.1 (hash e1743a0317bc built 2024-04-15 23:47:45)
Read blend: "/opt/botworker/llvm/External/hip/Blender_Scenes/290skydemo_release.blend"
Could not open as Ogawa file from provided streams.
Unable to open /opt/botworker/llvm/External/hip/Blender_Scenes/290skydemo2_flags.abc
WARN (bke.modifier): source/blender/blenkernel/intern/modifier.cc:425 BKE_modifier_set_error: Object: "GEO-flag.002", Modifier: "MeshSequenceCache", Could not create reader for file //290skydemo2_flags.abc
WARN (bke.modifier): source/blender/blenkernel/intern/modifier.cc:425 BKE_modifier_set_error: Object: "GEO-flag.003", Modifier: "MeshSequenceCache", Could not create reader for file //290skydemo2_flags.abc
WARN (bke.modifier): source/blender/blenkernel/intern/modifier.cc:425 BKE_modifier_set_error: Object: "GEO-flag", Modifier: "MeshSequenceCache", Could not create reader for file //290skydemo2_flags.abc
WARN (bke.modifier): source/blender/blenkernel/intern/modifier.cc:425 BKE_modifier_set_error: Object: "GEO-flag.004", Modifier: "MeshSequenceCache", Could not create reader for file //290skydemo2_flags.abc
WARN (bke.modifier): source/blender/blenkernel/intern/modifier.cc:425 BKE_modifier_set_error: Object: "GEO-flag.001", Modifier: "MeshSequenceCache", Could not create reader for file //290skydemo2_flags.abc
Could not open as Ogawa file from provided streams.
Unable to open /opt/botworker/llvm/External/hip/Blender_Scenes/290skydemo2_flags.abc
WARN (bke.modifier): source/blender/blenkernel/intern/modifier.cc:425 BKE_modifier_set_error: Object: "GEO-flag.003", Modifier: "MeshSequenceCache", Could not create reader for file //290skydemo2_flags.abc
WARN (bke.modifier): source/blender/blenkernel/intern/modifier.cc:425 BKE_modifier_set_error: Object: "GEO-flag", Modifier: "MeshSequenceCache", Could not create reader for file //290skydemo2_flags.abc
WARN (bke.modifier): source/blender/blenkernel/intern/modifier.cc:425 BKE_modifier_set_error: Object: "GEO-flag.001", Modifier: "MeshSequenceCache", Could not create reader for file //290skydemo2_flags.abc
WARN (bke.modifier): source/blender/blenkernel/intern/modifier.cc:425 BKE_modifier_set_error: Object: "GEO-flag.002", Modifier: "MeshSequenceCache", Could not create reader for file //290skydemo2_flags.abc
WARN (bke.modifier): source/blender/blenkernel/intern/modifier.cc:425 BKE_modifier_set_error: Object: "GEO-flag.004", Modifier: "MeshSequenceCache", Could not create reader for file //290skydemo2_flags.abc
I0730 19:40:44.108335 1752073 device.cpp:39] HIPEW initialization succeeded
I0730 19:40:44.110196 1752073 device.cpp:45] Found HIPCC hipcc
I0730 19:40:44.179801 1752073 device.cpp:207] Device has compute preemption or is not used for display.
I0730 19:40:44.179826 1752073 device.cpp:211] Added device "" with id "HIP__0000:a3:00".
I0730 19:40:44.179899 1752073 device.cpp:568] Mapped host memory limit set to 536,444,985,344 bytes. (499.60G)
I0730 19:40:44.180145 1752073 device_impl.cpp:63] Using AVX2 CPU kernels.
Fra:1 Mem:524.00M (Peak 533.90M) | Time:00:00.67 | Mem:0.00M, Peak:0.00M | Scene, View Layer | Synchronizing object | GEO-Rivets
Fra:1 Mem:524.00M (Peak 533.90M) | Time:00:00.67 | Mem:0.00M, Peak:0.00M | Scene, View Layer | Synchronizing object | GEO-Rivets.012
Fra:1 Mem:524.10M (Peak 533.90M) | Time:00:00.67 | Mem:0.00M, Peak:0.00M | Scene, View Layer | Synchronizing object | GEO-Rivets.019
Fra:1 Mem:524.20M (Peak 533.90M) | Time:00:00.67 | Mem:0.00M, Peak:0.00M | Scene, View Layer | Synchronizing object | GEO-Curve_Cables.004
Fra:1 Mem:524.39M (Peak 533.90M) | Time:00:00.67 | Mem:0.00M, Peak:0.00M | Scene, View Layer | Synchronizing object | GEO-Rivets.025
Fra:1 Mem:524.67M (Peak 533.90M) | Time:00:00.67 | Mem:0.00M, Peak:0.00M | Scene, View Layer | Synchronizing object | GEO-Rivets.026
Fra:1 Mem:524.75M (Peak 533.90M) | Time:00:00.67 | Mem:0.00M, Peak:0.00M | Scene, View Layer | Synchronizing object | GEO-Rivets.039
Fra:1 Mem:524.85M (Peak 533.90M) | Time:00:00.67 | Mem:0.00M, Peak:0.00M | Scene, View Layer | Synchronizing object | GEO-Curve_Connectors
Fra:1 Mem:524.97M (Peak 533.90M) | Time:00:00.67 | Mem:0.00M, Peak:0.00M | Scene, View Layer | Synchronizing object | GEO-Curve_Connectors.001
Step 12 (Testing HIP test-suite) failure: Testing HIP test-suite (failure)
@@@BUILD_STEP Testing HIP test-suite@@@
+ build_step 'Testing HIP test-suite'
+ echo '@@@BUILD_STEP Testing HIP test-suite@@@'
+ ninja check-hip-simple
[0/1] cd /home/botworker/bbot/clang-hip-vega20/botworker/clang-hip-vega20/test-suite-build/External/HIP && /home/botworker/bbot/clang-hip-vega20/botworker/clang-hip-vega20/llvm/bin/llvm-lit -sv array-hip-6.3.0.test empty-hip-6.3.0.test with-fopenmp-hip-6.3.0.test saxpy-hip-6.3.0.test memmove-hip-6.3.0.test split-kernel-args-hip-6.3.0.test builtin-logb-scalbn-hip-6.3.0.test TheNextWeek-hip-6.3.0.test algorithm-hip-6.3.0.test cmath-hip-6.3.0.test complex-hip-6.3.0.test math_h-hip-6.3.0.test new-hip-6.3.0.test blender.test
-- Testing: 14 tests, 14 workers --
Testing:  0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90
FAIL: test-suite :: External/HIP/blender.test (14 of 14)
******************** TEST 'test-suite :: External/HIP/blender.test' FAILED ********************

/home/botworker/bbot/clang-hip-vega20/botworker/clang-hip-vega20/test-suite-build/tools/timeit-target --timeout 7200 --limit-core 0 --limit-cpu 7200 --limit-file-size 209715200 --limit-rss-size 838860800 --append-exitstatus --redirect-output /home/botworker/bbot/clang-hip-vega20/botworker/clang-hip-vega20/test-suite-build/External/HIP/Output/blender.test.out --redirect-input /dev/null --summary /home/botworker/bbot/clang-hip-vega20/botworker/clang-hip-vega20/test-suite-build/External/HIP/Output/blender.test.time /bin/bash test_blender.sh
/bin/bash verify_blender.sh /home/botworker/bbot/clang-hip-vega20/botworker/clang-hip-vega20/test-suite-build/External/HIP/Output/blender.test.out
Begin Blender test.
TEST_SUITE_HIP_ROOT=/opt/botworker/llvm/External/hip
Render /opt/botworker/llvm/External/hip/Blender_Scenes/290skydemo_release.blend
Blender 4.1.1 (hash e1743a0317bc built 2024-04-15 23:47:45)
Read blend: "/opt/botworker/llvm/External/hip/Blender_Scenes/290skydemo_release.blend"
Could not open as Ogawa file from provided streams.
Unable to open /opt/botworker/llvm/External/hip/Blender_Scenes/290skydemo2_flags.abc
WARN (bke.modifier): source/blender/blenkernel/intern/modifier.cc:425 BKE_modifier_set_error: Object: "GEO-flag.002", Modifier: "MeshSequenceCache", Could not create reader for file //290skydemo2_flags.abc
WARN (bke.modifier): source/blender/blenkernel/intern/modifier.cc:425 BKE_modifier_set_error: Object: "GEO-flag.003", Modifier: "MeshSequenceCache", Could not create reader for file //290skydemo2_flags.abc
WARN (bke.modifier): source/blender/blenkernel/intern/modifier.cc:425 BKE_modifier_set_error: Object: "GEO-flag", Modifier: "MeshSequenceCache", Could not create reader for file //290skydemo2_flags.abc
WARN (bke.modifier): source/blender/blenkernel/intern/modifier.cc:425 BKE_modifier_set_error: Object: "GEO-flag.004", Modifier: "MeshSequenceCache", Could not create reader for file //290skydemo2_flags.abc
WARN (bke.modifier): source/blender/blenkernel/intern/modifier.cc:425 BKE_modifier_set_error: Object: "GEO-flag.001", Modifier: "MeshSequenceCache", Could not create reader for file //290skydemo2_flags.abc
Could not open as Ogawa file from provided streams.
Unable to open /opt/botworker/llvm/External/hip/Blender_Scenes/290skydemo2_flags.abc
WARN (bke.modifier): source/blender/blenkernel/intern/modifier.cc:425 BKE_modifier_set_error: Object: "GEO-flag.003", Modifier: "MeshSequenceCache", Could not create reader for file //290skydemo2_flags.abc
WARN (bke.modifier): source/blender/blenkernel/intern/modifier.cc:425 BKE_modifier_set_error: Object: "GEO-flag", Modifier: "MeshSequenceCache", Could not create reader for file //290skydemo2_flags.abc
WARN (bke.modifier): source/blender/blenkernel/intern/modifier.cc:425 BKE_modifier_set_error: Object: "GEO-flag.001", Modifier: "MeshSequenceCache", Could not create reader for file //290skydemo2_flags.abc
WARN (bke.modifier): source/blender/blenkernel/intern/modifier.cc:425 BKE_modifier_set_error: Object: "GEO-flag.002", Modifier: "MeshSequenceCache", Could not create reader for file //290skydemo2_flags.abc
WARN (bke.modifier): source/blender/blenkernel/intern/modifier.cc:425 BKE_modifier_set_error: Object: "GEO-flag.004", Modifier: "MeshSequenceCache", Could not create reader for file //290skydemo2_flags.abc
I0730 19:40:44.108335 1752073 device.cpp:39] HIPEW initialization succeeded
I0730 19:40:44.110196 1752073 device.cpp:45] Found HIPCC hipcc
I0730 19:40:44.179801 1752073 device.cpp:207] Device has compute preemption or is not used for display.
I0730 19:40:44.179826 1752073 device.cpp:211] Added device "" with id "HIP__0000:a3:00".
I0730 19:40:44.179899 1752073 device.cpp:568] Mapped host memory limit set to 536,444,985,344 bytes. (499.60G)
I0730 19:40:44.180145 1752073 device_impl.cpp:63] Using AVX2 CPU kernels.
Fra:1 Mem:524.00M (Peak 533.90M) | Time:00:00.67 | Mem:0.00M, Peak:0.00M | Scene, View Layer | Synchronizing object | GEO-Rivets
Fra:1 Mem:524.00M (Peak 533.90M) | Time:00:00.67 | Mem:0.00M, Peak:0.00M | Scene, View Layer | Synchronizing object | GEO-Rivets.012
Fra:1 Mem:524.10M (Peak 533.90M) | Time:00:00.67 | Mem:0.00M, Peak:0.00M | Scene, View Layer | Synchronizing object | GEO-Rivets.019
Fra:1 Mem:524.20M (Peak 533.90M) | Time:00:00.67 | Mem:0.00M, Peak:0.00M | Scene, View Layer | Synchronizing object | GEO-Curve_Cables.004
Fra:1 Mem:524.39M (Peak 533.90M) | Time:00:00.67 | Mem:0.00M, Peak:0.00M | Scene, View Layer | Synchronizing object | GEO-Rivets.025
Fra:1 Mem:524.67M (Peak 533.90M) | Time:00:00.67 | Mem:0.00M, Peak:0.00M | Scene, View Layer | Synchronizing object | GEO-Rivets.026
Fra:1 Mem:524.75M (Peak 533.90M) | Time:00:00.67 | Mem:0.00M, Peak:0.00M | Scene, View Layer | Synchronizing object | GEO-Rivets.039
Fra:1 Mem:524.85M (Peak 533.90M) | Time:00:00.67 | Mem:0.00M, Peak:0.00M | Scene, View Layer | Synchronizing object | GEO-Curve_Connectors
Fra:1 Mem:524.97M (Peak 533.90M) | Time:00:00.67 | Mem:0.00M, Peak:0.00M | Scene, View Layer | Synchronizing object | GEO-Curve_Connectors.001
Fra:1 Mem:525.09M (Peak 533.90M) | Time:00:00.67 | Mem:0.00M, Peak:0.00M | Scene, View Layer | Synchronizing object | GEO-Curve_Connectors.002
Fra:1 Mem:527.20M (Peak 533.90M) | Time:00:00.67 | Mem:0.00M, Peak:0.00M | Scene, View Layer | Synchronizing object | GEO-Curve_Connectors.004
Fra:1 Mem:527.46M (Peak 533.90M) | Time:00:00.67 | Mem:0.00M, Peak:0.00M | Scene, View Layer | Synchronizing object | GEO-Curve_Connectors.006
Fra:1 Mem:527.68M (Peak 533.90M) | Time:00:00.67 | Mem:0.00M, Peak:0.00M | Scene, View Layer | Synchronizing object | GEO-Curve_Connectors.007

snehasish pushed a commit that referenced this pull request Jul 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

compiler-rt PGO Profile Guided Optimizations

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants