[llvm-branch-commits] [llvm] [llvm-profgen] Support [buildid:]0xaddr format in perfscript input (PR #190863)
Amir Ayupov via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Thu Apr 30 20:46:11 PDT 2026
https://github.com/aaupov updated https://github.com/llvm/llvm-project/pull/190863
>From a98cb95a1c3b46f242e6ffc30148d6c267ea9cf2 Mon Sep 17 00:00:00 2001
From: Amir Ayupov <aaupov at fb.com>
Date: Sun, 12 Apr 2026 12:15:02 -0700
Subject: [PATCH] reduce changes
Created using spr 1.3.4
---
llvm/tools/llvm-profgen/PerfReader.cpp | 20 ++++++++++----------
llvm/tools/llvm-profgen/PerfReader.h | 3 +++
2 files changed, 13 insertions(+), 10 deletions(-)
diff --git a/llvm/tools/llvm-profgen/PerfReader.cpp b/llvm/tools/llvm-profgen/PerfReader.cpp
index becabe4ab37bd..785946188b0b6 100644
--- a/llvm/tools/llvm-profgen/PerfReader.cpp
+++ b/llvm/tools/llvm-profgen/PerfReader.cpp
@@ -747,9 +747,9 @@ bool PerfScriptReader::extractLBRStack(TraceStream &TraceIt,
// For pre-aggregated input, filter by build ID.
if (IsPreAggregated) {
StringRef BinaryBuildID = getFilterBuildID(Binary);
- if (!SrcBuildID.empty() && SrcBuildID != BinaryBuildID)
+ if (SrcBuildID != BinaryBuildID)
SrcIsInternal = false;
- if (!DstBuildID.empty() && DstBuildID != BinaryBuildID)
+ if (DstBuildID != BinaryBuildID)
DstIsInternal = false;
}
if (!SrcIsInternal)
@@ -775,8 +775,7 @@ bool PerfScriptReader::extractCallstack(TraceStream &TraceIt,
// It's in bottom-up order with each frame in one line.
// Extract stack frames from sample
- while (!TraceIt.isAtEoF() &&
- !isLBRSample(TraceIt.getCurrentLine(), true, IsPreAggregated)) {
+ while (!TraceIt.isAtEoF() && !isLBRSample(TraceIt.getCurrentLine(), true)) {
StringRef FrameStr = TraceIt.getCurrentLine().ltrim();
uint64_t FrameAddr = 0;
StringRef FrameBuildID;
@@ -830,8 +829,7 @@ bool PerfScriptReader::extractCallstack(TraceStream &TraceIt,
// Skip other unrelated line, find the next valid LBR line
// Note that even for empty call stack, we should skip the address at the
// bottom, otherwise the following pass may generate a truncated callstack
- while (!TraceIt.isAtEoF() &&
- !isLBRSample(TraceIt.getCurrentLine(), true, IsPreAggregated)) {
+ while (!TraceIt.isAtEoF() && !isLBRSample(TraceIt.getCurrentLine(), true)) {
TraceIt.advance();
}
// Filter out broken stack sample. We may not have complete frame info
@@ -876,16 +874,14 @@ void HybridPerfReader::parseSample(TraceStream &TraceIt, uint64_t Count) {
// Parsing call stack and populate into PerfSample.CallStack
if (!extractCallstack(TraceIt, Sample->CallStack)) {
// Skip the next LBR line matched current call stack
- if (!TraceIt.isAtEoF() &&
- isLBRSample(TraceIt.getCurrentLine(), true, IsPreAggregated))
+ if (!TraceIt.isAtEoF() && isLBRSample(TraceIt.getCurrentLine(), true))
TraceIt.advance();
return;
}
warnIfMissingMMap();
- if (!TraceIt.isAtEoF() &&
- isLBRSample(TraceIt.getCurrentLine(), true, IsPreAggregated)) {
+ if (!TraceIt.isAtEoF() && isLBRSample(TraceIt.getCurrentLine(), true)) {
// Parsing LBR stack and populate into PerfSample.LBRStack
if (extractLBRStack(TraceIt, Sample->LBRStack)) {
if (IgnoreStackSamples) {
@@ -1227,6 +1223,10 @@ bool PerfScriptReader::isLBRSample(StringRef Line, bool CheckLineStart,
return IsPreAggregated && Token.contains(":0x");
}
+bool PerfScriptReader::isLBRSample(StringRef Line, bool CheckLineStart) {
+ return isLBRSample(Line, CheckLineStart, IsPreAggregated);
+}
+
bool PerfScriptReader::isMMapEvent(StringRef Line) {
// Short cut to avoid string find is possible.
if (Line.empty() || Line.size() < 50)
diff --git a/llvm/tools/llvm-profgen/PerfReader.h b/llvm/tools/llvm-profgen/PerfReader.h
index f06c06d038a7b..7feb02b8c94c6 100644
--- a/llvm/tools/llvm-profgen/PerfReader.h
+++ b/llvm/tools/llvm-profgen/PerfReader.h
@@ -634,6 +634,9 @@ class PerfScriptReader : public PerfReaderBase {
void setIsPreAggregated(bool V) { IsPreAggregated = V; }
+ // Check whether a given line is LBR sample
+ bool isLBRSample(StringRef Line, bool CheckLineStart);
+
protected:
// Check whether a given line is LBR sample
static bool isLBRSample(StringRef Line, bool CheckLineStart,
More information about the llvm-branch-commits
mailing list