aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/ProfileData/InstrProfWriter.cpp
diff options
context:
space:
mode:
authorKazu Hirata <kazu@google.com>2024-04-12 11:14:20 -0700
committerGitHub <noreply@github.com>2024-04-12 11:14:20 -0700
commit83dc41992dc602070f5429e2717352f60aad931c (patch)
tree2b04f2ec81d637722986fdbdce9adf1e73e636df /llvm/lib/ProfileData/InstrProfWriter.cpp
parent4b0beb4f5ec42aea58461df7994e2fa40f335bb6 (diff)
downloadllvm-83dc41992dc602070f5429e2717352f60aad931c.zip
llvm-83dc41992dc602070f5429e2717352f60aad931c.tar.gz
llvm-83dc41992dc602070f5429e2717352f60aad931c.tar.bz2
[memprof] Clean up writer traits (NFC) (#88549)
RecordWriter does not live past the end of writeMemProfRecords, so it can be safely on stack. The constructor of FrameWriter does not take any parameter, so we can let OnDiskChainedHashTableGenerator::Emit (with a single parameter) default-construct an instance of the writer trait inside Emit.
Diffstat (limited to 'llvm/lib/ProfileData/InstrProfWriter.cpp')
-rw-r--r--llvm/lib/ProfileData/InstrProfWriter.cpp12
1 files changed, 5 insertions, 7 deletions
diff --git a/llvm/lib/ProfileData/InstrProfWriter.cpp b/llvm/lib/ProfileData/InstrProfWriter.cpp
index 7c56cde..ede042d 100644
--- a/llvm/lib/ProfileData/InstrProfWriter.cpp
+++ b/llvm/lib/ProfileData/InstrProfWriter.cpp
@@ -428,14 +428,13 @@ static uint64_t writeMemProfRecords(
llvm::MapVector<GlobalValue::GUID, memprof::IndexedMemProfRecord>
&MemProfRecordData,
memprof::MemProfSchema *Schema) {
- auto RecordWriter =
- std::make_unique<memprof::RecordWriterTrait>(memprof::Version1);
- RecordWriter->Schema = Schema;
+ memprof::RecordWriterTrait RecordWriter(memprof::Version1);
+ RecordWriter.Schema = Schema;
OnDiskChainedHashTableGenerator<memprof::RecordWriterTrait>
RecordTableGenerator;
for (auto &[GUID, Record] : MemProfRecordData) {
// Insert the key (func hash) and value (memprof record).
- RecordTableGenerator.insert(GUID, Record, *RecordWriter.get());
+ RecordTableGenerator.insert(GUID, Record, RecordWriter);
}
// Release the memory of this MapVector as it is no longer needed.
MemProfRecordData.clear();
@@ -443,14 +442,13 @@ static uint64_t writeMemProfRecords(
// The call to Emit invokes RecordWriterTrait::EmitData which destructs
// the memprof record copies owned by the RecordTableGenerator. This works
// because the RecordTableGenerator is not used after this point.
- return RecordTableGenerator.Emit(OS.OS, *RecordWriter);
+ return RecordTableGenerator.Emit(OS.OS, RecordWriter);
}
// Serialize MemProfFrameData. Return FrameTableOffset.
static uint64_t writeMemProfFrames(
ProfOStream &OS,
llvm::MapVector<memprof::FrameId, memprof::Frame> &MemProfFrameData) {
- auto FrameWriter = std::make_unique<memprof::FrameWriterTrait>();
OnDiskChainedHashTableGenerator<memprof::FrameWriterTrait>
FrameTableGenerator;
for (auto &[FrameId, Frame] : MemProfFrameData) {
@@ -460,7 +458,7 @@ static uint64_t writeMemProfFrames(
// Release the memory of this MapVector as it is no longer needed.
MemProfFrameData.clear();
- return FrameTableGenerator.Emit(OS.OS, *FrameWriter);
+ return FrameTableGenerator.Emit(OS.OS);
}
static Error writeMemProfV0(