[PATCH] D46433: [LNT] lnt profile upgrade command for large Spec2017 perf.data aborts

Phabricator via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 23 06:01:13 PDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rL333081: lnt profile upgrade command for large Spec2017 perf.data aborts. (authored by kbeyls, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D46433?vs=145201&id=148197#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D46433

Files:
  lnt/trunk/lnt/testing/profile/cPerf.cpp


Index: lnt/trunk/lnt/testing/profile/cPerf.cpp
===================================================================
--- lnt/trunk/lnt/testing/profile/cPerf.cpp
+++ lnt/trunk/lnt/testing/profile/cPerf.cpp
@@ -280,20 +280,25 @@
       if (Len == -1)
         break;
 
-      char One[32], Two[32], Three[32], Four[512];
-      if (sscanf(Line, "%s %s %s %s", One, Two, Three, Four) < 4)
-        continue;
+      std::vector<std::string> SplittedLine;
+      if (splitLine(std::string(Line), SplittedLine) < 4)
+        continue; 
+
+      const std::string& One = SplittedLine[0];
+      const std::string& Two = SplittedLine[1];
+      const std::string& Three = SplittedLine[2];
+      std::string& Four = SplittedLine[3];
 
       char *EndPtr = NULL;
-      uint64_t Start = strtoull(One, &EndPtr, 16);
-      if (EndPtr == One)
+      uint64_t Start = strtoull(One.c_str(), &EndPtr, 16);
+      if (EndPtr == One.c_str())
         continue;
-      uint64_t Extent = strtoull(Two, &EndPtr, 16);
-      if (EndPtr == Two)
+      uint64_t Extent = strtoull(Two.c_str(), &EndPtr, 16);
+      if (EndPtr == Two.c_str())
         continue;
-      if (strlen(Three) != 1)
+      if (Three.length() != 1)
         continue;
-      switch (Three[0]) {
+      switch (Three.front()) {
       default:
         continue;
       case 'T':
@@ -304,10 +309,9 @@
       case 'w': // Weak object (not tagged as such)
         break;
       }
-      std::string S(Four);
-      if (S.back() == '\n')
-        S.pop_back();
-      push_back({Start, Start + Extent, S});
+      if (Four.back() == '\n')
+        Four.pop_back();
+      push_back({Start, Start + Extent, Four});
     }
     if (Line)
       free(Line);
@@ -326,6 +330,16 @@
     auto NewEnd = std::unique(begin(), end());
     erase(NewEnd, end());
   }
+
+protected:
+  int splitLine(const std::string& line, std::vector<std::string>& output, char delim = ' ') {
+    std::stringstream ss(line);
+    std::string token;
+    while (std::getline(ss, token, delim)) {
+        output.push_back(token);
+    }
+    return output.size();
+  }
 };
 
 class ObjdumpOutput {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D46433.148197.patch
Type: text/x-patch
Size: 2119 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180523/91e6d51e/attachment.bin>


More information about the llvm-commits mailing list