aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
diff options
context:
space:
mode:
authorKazu Hirata <kazu@google.com>2024-11-24 21:08:54 -0800
committerGitHub <noreply@github.com>2024-11-24 21:08:54 -0800
commitff7b42c194e0fa23e6a76f0a33a80c0c3af14e7d (patch)
tree1420d356236d4a090ea76ea38a254a589ced5168 /llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
parent9e3215ac167b80dcf51d6693ecdd6275c4e89954 (diff)
downloadllvm-ff7b42c194e0fa23e6a76f0a33a80c0c3af14e7d.zip
llvm-ff7b42c194e0fa23e6a76f0a33a80c0c3af14e7d.tar.gz
llvm-ff7b42c194e0fa23e6a76f0a33a80c0c3af14e7d.tar.bz2
[memprof] Speed up llvm-profdata (#117446)
CallStackRadixTreeBuilder::build takes the parameter MemProfFrameIndexes by value, involving copies: std::optional<const llvm::DenseMap<FrameIdTy, LinearFrameId>> MemProfFrameIndexes Then "build" makes another copy of MemProfFrameIndexe and passes it to encodeCallStack for every call stack, which is painfully slow. This patch changes the type to a pointer so that we don't have to make a copy every time we pass the argument. Without this patch, it takes 553 seconds to run "llvm-profdata merge" on a large MemProf raw profile. This patch shortenes that down to 67 seconds.
Diffstat (limited to 'llvm/lib/Bitcode/Writer/BitcodeWriter.cpp')
-rw-r--r--llvm/lib/Bitcode/Writer/BitcodeWriter.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
index 8f22a50..63f4e34 100644
--- a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
+++ b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
@@ -4235,7 +4235,7 @@ static DenseMap<CallStackId, LinearCallStackId> writeMemoryProfileRadixTree(
CallStackRadixTreeBuilder<LinearFrameId> Builder;
// We don't need a MemProfFrameIndexes map as we have already converted the
// full stack id hash to a linear offset into the StackIds array.
- Builder.build(std::move(CallStacks), /*MemProfFrameIndexes=*/std::nullopt,
+ Builder.build(std::move(CallStacks), /*MemProfFrameIndexes=*/nullptr,
FrameHistogram);
Stream.EmitRecord(bitc::FS_CONTEXT_RADIX_TREE_ARRAY, Builder.getRadixArray(),
RadixAbbrev);