[llvm] [BOLT] Support --lite selection with basic sample profiles (PR #210226)
Daniel Hill via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 17 03:22:24 PDT 2026
https://github.com/hilldani updated https://github.com/llvm/llvm-project/pull/210226
>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 1/2] 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
>From 9e59047698c287829c9a5dd8dada563cf3049bdd Mon Sep 17 00:00:00 2001
From: hilldani <daniel.hill at mongodb.com>
Date: Fri, 17 Jul 2026 06:21:59 -0400
Subject: [PATCH 2/2] [BOLT] Address review comments
---
bolt/lib/Profile/DataReader.cpp | 6 ++++--
bolt/test/X86/nolbr.s | 6 +-----
2 files changed, 5 insertions(+), 7 deletions(-)
diff --git a/bolt/lib/Profile/DataReader.cpp b/bolt/lib/Profile/DataReader.cpp
index c6377d46252a1..48bca308665a2 100644
--- a/bolt/lib/Profile/DataReader.cpp
+++ b/bolt/lib/Profile/DataReader.cpp
@@ -275,10 +275,12 @@ Error DataReader::preprocessProfile(BinaryContext &BC) {
FuncData->setEntryCounts(Function);
FuncData->Used = true;
}
- if (NoLBRMode)
+ if (NoLBRMode) {
if (FuncBasicSampleData *SampleData =
- getFuncBasicSampleData(Function.getNames()))
+ 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 6cdeb47f3441c..21c7a9bc45396 100644
--- a/bolt/test/X86/nolbr.s
+++ b/bolt/test/X86/nolbr.s
@@ -12,8 +12,6 @@
# 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
@@ -24,13 +22,11 @@
# CHECK-FDATA-NEXT: 1 _start [[#]] 1
# CHECK-BOLT: BOLT-INFO: pre-processing profile using branch profile reader
+# CHECK-BOLT-NOT: BOLT-INFO: skipping processing _start per user request
# CHECK-BOLT: BOLT-INFO: operating with basic samples profiling data (no brstack).
# 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