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
2223using namespace llvm ;
2324using 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+
2545namespace opts {
2646
2747extern 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
6170static 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
7680namespace llvm {
@@ -85,9 +89,7 @@ bool SplitFunctions::shouldOptimize(const BinaryFunction &BF) const {
8589}
8690
8791void 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.
0 commit comments