[llvm] [memprof] Use MinimumSupportedVersion in place of Verion0 (NFC) (PR #114723)

Kazu Hirata via llvm-commits llvm-commits at lists.llvm.org
Sun Nov 3 16:19:23 PST 2024


https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/114723

I'm planning to remove old versions of the MemProf indexed formats at
some point.  Replacing these occurrences of Version0 with
MinimumSupportedVersion allows me to touch fewer places when I remove
old versions in the future.

Note that these two parameters being touched in this patch have
nothing to do with the default MemProf version that llvm-profdata
uses, which is controlled by MemProfVersionRequested in
llvm-profdata.cpp.


>From 92d16d49995e2307764b907dbe09b7ed72087402 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Sun, 3 Nov 2024 15:36:35 -0800
Subject: [PATCH] [memprof] Use MinimumSupportedVersion in place of Verion0
 (NFC)

I'm planning to remove old versions of the MemProf indexed formats at
some point.  Replacing these occurrences of Version0 with
MinimumSupportedVersion allows me to touch fewer places when I remove
old versions in the future.

Note that these two parameters being touched in this patch have
nothing to do with the default MemProf version that llvm-profdata
uses, which is controlled by MemProfVersionRequested in
llvm-profdata.cpp.
---
 llvm/include/llvm/ProfileData/InstrProfReader.h |  3 ++-
 llvm/include/llvm/ProfileData/InstrProfWriter.h | 16 ++++++++++------
 2 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/llvm/include/llvm/ProfileData/InstrProfReader.h b/llvm/include/llvm/ProfileData/InstrProfReader.h
index 00b361f4ad1c56..6be3fad41824a9 100644
--- a/llvm/include/llvm/ProfileData/InstrProfReader.h
+++ b/llvm/include/llvm/ProfileData/InstrProfReader.h
@@ -669,7 +669,8 @@ class InstrProfReaderRemapper {
 class IndexedMemProfReader {
 private:
   /// The MemProf version.
-  memprof::IndexedVersion Version = memprof::Version0;
+  memprof::IndexedVersion Version =
+      static_cast<memprof::IndexedVersion>(memprof::MinimumSupportedVersion);
   /// MemProf profile schema (if available).
   memprof::MemProfSchema Schema;
   /// MemProf record profile data on-disk indexed via llvm::md5(FunctionName).
diff --git a/llvm/include/llvm/ProfileData/InstrProfWriter.h b/llvm/include/llvm/ProfileData/InstrProfWriter.h
index 559549b0a22cc9..199e565bead044 100644
--- a/llvm/include/llvm/ProfileData/InstrProfWriter.h
+++ b/llvm/include/llvm/ProfileData/InstrProfWriter.h
@@ -86,12 +86,16 @@ class InstrProfWriter {
   // MemprofGenerateRandomHotness is enabled. The random seed can be either
   // provided by MemprofGenerateRandomHotnessSeed, or if that is 0, one will be
   // generated in the writer using the current time.
-  InstrProfWriter(
-      bool Sparse = false, uint64_t TemporalProfTraceReservoirSize = 0,
-      uint64_t MaxTemporalProfTraceLength = 0, bool WritePrevVersion = false,
-      memprof::IndexedVersion MemProfVersionRequested = memprof::Version0,
-      bool MemProfFullSchema = false, bool MemprofGenerateRandomHotness = false,
-      unsigned MemprofGenerateRandomHotnessSeed = 0);
+  InstrProfWriter(bool Sparse = false,
+                  uint64_t TemporalProfTraceReservoirSize = 0,
+                  uint64_t MaxTemporalProfTraceLength = 0,
+                  bool WritePrevVersion = false,
+                  memprof::IndexedVersion MemProfVersionRequested =
+                      static_cast<memprof::IndexedVersion>(
+                          memprof::MinimumSupportedVersion),
+                  bool MemProfFullSchema = false,
+                  bool MemprofGenerateRandomHotness = false,
+                  unsigned MemprofGenerateRandomHotnessSeed = 0);
   ~InstrProfWriter();
 
   StringMap<ProfilingData> &getProfileData() { return FunctionData; }



More information about the llvm-commits mailing list