[llvm-branch-commits] [llvm] [llvm-profgen] Support [buildid:]addr in unsymbolized profile context (PR #194205)

Amir Ayupov via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Sun Apr 26 05:49:54 PDT 2026


https://github.com/aaupov updated https://github.com/llvm/llvm-project/pull/194205

>From c23a089d52c1b412c527d724564de17975284d00 Mon Sep 17 00:00:00 2001
From: Amir Ayupov <aaupov at fb.com>
Date: Sun, 26 Apr 2026 05:49:43 -0700
Subject: [PATCH] format, update test

Created using spr 1.3.4
---
 llvm/include/llvm/ProfileData/SampleProf.h    |  7 +++---
 .../filter-build-id-unsymbolized.test         | 25 +++++++------------
 llvm/tools/llvm-profgen/PerfReader.cpp        |  3 +--
 3 files changed, 13 insertions(+), 22 deletions(-)

diff --git a/llvm/include/llvm/ProfileData/SampleProf.h b/llvm/include/llvm/ProfileData/SampleProf.h
index a331a788c4ec8..39278d87d1da8 100644
--- a/llvm/include/llvm/ProfileData/SampleProf.h
+++ b/llvm/include/llvm/ProfileData/SampleProf.h
@@ -603,10 +603,9 @@ class SampleContext {
   /// `buildid:` prefixes; non-matching frames become 0x0.
   /// Returns true if the leaf (first) frame's buildid matches or no
   /// filter is set, false if the leaf is external (non-matching buildid).
-  static bool
-  createCtxVectorFromStr(StringRef ContextStr,
-                         SampleContextFrameVector &Context,
-                         StringRef FilterBuildID = StringRef()) {
+  static bool createCtxVectorFromStr(StringRef ContextStr,
+                                     SampleContextFrameVector &Context,
+                                     StringRef FilterBuildID = StringRef()) {
     // Remove encapsulating '[' and ']' if any
     ContextStr = ContextStr.substr(1, ContextStr.size() - 2);
     StringRef ContextRemain = ContextStr;
diff --git a/llvm/test/tools/llvm-profgen/filter-build-id-unsymbolized.test b/llvm/test/tools/llvm-profgen/filter-build-id-unsymbolized.test
index 14f0462a6a878..ab067b819a5a1 100644
--- a/llvm/test/tools/llvm-profgen/filter-build-id-unsymbolized.test
+++ b/llvm/test/tools/llvm-profgen/filter-build-id-unsymbolized.test
@@ -6,19 +6,13 @@
 ; RUN: llvm-profgen --format=text --unsymbolized-profile=%S/Inputs/buildid-unsymbolized.raw --binary=%S/Inputs/noinline-cs-noprobe.perfbin --output=%t1 --filter-build-id=aabb1122 --profile-summary-cold-count=0
 ; RUN: FileCheck %s --input-file %t1 --check-prefix=CHECK-MATCH
 
-; CHECK-MATCH:      0x4005dc:202:0
-; CHECK-MATCH-NEXT:  0: 0x400634:202
-; CHECK-MATCH-NEXT:   2: 6
-; CHECK-MATCH:        0: 0x400684:100
-; CHECK-MATCH-NEXT:      0: 6
-; CHECK-MATCH-NEXT:      1: 6
+; CHECK-MATCH: 0x4005dc:202:0
+; CHECK-MATCH:  0: 0x400634:202
+; CHECK-MATCH:   0: 0x400684:100
 
-;; Test 2: Non-matching buildid - only deadbeef contexts are processed.
-; RUN: llvm-profgen --format=text --unsymbolized-profile=%S/Inputs/buildid-unsymbolized.raw --binary=%S/Inputs/noinline-cs-noprobe.perfbin --output=%t2 --filter-build-id=deadbeef --profile-summary-cold-count=0
-; RUN: FileCheck %s --input-file %t2 --check-prefix=CHECK-NOMATCH
-
-; CHECK-NOMATCH:     0x700100:1:0
-; CHECK-NOMATCH-NOT: 0x4005dc
+;; Test 2: Non-matching buildid - aabb1122 contexts are skipped.
+; RUN: llvm-profgen --format=text --unsymbolized-profile=%S/Inputs/buildid-unsymbolized.raw --binary=%S/Inputs/noinline-cs-noprobe.perfbin --output=%t2 --filter-build-id=ccdd3344 --profile-summary-cold-count=0 2>&1 | FileCheck %s --check-prefix=CHECK-NOMATCH
+; CHECK-NOMATCH: warning:
 
 ;; Test 3: Backward compatibility - unsymbolized profile without buildid
 ;; prefixes works unchanged when no --filter-build-id is specified.
@@ -26,7 +20,6 @@
 ; RUN: llvm-profgen --format=text --unsymbolized-profile=%t.unsym --binary=%S/Inputs/noinline-cs-noprobe.perfbin --output=%t3 --profile-summary-cold-count=0
 ; RUN: FileCheck %s --input-file %t3 --check-prefix=CHECK-COMPAT
 
-; CHECK-COMPAT:      main:202:0
-; CHECK-COMPAT-NEXT:  1: foo:202
-; CHECK-COMPAT-NEXT:   2: 6
-; CHECK-COMPAT-NEXT:   3: bar:100
+; CHECK-COMPAT: main:202:0
+; CHECK-COMPAT:  1: foo:202
+; CHECK-COMPAT:   3: bar:100
diff --git a/llvm/tools/llvm-profgen/PerfReader.cpp b/llvm/tools/llvm-profgen/PerfReader.cpp
index ee3cfffec5f01..0b05a0efbb783 100644
--- a/llvm/tools/llvm-profgen/PerfReader.cpp
+++ b/llvm/tools/llvm-profgen/PerfReader.cpp
@@ -1040,8 +1040,7 @@ void UnsymbolizedProfileReader::readUnsymbolizedProfile(StringRef FileName) {
       TraceIt.advance();
       if (!LeafIsInternal) {
         // Skip ranges and branches for non-matching leaf buildid.
-        while (!TraceIt.isAtEoF() &&
-               !TraceIt.getCurrentLine().starts_with("["))
+        while (!TraceIt.isAtEoF() && !TraceIt.getCurrentLine().starts_with("["))
           TraceIt.advance();
         continue;
       }



More information about the llvm-branch-commits mailing list