[llvm] [BOLT] Support --lite selection with basic sample profiles (PR #210226)

Daniel Hill via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 16 18:53:41 PDT 2026


https://github.com/hilldani created https://github.com/llvm/llvm-project/pull/210226

Seed function execution counts from no-LBR basic samples during profile preprocessing, allowing `--lite` threshold selection to identify profiled functions. Add coverage for lite-mode processing of no-LBR fdata.

>From 9c28a9923781c56f7a40ed3c9b74b2808d7276be Mon Sep 17 00:00:00 2001
From: hilldani <daniel.hill at mongodb.com>
Date: Thu, 16 Jul 2026 20:49:46 -0400
Subject: [PATCH] allow basic sample lite pct

---
 bolt/lib/Profile/DataReader.cpp | 4 ++++
 bolt/test/X86/nolbr.s           | 5 +++++
 2 files changed, 9 insertions(+)

diff --git a/bolt/lib/Profile/DataReader.cpp b/bolt/lib/Profile/DataReader.cpp
index 7fcaffd763ad3..c6377d46252a1 100644
--- a/bolt/lib/Profile/DataReader.cpp
+++ b/bolt/lib/Profile/DataReader.cpp
@@ -275,6 +275,10 @@ Error DataReader::preprocessProfile(BinaryContext &BC) {
       FuncData->setEntryCounts(Function);
       FuncData->Used = true;
     }
+    if (NoLBRMode)
+      if (FuncBasicSampleData *SampleData =
+              getFuncBasicSampleData(Function.getNames()))
+        Function.setExecutionCount(SampleData->getSamples());
   }
 
   for (auto &BFI : BC.getBinaryFunctions()) {
diff --git a/bolt/test/X86/nolbr.s b/bolt/test/X86/nolbr.s
index 774819381ec82..6cdeb47f3441c 100644
--- a/bolt/test/X86/nolbr.s
+++ b/bolt/test/X86/nolbr.s
@@ -12,6 +12,8 @@
 # RUN: %clang %cflags %t.o -o %t.exe -Wl,-q -nostdlib
 # RUN: llvm-bolt %t.exe -o %t.out --data %t.fdata --dyno-stats -ba \
 # RUN:    --print-only=_start 2>&1 | FileCheck %s --check-prefix=CHECK-BOLT
+# RUN: llvm-bolt %t.exe -o %t.lite.out --data %t.fdata --lite \
+# RUN:    --lite-threshold-count=1 -v=1 2>&1 | FileCheck %s --check-prefix=CHECK-LITE
 ## Check that invalid fdata is detected.
 # RUN: cp %t.fdata %t.invalid.fdata
 # RUN: echo "invalid" >> %t.invalid.fdata
@@ -26,6 +28,9 @@
 # CHECK-BOLT: BOLT-INFO: 1 out of 1 functions in the binary (100.0%) have non-empty execution profile
 # CHECK-BOLT-NOT: WARNING: invalid profile data detected
 
+# CHECK-LITE-NOT: BOLT-INFO: skipping processing _start per user request
+# CHECK-LITE: BOLT-INFO: operating with basic samples profiling data (no brstack).
+
 # CHECK-WARN: WARNING: invalid profile data detected at line {{[0-9]+}}. Possibly corrupted profile.
 
   .globl _start



More information about the llvm-commits mailing list