[llvm-branch-commits] [llvm-profgen][NFC] Reuse isLBRSample (PR #191595)

via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Wed Apr 15 23:19:07 PDT 2026


================
@@ -1162,13 +1162,18 @@ void PerfScriptReader::parseAndAggregateTrace() {
 // 40062f 0x5c6313f/0x5c63170/P/-/-/0  0x5c630e7/0x5c63130/P/-/-/0 ...
 // A heuristic for fast detection by checking whether a
 // leading "  0x" and the '/' exist.
-bool PerfScriptReader::isLBRSample(StringRef Line) {
+bool PerfScriptReader::isLBRSample(StringRef Line, bool CheckLineStart) {
   // Skip the leading instruction pointer
   SmallVector<StringRef, 32> Records;
-  Line.trim().split(Records, " ", 2, false);
+  if (!CheckLineStart)
+    Line = Line.trim();
+  Line.split(Records, " ", 2, CheckLineStart);
   if (Records.size() < 2)
     return false;
-  if (Records[1].starts_with("0x") && Records[1].contains('/'))
+  StringRef Token = Records[1];
+  if (!Token.contains('/'))
+    return false;
+  if (Token.starts_with("0x"))
----------------
HighW4y2H3ll wrote:

Why splitting the conditions like this? It looks like doing the same thing?

https://github.com/llvm/llvm-project/pull/191595


More information about the llvm-branch-commits mailing list