aboutsummaryrefslogtreecommitdiff
path: root/llvm/tools/llvm-profdata/llvm-profdata.cpp
diff options
context:
space:
mode:
authorKazu Hirata <kazu@google.com>2024-04-18 14:12:58 -0700
committerGitHub <noreply@github.com>2024-04-18 14:12:58 -0700
commit172f6ddfa7662a36e3a41db6bb944f7d72fd0b00 (patch)
tree57e5d885aeda67aa160c2134ebdce099d09d5c14 /llvm/tools/llvm-profdata/llvm-profdata.cpp
parent7aad1ee70f2c6be603707ff52a13e0e22330e859 (diff)
downloadllvm-172f6ddfa7662a36e3a41db6bb944f7d72fd0b00.zip
llvm-172f6ddfa7662a36e3a41db6bb944f7d72fd0b00.tar.gz
llvm-172f6ddfa7662a36e3a41db6bb944f7d72fd0b00.tar.bz2
[memprof] Add Version2 of the indexed MemProf format (#89100)
This patch adds Version2 of the indexed MemProf format. The new format comes with a hash table from CallStackId to actual call stacks llvm::SmallVector<FrameId>. The rest of the format refers to call stacks with CallStackId. This "values + references" model effectively deduplicates call stacks. Without this patch, a large indexed memprof file of mine shrinks from 4.4GB to 1.6GB, a 64% reduction. This patch does not make Version2 generally available yet as I am planning to make a few more changes to the format.
Diffstat (limited to 'llvm/tools/llvm-profdata/llvm-profdata.cpp')
-rw-r--r--llvm/tools/llvm-profdata/llvm-profdata.cpp15
1 files changed, 14 insertions, 1 deletions
diff --git a/llvm/tools/llvm-profdata/llvm-profdata.cpp b/llvm/tools/llvm-profdata/llvm-profdata.cpp
index 66a4cea..78daf9f 100644
--- a/llvm/tools/llvm-profdata/llvm-profdata.cpp
+++ b/llvm/tools/llvm-profdata/llvm-profdata.cpp
@@ -305,7 +305,8 @@ cl::opt<memprof::IndexedVersion> MemProfVersionRequested(
cl::desc("Specify the version of the memprof format to use"),
cl::init(memprof::Version0),
cl::values(clEnumValN(memprof::Version0, "0", "version 0"),
- clEnumValN(memprof::Version1, "1", "version 1")));
+ clEnumValN(memprof::Version1, "1", "version 1"),
+ clEnumValN(memprof::Version2, "2", "version 2")));
// Options specific to overlap subcommand.
cl::opt<std::string> BaseFilename(cl::Positional, cl::Required,
@@ -677,6 +678,18 @@ static void loadInput(const WeightedFile &Input, SymbolRemapper *Remapper,
if (!Succeeded)
return;
}
+
+ // Add the call stacks into the writer context.
+ const auto &CSIdToCallStacks = Reader->getCallStacks();
+ for (const auto &I : CSIdToCallStacks) {
+ bool Succeeded = WC->Writer.addMemProfCallStack(
+ /*Id=*/I.first, /*Frame=*/I.getSecond(), MemProfError);
+ // If we weren't able to add the call stacks 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 &[GUID, Record] : FunctionProfileData) {