aboutsummaryrefslogtreecommitdiff
path: root/llvm/tools/llvm-profdata/llvm-profdata.cpp
diff options
context:
space:
mode:
authorSnehasish Kumar <snehasishk@google.com>2022-03-21 19:39:24 -0700
committerSnehasish Kumar <snehasishk@google.com>2022-04-08 09:15:20 -0700
commit6dd6a6161f3a5c25162af9dc3625c8dfcc62a1ed (patch)
treecbb80987fdf31edb688183c3f357b58443102ae1 /llvm/tools/llvm-profdata/llvm-profdata.cpp
parent575a1d48e781a03a1bb892ff52e16ee0485d0a34 (diff)
downloadllvm-6dd6a6161f3a5c25162af9dc3625c8dfcc62a1ed.zip
llvm-6dd6a6161f3a5c25162af9dc3625c8dfcc62a1ed.tar.gz
llvm-6dd6a6161f3a5c25162af9dc3625c8dfcc62a1ed.tar.bz2
[memprof] Deduplicate and outline frame storage in the memprof profile.
The current implementation of memprof information in the indexed profile format stores the representation of each calling context fram inline. This patch uses an interned representation where the frame contents are stored in a separate on-disk hash table. The table is indexed via a hash of the contents of the frame. With this patch, the compressed size of a large memprof profile reduces by ~22%. Reviewed By: tejohnson Differential Revision: https://reviews.llvm.org/D123094
Diffstat (limited to 'llvm/tools/llvm-profdata/llvm-profdata.cpp')
-rw-r--r--llvm/tools/llvm-profdata/llvm-profdata.cpp25
1 files changed, 19 insertions, 6 deletions
diff --git a/llvm/tools/llvm-profdata/llvm-profdata.cpp b/llvm/tools/llvm-profdata/llvm-profdata.cpp
index b9245fd..73b0416 100644
--- a/llvm/tools/llvm-profdata/llvm-profdata.cpp
+++ b/llvm/tools/llvm-profdata/llvm-profdata.cpp
@@ -266,12 +266,25 @@ static void loadInput(const WeightedFile &Input, SymbolRemapper *Remapper,
return;
}
- // Add the records into the writer context.
- for (auto I = Reader->begin(), E = Reader->end(); I != E; ++I) {
- WC->Writer.addRecord(/*Id=*/I->first, /*Record=*/I->second, [&](Error E) {
- instrprof_error IPE = InstrProfError::take(std::move(E));
- WC->Errors.emplace_back(make_error<InstrProfError>(IPE), Filename);
- });
+ auto MemProfError = [&](Error E) {
+ instrprof_error IPE = InstrProfError::take(std::move(E));
+ WC->Errors.emplace_back(make_error<InstrProfError>(IPE), Filename);
+ };
+
+ // Add the frame mappings into the writer context.
+ const auto &IdToFrame = Reader->getFrameMapping();
+ for (const auto &I : IdToFrame) {
+ bool Succeeded = WC->Writer.addMemProfFrame(
+ /*Id=*/I.first, /*Frame=*/I.getSecond(), MemProfError);
+ // If we weren't able to add the frame mappings then it doesn't make sense
+ // to try to add the records from this profile.
+ if (!Succeeded)
+ return;
+ }
+ const auto &FunctionProfileData = Reader->getProfileData();
+ // Add the memprof records into the writer context.
+ for (const auto &I : FunctionProfileData) {
+ WC->Writer.addMemProfRecord(/*Id=*/I.first, /*Record=*/I.second);
}
return;
}