@@ -105,29 +105,19 @@ MinBranchClusters("min-branch-clusters",
105105 cl::Hidden,
106106 cl::cat(BoltOptCategory));
107107
108- enum PeepholeOpts : char {
109- PEEP_NONE = 0x0 ,
110- PEEP_DOUBLE_JUMPS = 0x2 ,
111- PEEP_TAILCALL_TRAPS = 0x4 ,
112- PEEP_USELESS_BRANCHES = 0x8 ,
113- PEEP_ALL = 0xf
114- };
115-
116- static cl::list<PeepholeOpts>
117- Peepholes (" peepholes" ,
118- cl::CommaSeparated,
119- cl::desc (" enable peephole optimizations" ),
120- cl::value_desc(" opt1,opt2,opt3,..." ),
121- cl::values(
122- clEnumValN (PEEP_NONE, " none" , " disable peepholes" ),
123- clEnumValN(PEEP_DOUBLE_JUMPS, " double-jumps" ,
124- " remove double jumps when able" ),
125- clEnumValN(PEEP_TAILCALL_TRAPS, " tailcall-traps" , " insert tail call traps" ),
126- clEnumValN(PEEP_USELESS_BRANCHES, " useless-branches" ,
127- " remove useless conditional branches" ),
128- clEnumValN(PEEP_ALL, " all" , " enable all peephole optimizations" )),
129- cl::ZeroOrMore,
130- cl::cat(BoltOptCategory));
108+ static cl::list<Peepholes::PeepholeOpts> Peepholes (
109+ " peepholes" , cl::CommaSeparated, cl::desc(" enable peephole optimizations" ),
110+ cl::value_desc(" opt1,opt2,opt3,..." ),
111+ cl::values(clEnumValN(Peepholes::PEEP_NONE, " none" , " disable peepholes" ),
112+ clEnumValN(Peepholes::PEEP_DOUBLE_JUMPS, " double-jumps" ,
113+ " remove double jumps when able" ),
114+ clEnumValN(Peepholes::PEEP_TAILCALL_TRAPS, " tailcall-traps" ,
115+ " insert tail call traps" ),
116+ clEnumValN(Peepholes::PEEP_USELESS_BRANCHES, " useless-branches" ,
117+ " remove useless conditional branches" ),
118+ clEnumValN(Peepholes::PEEP_ALL, " all" ,
119+ " enable all peephole optimizations" )),
120+ cl::ZeroOrMore, cl::cat(BoltOptCategory));
131121
132122static cl::opt<unsigned >
133123PrintFuncStat (" print-function-statistics" ,
@@ -1092,20 +1082,20 @@ void Peepholes::removeUselessCondBranches(BinaryFunction &Function) {
10921082}
10931083
10941084void Peepholes::runOnFunctions (BinaryContext &BC) {
1095- const char Opts = std::accumulate (
1096- opts::Peepholes.begin (), opts::Peepholes.end (), 0 ,
1097- [](const char A, const opts:: PeepholeOpts B) { return A | B; });
1098- if (Opts == opts:: PEEP_NONE || !BC. isX86 () )
1085+ const char Opts =
1086+ std::accumulate ( opts::Peepholes.begin (), opts::Peepholes.end (), 0 ,
1087+ [](const char A, const PeepholeOpts B) { return A | B; });
1088+ if (Opts == PEEP_NONE)
10991089 return ;
11001090
11011091 for (auto &It : BC.getBinaryFunctions ()) {
11021092 BinaryFunction &Function = It.second ;
11031093 if (shouldOptimize (Function)) {
1104- if (Opts & opts:: PEEP_DOUBLE_JUMPS)
1094+ if (Opts & PEEP_DOUBLE_JUMPS)
11051095 NumDoubleJumps += fixDoubleJumps (Function, false );
1106- if (Opts & opts:: PEEP_TAILCALL_TRAPS)
1096+ if (Opts & PEEP_TAILCALL_TRAPS)
11071097 addTailcallTraps (Function);
1108- if (Opts & opts:: PEEP_USELESS_BRANCHES)
1098+ if (Opts & PEEP_USELESS_BRANCHES)
11091099 removeUselessCondBranches (Function);
11101100 assert (Function.validateCFG ());
11111101 }
0 commit comments