Skip to content

Commit 96f6ec5

Browse files
Fabian Parzefallmaksfb
Fabian Parzefall
authored andcommitted
[BOLT] Mark option values of --split-functions deprecated
The SplitFunctions pass does not distinguish between various splitting modes anymore. This change updates the command line interface to reflect this behavior by deprecating values passed to the --split-function option. Reviewed By: rafauler Differential Revision: https://reviews.llvm.org/D128558
1 parent d72d488 commit 96f6ec5

11 files changed

+35
-49
lines changed

bolt/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ Once you have `perf.fdata` ready, you can use it for optimizations with
180180
BOLT. Assuming your environment is setup to include the right path, execute
181181
`llvm-bolt`:
182182
```
183-
$ llvm-bolt <executable> -o <executable>.bolt -data=perf.fdata -reorder-blocks=ext-tsp -reorder-functions=hfsort -split-functions=2 -split-all-cold -split-eh -dyno-stats
183+
$ llvm-bolt <executable> -o <executable>.bolt -data=perf.fdata -reorder-blocks=ext-tsp -reorder-functions=hfsort -split-functions -split-all-cold -split-eh -dyno-stats
184184
```
185185

186186
If you do need an updated debug info, then add `-update-debug-sections` option

bolt/docs/OptimizingClang.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ Notice that we are passing `clang-7` to `perf2bolt` which is the real binary tha
6464
the generated profile:
6565
```bash
6666
$ llvm-bolt $CPATH/clang-7 -o $CPATH/clang-7.bolt -b clang-7.yaml \
67-
-reorder-blocks=ext-tsp -reorder-functions=hfsort+ -split-functions=3 \
67+
-reorder-blocks=ext-tsp -reorder-functions=hfsort+ -split-functions \
6868
-split-all-cold -dyno-stats -icf=1 -use-gnu-stack
6969
```
7070
The output will look similar to the one below:

bolt/include/bolt/Passes/SplitFunctions.h

-9
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,6 @@ namespace bolt {
1818

1919
/// Split function code in multiple parts.
2020
class SplitFunctions : public BinaryFunctionPass {
21-
public:
22-
/// Settings for splitting function bodies into hot/cold partitions.
23-
enum SplittingType : char {
24-
ST_NONE = 0, /// Do not split functions.
25-
ST_LARGE, /// In non-relocation mode, only split functions that
26-
/// are too large to fit into the original space.
27-
ST_ALL, /// Split all functions.
28-
};
29-
3021
private:
3122
/// Split function body into fragments.
3223
void splitFunction(BinaryFunction &Function);

bolt/lib/Passes/SplitFunctions.cpp

+25-29
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include "bolt/Core/BinaryFunction.h"
1515
#include "bolt/Core/ParallelUtilities.h"
1616
#include "llvm/Support/CommandLine.h"
17+
#include "llvm/Support/FormatVariadic.h"
1718

1819
#include <vector>
1920

@@ -22,6 +23,25 @@
2223
using namespace llvm;
2324
using namespace bolt;
2425

26+
namespace {
27+
class DeprecatedSplitFunctionOptionParser : public cl::parser<bool> {
28+
public:
29+
explicit DeprecatedSplitFunctionOptionParser(cl::Option &O)
30+
: cl::parser<bool>(O) {}
31+
32+
bool parse(cl::Option &O, StringRef ArgName, StringRef Arg, bool &Value) {
33+
if (Arg == "2" || Arg == "3") {
34+
Value = true;
35+
errs() << formatv("BOLT-WARNING: specifying non-boolean value \"{0}\" "
36+
"for option -{1} is deprecated\n",
37+
Arg, ArgName);
38+
return false;
39+
}
40+
return cl::parser<bool>::parse(O, ArgName, Arg, Value);
41+
}
42+
};
43+
} // namespace
44+
2545
namespace opts {
2646

2747
extern cl::OptionCategory BoltOptCategory;
@@ -42,21 +62,10 @@ static cl::opt<unsigned> SplitAlignThreshold(
4262

4363
cl::Hidden, cl::cat(BoltOptCategory));
4464

45-
static cl::opt<SplitFunctions::SplittingType>
46-
SplitFunctions("split-functions",
47-
cl::desc("split functions into hot and cold regions"),
48-
cl::init(SplitFunctions::ST_NONE),
49-
cl::values(clEnumValN(SplitFunctions::ST_NONE, "0",
50-
"do not split any function"),
51-
clEnumValN(SplitFunctions::ST_LARGE, "1",
52-
"in non-relocation mode only split functions too large "
53-
"to fit into original code space"),
54-
clEnumValN(SplitFunctions::ST_LARGE, "2",
55-
"same as 1 (backwards compatibility)"),
56-
clEnumValN(SplitFunctions::ST_ALL, "3",
57-
"split all functions")),
58-
cl::ZeroOrMore,
59-
cl::cat(BoltOptCategory));
65+
static cl::opt<bool, false, DeprecatedSplitFunctionOptionParser>
66+
SplitFunctions("split-functions",
67+
cl::desc("split functions into hot and cold regions"),
68+
cl::cat(BoltOptCategory));
6069

6170
static cl::opt<unsigned> SplitThreshold(
6271
"split-threshold",
@@ -66,11 +75,6 @@ static cl::opt<unsigned> SplitThreshold(
6675
"increase after splitting."),
6776
cl::init(0), cl::Hidden, cl::cat(BoltOptCategory));
6877

69-
void syncOptions(BinaryContext &BC) {
70-
if (!BC.HasRelocations && opts::SplitFunctions == SplitFunctions::ST_LARGE)
71-
opts::SplitFunctions = SplitFunctions::ST_ALL;
72-
}
73-
7478
} // namespace opts
7579

7680
namespace llvm {
@@ -85,9 +89,7 @@ bool SplitFunctions::shouldOptimize(const BinaryFunction &BF) const {
8589
}
8690

8791
void SplitFunctions::runOnFunctions(BinaryContext &BC) {
88-
opts::syncOptions(BC);
89-
90-
if (opts::SplitFunctions == SplitFunctions::ST_NONE)
92+
if (!opts::SplitFunctions)
9193
return;
9294

9395
ParallelUtilities::WorkFuncTy WorkFun = [&](BinaryFunction &BF) {
@@ -140,12 +142,6 @@ void SplitFunctions::splitFunction(BinaryFunction &BF) {
140142
<< " pre-split is <0x"
141143
<< Twine::utohexstr(OriginalHotSize) << ", 0x"
142144
<< Twine::utohexstr(ColdSize) << ">\n");
143-
if (opts::SplitFunctions == SplitFunctions::ST_LARGE &&
144-
!BC.HasRelocations) {
145-
// Split only if the function wouldn't fit.
146-
if (OriginalHotSize <= BF.getMaxSize())
147-
return;
148-
}
149145
}
150146

151147
// Never outline the first basic block.

bolt/test/X86/bug-reorder-bb-jrcxz.s

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
# RUN: llvm-bolt %t.exe -o %t.bolted --data %t.fdata \
1818
# RUN: --reorder-blocks=ext-tsp --reorder-functions=hfsort \
19-
# RUN: --split-functions=2 --split-all-cold --split-eh --dyno-stats \
19+
# RUN: --split-functions --split-all-cold --split-eh --dyno-stats \
2020
# RUN: --print-finalized 2>&1 | FileCheck %s
2121

2222
# CHECK-NOT: value of -2105 is too large for field of 1 byte.

bolt/test/X86/jump-table-icp.test

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ RUN: llvm-strip --strip-unneeded %t.o
55
RUN: %clang %cflags -no-pie %t.o -o %t.exe -Wl,-q
66

77
RUN: (llvm-bolt %t.exe --data %t.fdata -o %t --relocs \
8-
RUN: --reorder-blocks=cache --split-functions=3 --split-all-cold \
8+
RUN: --reorder-blocks=cache --split-functions --split-all-cold \
99
RUN: --use-gnu-stack --dyno-stats --indirect-call-promotion=jump-tables \
1010
RUN: --print-icp -v=0 \
1111
RUN: --icp-jt-remaining-percent-threshold=10 \

bolt/test/X86/shared_object_entry.s

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown %s -o %t.o
22
# RUN: ld.lld %t.o -o %t.so --shared --entry=func1.cold.1 --emit-relocs
33
# RUN: llvm-bolt -relocs %t.so -o %t -reorder-functions=hfsort+ \
4-
# RUN: -split-functions=3 -reorder-blocks=ext-tsp -split-all-cold \
4+
# RUN: -split-functions -reorder-blocks=ext-tsp -split-all-cold \
55
# RUN: -dyno-stats -icf=1 -use-gnu-stack
66

77
# Check that an entry point is a cold symbol

bolt/test/X86/unreachable.test

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown \
55
RUN: %p/Inputs/unreachable.s -o %t.o
66
RUN: %clangxx %cxxflags -no-pie %t.o -o %t.exe %t.so
77
RUN: llvm-bolt %t.exe -o %t \
8-
RUN: -reorder-blocks=none -split-functions=1 -eliminate-unreachable \
8+
RUN: -reorder-blocks=none -split-functions -eliminate-unreachable \
99
RUN: -funcs=foo -use-gnu-stack -print-cfg -print-finalized \
1010
RUN: | FileCheck %s --check-prefix=BOLT
1111
RUN: llvm-objdump -d %t --print-imm-hex --disassemble-symbols=foo \

bolt/test/runtime/X86/exceptions-instrumentation.test

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ RUN: %t.exc arg1 arg2 arg3
99

1010
RUN: llvm-bolt %t_exc_split -o %t.exc.bolted --data %t.fdata \
1111
RUN: --reorder-blocks=ext-tsp --reorder-functions=hfsort+ \
12-
RUN: --split-functions=3 --split-eh=1 \
12+
RUN: --split-functions --split-eh=1 \
1313
RUN: | FileCheck --check-prefix=EXCEPTIONS %s
1414
EXCEPTIONS-NOT: invalid (possibly stale) profile
1515

bolt/test/runtime/X86/pie-exceptions-split.test

+1-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ RUN: llvm-bolt %t -o %t.instr --instrument --instrumentation-file=%t.fdata
1010
RUN: %t.instr
1111

1212
RUN: llvm-bolt %t -o %t.bolt --data %t.fdata --reorder-blocks=ext-tsp \
13-
RUN: --split-functions=1 --split-eh --print-after-lowering \
13+
RUN: --split-functions --split-eh --print-after-lowering \
1414
RUN: --print-only=main 2>&1 | FileCheck %s
1515

1616
## All calls to printf() should be from exception handling code that was
@@ -26,4 +26,3 @@ RUN: %t.bolt arg1 arg2 arg3 2>&1 | FileCheck --check-prefix=CHECK-BOLTED %s
2626

2727
CHECK-BOLTED: catch 2
2828
CHECK-BOLTED-NEXT: catch 1
29-

bolt/test/runtime/meta-merge-fdata.test

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ CHECK-FDATA: 0 [unknown] 0 1 _start 0 0 1
2222
# Check that BOLT works with this profile
2323
RUN: llvm-bolt merge-fdata -o %t.bolt --data %t.fdata1 \
2424
RUN: --reorder-blocks=ext-tsp --reorder-functions=hfsort+ \
25-
RUN: --split-functions=3 \
25+
RUN: --split-functions \
2626
RUN: | FileCheck %s --check-prefix=CHECK-BOLT1
2727
CHECK-BOLT1-NOT: invalid (possibly stale) profile
2828

@@ -44,7 +44,7 @@ RUN: cmp %t.fdata.base %t.fdata.inst
4444
# Optimize using merged fdata
4545
RUN: llvm-bolt merge-fdata -o %t.opt --data %t.fdata.base \
4646
RUN: --reorder-blocks=ext-tsp --reorder-functions=hfsort+ \
47-
RUN: --split-functions=3 \
47+
RUN: --split-functions \
4848
RUN: | FileCheck %s --check-prefix=CHECK-BOLT2
4949
CHECK-BOLT2-NOT: invalid (possibly stale) profile
5050

0 commit comments

Comments
 (0)