[PATCH] D123513: [BOLT] Compact legacy profiles

Yi Kong via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 12 01:43:44 PDT 2022


This revision was automatically updated to reflect the committed changes.
Closed by commit rG7d7771f34d14: [BOLT] Compact legacy profiles (authored by kongyi).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123513

Files:
  bolt/tools/merge-fdata/merge-fdata.cpp


Index: bolt/tools/merge-fdata/merge-fdata.cpp
===================================================================
--- bolt/tools/merge-fdata/merge-fdata.cpp
+++ bolt/tools/merge-fdata/merge-fdata.cpp
@@ -239,6 +239,7 @@
   errs() << "Using legacy profile format.\n";
   bool BoltedCollection = false;
   bool First = true;
+  StringMap<uint64_t> Entries;
   for (const std::string &Filename : Filenames) {
     if (isYAML(Filename))
       report_error(Filename, "cannot mix YAML and legacy formats");
@@ -265,9 +266,25 @@
             "cannot mix profile collected in BOLT and non-BOLT deployments");
     }
 
-    outs() << Buf;
+    SmallVector<StringRef, 10> Lines;
+    SplitString(Buf, Lines, "\n");
+    for (StringRef Line : Lines) {
+      size_t Pos = Line.rfind(" ");
+      if (Pos == StringRef::npos)
+        report_error(Filename, "Malformed / corrupted profile");
+      StringRef Signature = Line.substr(0, Pos);
+      uint64_t Count;
+      if (Line.substr(Pos + 1, Line.size() - Pos).getAsInteger(10, Count))
+        report_error(Filename, "Malformed / corrupted profile counter");
+      Count += Entries.lookup(Signature);
+      Entries.insert_or_assign(Signature, Count);
+    }
     First = false;
   }
+
+  for (const auto &Entry : Entries)
+    outs() << Entry.getKey() << " " << Entry.getValue() << "\n";
+
   errs() << "Profile from " << Filenames.size() << " files merged.\n";
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D123513.422140.patch
Type: text/x-patch
Size: 1413 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220412/00044c3b/attachment.bin>


More information about the llvm-commits mailing list