[llvm] [memprof] Accept Schema in the constructor of RecordWriterTrait (NFC) (PR #89486)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 19 20:43:48 PDT 2024
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/89486
The comment being deleted in this patch is not correct. We already
construct an instance of RecordWriterTrait with Version.
This patch teaches the constructor of RecordWriterTrait to accept
Schema. While I am at it, this patch makes Version a private
variable.
>From 1caded2e1772f5e7fc0c84f0e48c4017871b073c Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Fri, 19 Apr 2024 19:10:16 -0700
Subject: [PATCH] [memprof] Accept Schema in the constructor of
RecordWriterTrait (NFC)
The comment being deleted in this patch is not correct. We already
construct an instance of RecordWriterTrait with Version.
This patch teaches the constructor of RecordWriterTrait to accept
Schema. While I am at it, this patch makes Version a private
variable.
---
llvm/include/llvm/ProfileData/MemProf.h | 11 ++++++-----
llvm/lib/ProfileData/InstrProfWriter.cpp | 3 +--
2 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/llvm/include/llvm/ProfileData/MemProf.h b/llvm/include/llvm/ProfileData/MemProf.h
index faaec331c823ed..59ef59fd33a3ff 100644
--- a/llvm/include/llvm/ProfileData/MemProf.h
+++ b/llvm/include/llvm/ProfileData/MemProf.h
@@ -514,16 +514,17 @@ class RecordWriterTrait {
using hash_value_type = uint64_t;
using offset_type = uint64_t;
- // Pointer to the memprof schema to use for the generator. Unlike the reader
- // we must use a default constructor with no params for the writer trait so we
- // have a public member which must be initialized by the user.
- MemProfSchema *Schema = nullptr;
+private:
+ // Pointer to the memprof schema to use for the generator.
+ const MemProfSchema *Schema;
// The MemProf version to use for the serialization.
IndexedVersion Version;
+public:
// We do not support the default constructor, which does not set Version.
RecordWriterTrait() = delete;
- RecordWriterTrait(IndexedVersion V) : Version(V) {}
+ RecordWriterTrait(const MemProfSchema *Schema, IndexedVersion V)
+ : Schema(Schema), Version(V) {}
static hash_value_type ComputeHash(key_type_ref K) { return K; }
diff --git a/llvm/lib/ProfileData/InstrProfWriter.cpp b/llvm/lib/ProfileData/InstrProfWriter.cpp
index 0bc5f5206dc2ff..4a6fc9d64b6900 100644
--- a/llvm/lib/ProfileData/InstrProfWriter.cpp
+++ b/llvm/lib/ProfileData/InstrProfWriter.cpp
@@ -451,8 +451,7 @@ static uint64_t writeMemProfRecords(
llvm::MapVector<GlobalValue::GUID, memprof::IndexedMemProfRecord>
&MemProfRecordData,
memprof::MemProfSchema *Schema, memprof::IndexedVersion Version) {
- memprof::RecordWriterTrait RecordWriter(Version);
- RecordWriter.Schema = Schema;
+ memprof::RecordWriterTrait RecordWriter(Schema, Version);
OnDiskChainedHashTableGenerator<memprof::RecordWriterTrait>
RecordTableGenerator;
for (auto &[GUID, Record] : MemProfRecordData) {
More information about the llvm-commits
mailing list