[llvm-branch-commits] [llvm-profgen] Support [buildid:]0xaddr format in perfscript input (PR #190863)
Amir Ayupov via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Fri Apr 10 21:34:30 PDT 2026
================
@@ -654,6 +661,43 @@ void HybridPerfReader::unwindSamples() {
"frame to match.");
}
+/// Parse an address that may optionally have a build ID prefix in
+/// [buildid:]addr format. Sets \p BuildID to the build ID prefix (empty if
+/// none) and \p Addr to the hex address. Returns true on success.
+/// Handles optional "0x" prefix on the address part.
+static bool parseAddressWithBuildID(StringRef Str, uint64_t &Addr,
+ StringRef &BuildID) {
+ BuildID = StringRef();
+ size_t ColonPos = Str.find(':');
+ if (ColonPos != StringRef::npos) {
+ BuildID = Str.substr(0, ColonPos);
+ Str = Str.substr(ColonPos + 1);
+ }
+ Str.consume_front("0x");
+ return !Str.getAsInteger(16, Addr);
+}
+
+/// Return the build ID to use for filtering perfscript addresses.
+/// If --filter-build-id is specified, use it as an override.
+/// Otherwise, use the auto-detected value from the binary.
+static StringRef getFilterBuildID(const ProfiledBinary *Binary) {
+ if (FilterBuildID.getNumOccurrences() > 0)
+ return FilterBuildID;
+ return Binary->getFilterBuildID();
+}
+
+/// Check if a line looks like an LBR sample line. LBR lines start with
+/// a space and the first whitespace-delimited token contains '/'.
+static bool looksLikeLBRLine(StringRef Line) {
----------------
aaupov wrote:
Moved to https://github.com/llvm/llvm-project/pull/191595
https://github.com/llvm/llvm-project/pull/190863
More information about the llvm-branch-commits
mailing list