Skip to content

Commit 34dffc5

Browse files
[memprof] Accept Schema in the constructor of RecordWriterTrait (NFC) (llvm#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.
1 parent 1faf314 commit 34dffc5

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

llvm/include/llvm/ProfileData/MemProf.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -514,16 +514,17 @@ class RecordWriterTrait {
514514
using hash_value_type = uint64_t;
515515
using offset_type = uint64_t;
516516

517-
// Pointer to the memprof schema to use for the generator. Unlike the reader
518-
// we must use a default constructor with no params for the writer trait so we
519-
// have a public member which must be initialized by the user.
520-
MemProfSchema *Schema = nullptr;
517+
private:
518+
// Pointer to the memprof schema to use for the generator.
519+
const MemProfSchema *Schema;
521520
// The MemProf version to use for the serialization.
522521
IndexedVersion Version;
523522

523+
public:
524524
// We do not support the default constructor, which does not set Version.
525525
RecordWriterTrait() = delete;
526-
RecordWriterTrait(IndexedVersion V) : Version(V) {}
526+
RecordWriterTrait(const MemProfSchema *Schema, IndexedVersion V)
527+
: Schema(Schema), Version(V) {}
527528

528529
static hash_value_type ComputeHash(key_type_ref K) { return K; }
529530

llvm/lib/ProfileData/InstrProfWriter.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -451,8 +451,7 @@ static uint64_t writeMemProfRecords(
451451
llvm::MapVector<GlobalValue::GUID, memprof::IndexedMemProfRecord>
452452
&MemProfRecordData,
453453
memprof::MemProfSchema *Schema, memprof::IndexedVersion Version) {
454-
memprof::RecordWriterTrait RecordWriter(Version);
455-
RecordWriter.Schema = Schema;
454+
memprof::RecordWriterTrait RecordWriter(Schema, Version);
456455
OnDiskChainedHashTableGenerator<memprof::RecordWriterTrait>
457456
RecordTableGenerator;
458457
for (auto &[GUID, Record] : MemProfRecordData) {

0 commit comments

Comments
 (0)