14
14
#include " bolt/Core/BinaryFunction.h"
15
15
#include " bolt/Core/ParallelUtilities.h"
16
16
#include " llvm/Support/CommandLine.h"
17
+ #include " llvm/Support/FormatVariadic.h"
17
18
18
19
#include < vector>
19
20
22
23
using namespace llvm ;
23
24
using namespace bolt ;
24
25
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
+
25
45
namespace opts {
26
46
27
47
extern cl::OptionCategory BoltOptCategory;
@@ -42,21 +62,10 @@ static cl::opt<unsigned> SplitAlignThreshold(
42
62
43
63
cl::Hidden, cl::cat(BoltOptCategory));
44
64
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));
60
69
61
70
static cl::opt<unsigned > SplitThreshold (
62
71
" split-threshold" ,
@@ -66,11 +75,6 @@ static cl::opt<unsigned> SplitThreshold(
66
75
" increase after splitting." ),
67
76
cl::init(0 ), cl::Hidden, cl::cat(BoltOptCategory));
68
77
69
- void syncOptions (BinaryContext &BC) {
70
- if (!BC.HasRelocations && opts::SplitFunctions == SplitFunctions::ST_LARGE)
71
- opts::SplitFunctions = SplitFunctions::ST_ALL;
72
- }
73
-
74
78
} // namespace opts
75
79
76
80
namespace llvm {
@@ -85,9 +89,7 @@ bool SplitFunctions::shouldOptimize(const BinaryFunction &BF) const {
85
89
}
86
90
87
91
void SplitFunctions::runOnFunctions (BinaryContext &BC) {
88
- opts::syncOptions (BC);
89
-
90
- if (opts::SplitFunctions == SplitFunctions::ST_NONE)
92
+ if (!opts::SplitFunctions)
91
93
return ;
92
94
93
95
ParallelUtilities::WorkFuncTy WorkFun = [&](BinaryFunction &BF) {
@@ -140,12 +142,6 @@ void SplitFunctions::splitFunction(BinaryFunction &BF) {
140
142
<< " pre-split is <0x"
141
143
<< Twine::utohexstr (OriginalHotSize) << " , 0x"
142
144
<< 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
- }
149
145
}
150
146
151
147
// Never outline the first basic block.
0 commit comments