[llvm] [llvm-profgen][SPGO] Support profiles with multiple concurrent processes (PR #169353)

Wei Wang via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 9 16:47:26 PST 2025


================
@@ -1152,15 +1226,35 @@ void PerfScriptReader::parseAndAggregateTrace() {
 // A LBR sample is like:
 // 40062f 0x5c6313f/0x5c63170/P/-/-/0  0x5c630e7/0x5c63130/P/-/-/0 ...
 // A heuristic for fast detection by checking whether a
-// leading "  0x" and the '/' exist.
+// leading "0x" and the '/' exist.
 bool PerfScriptReader::isLBRSample(StringRef Line) {
-  // Skip the leading instruction pointer
+  // Skip the leading instruction pointer, and maybe PID
+
   SmallVector<StringRef, 32> Records;
-  Line.trim().split(Records, " ", 2, false);
-  if (Records.size() < 2)
-    return false;
-  if (Records[1].starts_with("0x") && Records[1].contains('/'))
+
+  // Trim off the PID (and maybe part/all of the IP)
----------------
apolloww wrote:

So I suppose the LBR line can be either
1),
```
ip space_delimited_source_target...
```
or
2),
```
pid ip space_delimited_source_target...
```

How about splitting into 3 records, like `Line.trim().split(Records, " ", 3, false);`, then if it returns 2 records, check for case 1. If it returns 3 records, check for case 2.

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


More information about the llvm-commits mailing list