[PATCH] D108147: [SamplePGO][NFC] Dump function profiles in order

Hongtao Yu via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 16 11:16:32 PDT 2021


hoy added inline comments.


================
Comment at: llvm/lib/ProfileData/SampleProfReader.cpp:69-82
+  // Sort the ProfileMap by total samples.
+  typedef std::pair<StringRef, const FunctionSamples *> NameFunctionSamples;
+  std::vector<NameFunctionSamples> V;
+  for (const auto &I : Profiles) {
+    assert(I.getKey() == I.second.getNameWithContext() &&
+           "Inconsistent profile map");
+    V.push_back(std::make_pair(I.second.getNameWithContext(), &I.second));
----------------
wenlei wrote:
> This is duplicated of the sorting in `SampleProfileWriter::writeFuncProfiles`. Can we make a standalone helper in SampleProf.h to avoid duplicate?
Good call, done.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108147



More information about the llvm-commits mailing list