Skip to content

Commit ae6cb98

Browse files
[BOLT] Add --ba flag to deprecate --nl (#164257)
The `--nl` flag, originally for Non-LBR mode, is deprecated and will be replaced by `--basic-events` (alias `--ba`). `--nl` remains as a deprecated alias for backward compatibility.
1 parent 7f66c31 commit ae6cb98

File tree

8 files changed

+30
-17
lines changed

8 files changed

+30
-17
lines changed

bolt/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ $ perf2bolt -p perf.data -o perf.fdata <executable>
164164
This command will aggregate branch data from `perf.data` and store it in a
165165
format that is both more compact and more resilient to binary modifications.
166166

167-
If the profile was collected without brstacks, you will need to add `-nl` flag to
167+
If the profile was collected without brstacks, you will need to add `-ba` flag to
168168
the command line above.
169169

170170
### Step 3: Optimize with BOLT

bolt/docs/Heatmaps.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ $ perf record -e cycles:u -j any,u [-p PID|-a] -- sleep <interval>
2121
```
2222

2323
Running with brstack (`-j any,u` or `-b`) is recommended. Heatmaps can be generated
24-
from basic events by using the llvm-bolt-heatmap option `-nl` (no brstack) but
24+
from basic events by using the llvm-bolt-heatmap option `-ba` (basic events) but
2525
such heatmaps do not have the coverage provided by brstack and may only be useful
2626
for finding event hotspots at larger code block granularities.
2727

bolt/docs/index.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,8 @@ This command will aggregate branch data from ``perf.data`` and store it
205205
in a format that is both more compact and more resilient to binary
206206
modifications.
207207

208-
If the profile was collected without LBRs, you will need to add ``-nl``
209-
flag to the command line above.
208+
If the profile was collected without brstacks, you will need to add `-ba` flag to
209+
the command line above.
210210

211211
Step 3: Optimize with BOLT
212212
~~~~~~~~~~~~~~~~~~~~~~~~~~

bolt/lib/Profile/DataAggregator.cpp

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,23 @@ using namespace bolt;
4545
namespace opts {
4646

4747
static cl::opt<bool>
48-
BasicAggregation("nl",
49-
cl::desc("aggregate basic samples (without brstack info)"),
48+
BasicAggregation("basic-events",
49+
cl::desc("aggregate basic events (without brstack info)"),
5050
cl::cat(AggregatorCategory));
5151

52+
static cl::alias BasicAggregationAlias("ba",
53+
cl::desc("Alias for --basic-events"),
54+
cl::aliasopt(BasicAggregation));
55+
56+
static cl::opt<bool> DeprecatedBasicAggregationNl(
57+
"nl", cl::desc("Alias for --basic-events (deprecated. Use --ba)"),
58+
cl::cat(AggregatorCategory), cl::ReallyHidden,
59+
cl::callback([](const bool &Enabled) {
60+
errs()
61+
<< "BOLT-WARNING: '-nl' is deprecated, please use '--ba' instead.\n";
62+
BasicAggregation = Enabled;
63+
}));
64+
5265
cl::opt<bool> ArmSPE("spe", cl::desc("Enable Arm SPE mode."),
5366
cl::cat(AggregatorCategory));
5467

@@ -1433,7 +1446,7 @@ std::error_code DataAggregator::printLBRHeatMap() {
14331446
"Cannot build heatmap.";
14341447
} else {
14351448
errs() << "HEATMAP-ERROR: no brstack traces detected in profile. "
1436-
"Cannot build heatmap. Use -nl for building heatmap from "
1449+
"Cannot build heatmap. Use -ba for building heatmap from "
14371450
"basic events.\n";
14381451
}
14391452
exit(1);
@@ -1629,8 +1642,8 @@ std::error_code DataAggregator::parseBranchEvents() {
16291642
<< "PERF2BOLT-WARNING: all recorded samples for this binary lack "
16301643
"brstack. Record profile with perf record -j any or run "
16311644
"perf2bolt "
1632-
"in non-brstack mode with -nl (the performance improvement in "
1633-
"-nl "
1645+
"in non-brstack mode with -ba (the performance improvement in "
1646+
"-ba "
16341647
"mode may be limited)\n";
16351648
else
16361649
errs()

bolt/test/X86/nolbr.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
# RUN: FileCheck %s --input-file %t.fdata --check-prefix=CHECK-FDATA
1111
# RUN: llvm-strip --strip-unneeded %t.o
1212
# RUN: %clang %cflags %t.o -o %t.exe -Wl,-q -nostdlib
13-
# RUN: llvm-bolt %t.exe -o %t.out --data %t.fdata --dyno-stats -nl \
13+
# RUN: llvm-bolt %t.exe -o %t.out --data %t.fdata --dyno-stats -ba \
1414
# RUN: --print-only=_start 2>&1 | FileCheck %s --check-prefix=CHECK-BOLT
1515

1616
# CHECK-FDATA: no_lbr

bolt/test/X86/pre-aggregated-perf.test

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,11 @@ RUN: FileCheck %s -check-prefix=NEWFORMAT --input-file %t.bolt.yaml
6161
RUN: perf2bolt %t.exe -o %t --pa -p %p/Inputs/pre-aggregated-basic.txt -o %t.ba \
6262
RUN: 2>&1 | FileCheck %s --check-prefix=BASIC-ERROR
6363
RUN: perf2bolt %t.exe -o %t --pa -p %p/Inputs/pre-aggregated-basic.txt -o %t.ba.nl \
64-
RUN: -nl 2>&1 | FileCheck %s --check-prefix=BASIC-SUCCESS
65-
RUN: FileCheck %s --input-file %t.ba.nl --check-prefix CHECK-BASIC-NL
64+
RUN: -ba 2>&1 | FileCheck %s --check-prefix=BASIC-SUCCESS
65+
RUN: FileCheck %s --input-file %t.ba.nl --check-prefix CHECK-BASIC-BA
6666
BASIC-ERROR: BOLT-INFO: 0 out of 7 functions in the binary (0.0%) have non-empty execution profile
6767
BASIC-SUCCESS: BOLT-INFO: 4 out of 7 functions in the binary (57.1%) have non-empty execution profile
68-
CHECK-BASIC-NL: no_lbr cycles
68+
CHECK-BASIC-BA: no_lbr cycles
6969

7070
PERF2BOLT: 1 frame_dummy/1 1e 1 frame_dummy/1 0 0 1
7171
PERF2BOLT-NEXT: 1 main 451 1 SolveCubic 0 0 2

bolt/test/perf2bolt/perf_test.test

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ REQUIRES: system-linux, perf
44

55
RUN: %clang %S/Inputs/perf_test.c -fuse-ld=lld -pie -Wl,--script=%S/Inputs/perf_test.lds -o %t
66
RUN: perf record -Fmax -e cycles:u -o %t2 -- %t
7-
RUN: perf2bolt %t -p=%t2 -o %t3 -nl -ignore-build-id --show-density \
7+
RUN: perf2bolt %t -p=%t2 -o %t3 -ba -ignore-build-id --show-density \
88
RUN: --heatmap %t.hm 2>&1 | FileCheck %s
99
RUN: FileCheck %s --input-file %t.hm-section-hotness.csv --check-prefix=CHECK-HM
1010

@@ -15,7 +15,7 @@ CHECK: BOLT-INFO: Functions with density >= {{.*}} account for 99.00% total samp
1515

1616
RUN: %clang %S/Inputs/perf_test.c -no-pie -fuse-ld=lld -o %t4
1717
RUN: perf record -Fmax -e cycles:u -o %t5 -- %t4
18-
RUN: perf2bolt %t4 -p=%t5 -o %t6 -nl -ignore-build-id --show-density \
18+
RUN: perf2bolt %t4 -p=%t5 -o %t6 -ba -ignore-build-id --show-density \
1919
RUN: --heatmap %t.hm2 2>&1 | FileCheck %s
2020
RUN: FileCheck %s --input-file %t.hm2-section-hotness.csv --check-prefix=CHECK-HM
2121

clang/utils/perf-training/perf-helper.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ def perf2bolt(args):
133133
"--profile-format=yaml",
134134
]
135135
if not opts.lbr:
136-
p2b_args += ["-nl"]
136+
p2b_args += ["-ba"]
137137
p2b_args += ["-p"]
138138
for filename in findFilesWithExtension(opts.path, "perf.data"):
139139
subprocess.check_call(p2b_args + [filename, "-o", filename + ".fdata"])
@@ -722,7 +722,7 @@ def bolt_optimize(args):
722722
"-dyno-stats",
723723
"-use-gnu-stack",
724724
"-update-debug-sections",
725-
"-nl" if opts.method == "PERF" else "",
725+
"-ba" if opts.method == "PERF" else "",
726726
]
727727
print("Running: " + " ".join(args))
728728
process = subprocess.run(

0 commit comments

Comments
 (0)