aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/ProfileData/InstrProfWriter.cpp
diff options
context:
space:
mode:
authorKazu Hirata <kazu@google.com>2024-11-19 19:33:26 -0800
committerGitHub <noreply@github.com>2024-11-19 19:33:26 -0800
commitf97c610d1f824bcd3e078560c836aaaffaaf69b0 (patch)
tree9fb79e809970403f7e3379ae43a5534437d290d8 /llvm/lib/ProfileData/InstrProfWriter.cpp
parenta2e266b3463844b92b082698aaf201fdd8757c32 (diff)
downloadllvm-f97c610d1f824bcd3e078560c836aaaffaaf69b0.zip
llvm-f97c610d1f824bcd3e078560c836aaaffaaf69b0.tar.gz
llvm-f97c610d1f824bcd3e078560c836aaaffaaf69b0.tar.bz2
[memprof] Add MemProfReader::takeMemProfData (#116769)
This patch adds MemProfReader::takeMemProfData, a function to return the complete MemProf profile from the reader. We can directly pass its return value to InstrProfWriter::addMemProfData without having to deal with the indivual components of the MemProf profile. The new function is named "take", but it doesn't do std::move yet because of type differences (DenseMap v.s. MapVector). The end state I'm trying to get to is roughly as follows: - MemProfReader accepts IndexedMemProfData as a parameter as opposed to the three individual components (frames, call stacks, and records). - MemProfReader keeps IndexedMemProfData as a class member without decomposing it into its individual components. - MemProfReader returns IndexedMemProfData like: IndexedMemProfData takeMemProfData() { return std::move(MemProfData); }
Diffstat (limited to 'llvm/lib/ProfileData/InstrProfWriter.cpp')
-rw-r--r--llvm/lib/ProfileData/InstrProfWriter.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/llvm/lib/ProfileData/InstrProfWriter.cpp b/llvm/lib/ProfileData/InstrProfWriter.cpp
index 87a538f..a1341d0 100644
--- a/llvm/lib/ProfileData/InstrProfWriter.cpp
+++ b/llvm/lib/ProfileData/InstrProfWriter.cpp
@@ -370,7 +370,8 @@ bool InstrProfWriter::addMemProfData(memprof::IndexedMemProfData Incoming,
if (addMemProfCallStack(CSId, CS, Warn))
return false;
- if (MemProfData.Records.empty())
+ // Add one record at a time if randomization is requested.
+ if (MemProfData.Records.empty() && !MemprofGenerateRandomHotness)
MemProfData.Records = std::move(Incoming.Records);
else
for (const auto &[GUID, Record] : Incoming.Records)