[PATCH] D139603: [llvm-profdata] Add option to cap profile output size

David Li via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 7 20:54:42 PST 2022


davidxl added a comment.

Add a test case for completeness.



================
Comment at: llvm/lib/ProfileData/SampleProfWriter.cpp:533
 std::error_code SampleProfileWriterBinary::writeNameIdx(StringRef FName) {
-  auto &NTable = getNameTable();
-  const auto &Ret = NTable.find(FName);
-  if (Ret == NTable.end())
+  const auto &Ret = NameTable.find(FName);
+  if (Ret == NameTable.end())
----------------
unneeded change


================
Comment at: llvm/lib/ProfileData/SampleProfWriter.cpp:541
 void SampleProfileWriterBinary::addName(StringRef FName) {
-  auto &NTable = getNameTable();
-  NTable.insert(std::make_pair(FName, 0));
+  NameTable.insert(std::make_pair(FName, 0));
 }
----------------
unneeded change.


================
Comment at: llvm/lib/ProfileData/SampleProfWriter.cpp:567
+    const SampleProfileMap &ProfileMap) {
+  NameTable.clear();
+  for (const auto &I : ProfileMap) {
----------------
The clear call changes the behavior. Why is it needed?


================
Comment at: llvm/tools/llvm-profdata/llvm-profdata.cpp:1077
+
+  // If limiting output size, rewrite the entire profile by dropping samples if
+  // the profile size exceeds limit. This iterates multiple times until the
----------------
Extract the following to a helper function.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D139603/new/

https://reviews.llvm.org/D139603



More information about the llvm-commits mailing list