[compiler-rt] [Profile] Use upper 32 bits of profile version for profile variants. (PR #67695)
Zequan Wu via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 28 08:54:40 PDT 2023
https://github.com/ZequanWu created https://github.com/llvm/llvm-project/pull/67695
Currently all upper 8 bits are reserved for different profile variants. We need more bits for new mods in the future.
Context: https://discourse.llvm.org/t/how-to-add-a-new-mode-to-llvm-raw-profile-version/73688
>From 6f042de6bd898437651b9c5cc323e5c86892f443 Mon Sep 17 00:00:00 2001
From: Zequan Wu <zequanwu at google.com>
Date: Thu, 28 Sep 2023 11:46:09 -0400
Subject: [PATCH] [Profile] Use upper 32 bits of profile version for profile
variants.
---
compiler-rt/include/profile/InstrProfData.inc | 5 ++---
llvm/include/llvm/ProfileData/InstrProfData.inc | 5 ++---
llvm/include/llvm/ProfileData/InstrProfReader.h | 4 ++--
llvm/lib/ProfileData/InstrProfReader.cpp | 2 +-
4 files changed, 7 insertions(+), 9 deletions(-)
diff --git a/compiler-rt/include/profile/InstrProfData.inc b/compiler-rt/include/profile/InstrProfData.inc
index 4456bf1ab176325..a000a38098ee30b 100644
--- a/compiler-rt/include/profile/InstrProfData.inc
+++ b/compiler-rt/include/profile/InstrProfData.inc
@@ -644,7 +644,6 @@ serializeValueProfDataFrom(ValueProfRecordClosure *Closure,
(uint64_t)'p' << 40 | (uint64_t)'r' << 32 | (uint64_t)'o' << 24 | \
(uint64_t)'f' << 16 | (uint64_t)'R' << 8 | (uint64_t)129
-/* FIXME: Please remedy the fixme in the header before bumping the version. */
/* Raw profile format version (start from 1). */
#define INSTR_PROF_RAW_VERSION 8
/* Indexed profile format version (start from 1). */
@@ -652,7 +651,7 @@ serializeValueProfDataFrom(ValueProfRecordClosure *Closure,
/* Coverage mapping format version (start from 0). */
#define INSTR_PROF_COVMAP_VERSION 5
-/* Profile version is always of type uint64_t. Reserve the upper 8 bits in the
+/* Profile version is always of type uint64_t. Reserve the upper 32 bits in the
* version for other variants of profile. We set the lowest bit of the upper 8
* bits (i.e. bit 56) to 1 to indicate if this is an IR-level instrumentation
* generated profile, and 0 if this is a Clang FE generated profile.
@@ -663,7 +662,7 @@ serializeValueProfDataFrom(ValueProfRecordClosure *Closure,
* The 62nd bit indicates whether memory profile information is present.
* The 63rd bit indicates if this is a temporal profile.
*/
-#define VARIANT_MASKS_ALL 0xff00000000000000ULL
+#define VARIANT_MASKS_ALL 0xffffffff00000000ULL
#define GET_VERSION(V) ((V) & ~VARIANT_MASKS_ALL)
#define VARIANT_MASK_IR_PROF (0x1ULL << 56)
#define VARIANT_MASK_CSIR_PROF (0x1ULL << 57)
diff --git a/llvm/include/llvm/ProfileData/InstrProfData.inc b/llvm/include/llvm/ProfileData/InstrProfData.inc
index 4456bf1ab176325..a000a38098ee30b 100644
--- a/llvm/include/llvm/ProfileData/InstrProfData.inc
+++ b/llvm/include/llvm/ProfileData/InstrProfData.inc
@@ -644,7 +644,6 @@ serializeValueProfDataFrom(ValueProfRecordClosure *Closure,
(uint64_t)'p' << 40 | (uint64_t)'r' << 32 | (uint64_t)'o' << 24 | \
(uint64_t)'f' << 16 | (uint64_t)'R' << 8 | (uint64_t)129
-/* FIXME: Please remedy the fixme in the header before bumping the version. */
/* Raw profile format version (start from 1). */
#define INSTR_PROF_RAW_VERSION 8
/* Indexed profile format version (start from 1). */
@@ -652,7 +651,7 @@ serializeValueProfDataFrom(ValueProfRecordClosure *Closure,
/* Coverage mapping format version (start from 0). */
#define INSTR_PROF_COVMAP_VERSION 5
-/* Profile version is always of type uint64_t. Reserve the upper 8 bits in the
+/* Profile version is always of type uint64_t. Reserve the upper 32 bits in the
* version for other variants of profile. We set the lowest bit of the upper 8
* bits (i.e. bit 56) to 1 to indicate if this is an IR-level instrumentation
* generated profile, and 0 if this is a Clang FE generated profile.
@@ -663,7 +662,7 @@ serializeValueProfDataFrom(ValueProfRecordClosure *Closure,
* The 62nd bit indicates whether memory profile information is present.
* The 63rd bit indicates if this is a temporal profile.
*/
-#define VARIANT_MASKS_ALL 0xff00000000000000ULL
+#define VARIANT_MASKS_ALL 0xffffffff00000000ULL
#define GET_VERSION(V) ((V) & ~VARIANT_MASKS_ALL)
#define VARIANT_MASK_IR_PROF (0x1ULL << 56)
#define VARIANT_MASK_CSIR_PROF (0x1ULL << 57)
diff --git a/llvm/include/llvm/ProfileData/InstrProfReader.h b/llvm/include/llvm/ProfileData/InstrProfReader.h
index faf91e017756da9..17194e2aa4c73ca 100644
--- a/llvm/include/llvm/ProfileData/InstrProfReader.h
+++ b/llvm/include/llvm/ProfileData/InstrProfReader.h
@@ -318,8 +318,8 @@ class RawInstrProfReader : public InstrProfReader {
/// A list of timestamps paired with a function name reference.
std::vector<std::pair<uint64_t, uint64_t>> TemporalProfTimestamps;
bool ShouldSwapBytes;
- // The value of the version field of the raw profile data header. The lower 56
- // bits specifies the format version and the most significant 8 bits specify
+ // The value of the version field of the raw profile data header. The lower 32
+ // bits specifies the format version and the most significant 32 bits specify
// the variant types of the profile.
uint64_t Version;
uint64_t CountersDelta;
diff --git a/llvm/lib/ProfileData/InstrProfReader.cpp b/llvm/lib/ProfileData/InstrProfReader.cpp
index 9375678f8046167..125184d4020840d 100644
--- a/llvm/lib/ProfileData/InstrProfReader.cpp
+++ b/llvm/lib/ProfileData/InstrProfReader.cpp
@@ -38,7 +38,7 @@
using namespace llvm;
-// Extracts the variant information from the top 8 bits in the version and
+// Extracts the variant information from the top 32 bits in the version and
// returns an enum specifying the variants present.
static InstrProfKind getProfileKindFromVersion(uint64_t Version) {
InstrProfKind ProfileKind = InstrProfKind::Unknown;
More information about the llvm-commits
mailing list