Skip to content

Commit c6ca7ea

Browse files
committed
[BOLT] Fix unrecognized option values for print-sorted-by-order
1 parent 6414ae6 commit c6ca7ea

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

bolt/lib/Passes/BinaryPasses.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,12 @@ static cl::opt<DynoStatsSortOrder> DynoStatsSortOrderOpt(
6060
"print-sorted-by-order",
6161
cl::desc("use ascending or descending order when printing functions "
6262
"ordered by dyno stats"),
63-
cl::init(DynoStatsSortOrder::Descending), cl::cat(BoltOptCategory));
63+
cl::init(DynoStatsSortOrder::Descending),
64+
cl::values(clEnumValN(DynoStatsSortOrder::Ascending, "ascending",
65+
"Ascending order"),
66+
clEnumValN(DynoStatsSortOrder::Descending, "descending",
67+
"Descending order")),
68+
cl::cat(BoltOptCategory));
6469

6570
cl::list<std::string>
6671
HotTextMoveSections("hot-text-move-sections",
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Check that --print-sorted-by-order=<ascending/descending> option works properly in llvm-bolt
2+
#
3+
# RUN: llvm-mc -filetype=obj -triple aarch64-unknown-unknown %s -o %t.o
4+
# RUN: %clang %cflags -fPIC -pie %t.o -o %t.exe -nostdlib -Wl,-q
5+
# RUN: link_fdata %s %t.o %t.fdata
6+
# RUN: llvm-bolt %t.exe -o %t.bolt --print-sorted-by=all --print-sorted-by-order=ascending \
7+
# RUN: --data %t.fdata | FileCheck %s -check-prefix=CHECK-ASCEND
8+
# RUN: llvm-bolt %t.exe -o %t.bolt --print-sorted-by=all --print-sorted-by-order=descending \
9+
# RUN: --data %t.fdata | FileCheck %s -check-prefix=CHECK-DESCEND
10+
11+
# CHECK-ASCEND: BOLT-INFO: top functions sorted by dyno stats are:
12+
# CHECK-ASCEND-NEXT: bar
13+
# CHECK-ASCEND-NEXT: foo
14+
# CHECK-DESCEND: BOLT-INFO: top functions sorted by dyno stats are:
15+
# CHECK-DESCEND-NEXT: foo
16+
# CHECK-DESCEND-NEXT: bar
17+
18+
.text
19+
.align 4
20+
.global bar
21+
.type bar, %function
22+
bar:
23+
mov w0, wzr
24+
ret
25+
26+
.global foo
27+
.type foo, %function
28+
foo:
29+
# FDATA: 1 foo 0 1 bar 0 0 1
30+
bl bar
31+
ret

0 commit comments

Comments
 (0)