Rafael Espindola | c684e83 | 2011-08-02 21:50:27 +0000 | [diff] [blame] | 1 | //===- PassManagerBuilder.cpp - Build Standard Pass -----------------------===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This file defines the PassManagerBuilder class, which is used to set up a |
| 11 | // "standard" optimization sequence suitable for languages like C and C++. |
| 12 | // |
| 13 | //===----------------------------------------------------------------------===// |
| 14 | |
| 15 | |
| 16 | #include "llvm/Transforms/IPO/PassManagerBuilder.h" |
| 17 | |
Rafael Espindola | 69cb216 | 2011-08-09 22:17:34 +0000 | [diff] [blame] | 18 | #include "llvm-c/Transforms/PassManagerBuilder.h" |
| 19 | |
Rafael Espindola | c684e83 | 2011-08-02 21:50:27 +0000 | [diff] [blame] | 20 | #include "llvm/PassManager.h" |
| 21 | #include "llvm/DefaultPasses.h" |
| 22 | #include "llvm/PassManager.h" |
| 23 | #include "llvm/Analysis/Passes.h" |
Hal Finkel | de5e5ec | 2012-02-01 03:51:43 +0000 | [diff] [blame] | 24 | #include "llvm/Analysis/Verifier.h" |
| 25 | #include "llvm/Support/CommandLine.h" |
Rafael Espindola | c684e83 | 2011-08-02 21:50:27 +0000 | [diff] [blame] | 26 | #include "llvm/Target/TargetLibraryInfo.h" |
| 27 | #include "llvm/Transforms/Scalar.h" |
Hal Finkel | de5e5ec | 2012-02-01 03:51:43 +0000 | [diff] [blame] | 28 | #include "llvm/Transforms/Vectorize.h" |
Rafael Espindola | c684e83 | 2011-08-02 21:50:27 +0000 | [diff] [blame] | 29 | #include "llvm/Transforms/IPO.h" |
David Chisnall | 7a817ea | 2011-08-16 13:58:41 +0000 | [diff] [blame] | 30 | #include "llvm/ADT/SmallVector.h" |
| 31 | #include "llvm/Support/ManagedStatic.h" |
Rafael Espindola | c684e83 | 2011-08-02 21:50:27 +0000 | [diff] [blame] | 32 | |
| 33 | using namespace llvm; |
| 34 | |
Hal Finkel | de5e5ec | 2012-02-01 03:51:43 +0000 | [diff] [blame] | 35 | static cl::opt<bool> |
Nadav Rotem | 9210cc3 | 2012-10-30 18:37:43 +0000 | [diff] [blame] | 36 | RunLoopVectorization("vectorize-loops", |
| 37 | cl::desc("Run the Loop vectorization passes")); |
Nadav Rotem | d233b78 | 2012-10-29 16:36:25 +0000 | [diff] [blame] | 38 | |
| 39 | static cl::opt<bool> |
| 40 | RunBBVectorization("vectorize", cl::desc("Run the BB vectorization passes")); |
Hal Finkel | de5e5ec | 2012-02-01 03:51:43 +0000 | [diff] [blame] | 41 | |
Hal Finkel | 064551e | 2012-04-13 17:15:33 +0000 | [diff] [blame] | 42 | static cl::opt<bool> |
| 43 | UseGVNAfterVectorization("use-gvn-after-vectorization", |
| 44 | cl::init(false), cl::Hidden, |
| 45 | cl::desc("Run GVN instead of Early CSE after vectorization passes")); |
| 46 | |
Chandler Carruth | 713aa94 | 2012-09-14 09:22:59 +0000 | [diff] [blame] | 47 | static cl::opt<bool> UseNewSROA("use-new-sroa", |
Chandler Carruth | 1fe4fae | 2012-10-02 04:24:01 +0000 | [diff] [blame] | 48 | cl::init(true), cl::Hidden, |
Chandler Carruth | 713aa94 | 2012-09-14 09:22:59 +0000 | [diff] [blame] | 49 | cl::desc("Enable the new, experimental SROA pass")); |
| 50 | |
Rafael Espindola | c684e83 | 2011-08-02 21:50:27 +0000 | [diff] [blame] | 51 | PassManagerBuilder::PassManagerBuilder() { |
| 52 | OptLevel = 2; |
| 53 | SizeLevel = 0; |
| 54 | LibraryInfo = 0; |
| 55 | Inliner = 0; |
| 56 | DisableSimplifyLibCalls = false; |
| 57 | DisableUnitAtATime = false; |
| 58 | DisableUnrollLoops = false; |
Nadav Rotem | 2459bf2 | 2012-10-29 18:01:14 +0000 | [diff] [blame] | 59 | Vectorize = RunBBVectorization; |
Nadav Rotem | d233b78 | 2012-10-29 16:36:25 +0000 | [diff] [blame] | 60 | LoopVectorize = RunLoopVectorization; |
Rafael Espindola | c684e83 | 2011-08-02 21:50:27 +0000 | [diff] [blame] | 61 | } |
| 62 | |
| 63 | PassManagerBuilder::~PassManagerBuilder() { |
| 64 | delete LibraryInfo; |
| 65 | delete Inliner; |
| 66 | } |
| 67 | |
David Chisnall | 7a817ea | 2011-08-16 13:58:41 +0000 | [diff] [blame] | 68 | /// Set of global extensions, automatically added as part of the standard set. |
| 69 | static ManagedStatic<SmallVector<std::pair<PassManagerBuilder::ExtensionPointTy, |
| 70 | PassManagerBuilder::ExtensionFn>, 8> > GlobalExtensions; |
| 71 | |
| 72 | void PassManagerBuilder::addGlobalExtension( |
| 73 | PassManagerBuilder::ExtensionPointTy Ty, |
| 74 | PassManagerBuilder::ExtensionFn Fn) { |
| 75 | GlobalExtensions->push_back(std::make_pair(Ty, Fn)); |
| 76 | } |
| 77 | |
Rafael Espindola | c684e83 | 2011-08-02 21:50:27 +0000 | [diff] [blame] | 78 | void PassManagerBuilder::addExtension(ExtensionPointTy Ty, ExtensionFn Fn) { |
| 79 | Extensions.push_back(std::make_pair(Ty, Fn)); |
| 80 | } |
| 81 | |
| 82 | void PassManagerBuilder::addExtensionsToPM(ExtensionPointTy ETy, |
| 83 | PassManagerBase &PM) const { |
David Chisnall | 7a817ea | 2011-08-16 13:58:41 +0000 | [diff] [blame] | 84 | for (unsigned i = 0, e = GlobalExtensions->size(); i != e; ++i) |
| 85 | if ((*GlobalExtensions)[i].first == ETy) |
| 86 | (*GlobalExtensions)[i].second(*this, PM); |
Rafael Espindola | c684e83 | 2011-08-02 21:50:27 +0000 | [diff] [blame] | 87 | for (unsigned i = 0, e = Extensions.size(); i != e; ++i) |
| 88 | if (Extensions[i].first == ETy) |
| 89 | Extensions[i].second(*this, PM); |
| 90 | } |
| 91 | |
| 92 | void |
| 93 | PassManagerBuilder::addInitialAliasAnalysisPasses(PassManagerBase &PM) const { |
| 94 | // Add TypeBasedAliasAnalysis before BasicAliasAnalysis so that |
| 95 | // BasicAliasAnalysis wins if they disagree. This is intended to help |
| 96 | // support "obvious" type-punning idioms. |
| 97 | PM.add(createTypeBasedAliasAnalysisPass()); |
| 98 | PM.add(createBasicAliasAnalysisPass()); |
| 99 | } |
| 100 | |
| 101 | void PassManagerBuilder::populateFunctionPassManager(FunctionPassManager &FPM) { |
| 102 | addExtensionsToPM(EP_EarlyAsPossible, FPM); |
| 103 | |
| 104 | // Add LibraryInfo if we have some. |
| 105 | if (LibraryInfo) FPM.add(new TargetLibraryInfo(*LibraryInfo)); |
| 106 | |
| 107 | if (OptLevel == 0) return; |
| 108 | |
| 109 | addInitialAliasAnalysisPasses(FPM); |
| 110 | |
| 111 | FPM.add(createCFGSimplificationPass()); |
Chandler Carruth | 713aa94 | 2012-09-14 09:22:59 +0000 | [diff] [blame] | 112 | if (UseNewSROA) |
| 113 | FPM.add(createSROAPass()); |
| 114 | else |
| 115 | FPM.add(createScalarReplAggregatesPass()); |
Rafael Espindola | c684e83 | 2011-08-02 21:50:27 +0000 | [diff] [blame] | 116 | FPM.add(createEarlyCSEPass()); |
| 117 | FPM.add(createLowerExpectIntrinsicPass()); |
| 118 | } |
| 119 | |
| 120 | void PassManagerBuilder::populateModulePassManager(PassManagerBase &MPM) { |
| 121 | // If all optimizations are disabled, just run the always-inline pass. |
| 122 | if (OptLevel == 0) { |
| 123 | if (Inliner) { |
| 124 | MPM.add(Inliner); |
| 125 | Inliner = 0; |
| 126 | } |
Chandler Carruth | 63a1eb6 | 2012-10-18 08:05:46 +0000 | [diff] [blame] | 127 | |
| 128 | // FIXME: This is a HACK! The inliner pass above implicitly creates a CGSCC |
| 129 | // pass manager, but we don't want to add extensions into that pass manager. |
| 130 | // To prevent this we must insert a no-op module pass to reset the pass |
| 131 | // manager to get the same behavior as EP_OptimizerLast in non-O0 builds. |
| 132 | if (!GlobalExtensions->empty() || !Extensions.empty()) |
| 133 | MPM.add(createBarrierNoopPass()); |
| 134 | |
Kostya Serebryany | af65a8c | 2011-11-30 22:19:26 +0000 | [diff] [blame] | 135 | addExtensionsToPM(EP_EnabledOnOptLevel0, MPM); |
Rafael Espindola | c684e83 | 2011-08-02 21:50:27 +0000 | [diff] [blame] | 136 | return; |
| 137 | } |
| 138 | |
| 139 | // Add LibraryInfo if we have some. |
| 140 | if (LibraryInfo) MPM.add(new TargetLibraryInfo(*LibraryInfo)); |
| 141 | |
| 142 | addInitialAliasAnalysisPasses(MPM); |
| 143 | |
| 144 | if (!DisableUnitAtATime) { |
Dan Gohman | 7d4c87e | 2012-01-17 20:51:32 +0000 | [diff] [blame] | 145 | addExtensionsToPM(EP_ModuleOptimizerEarly, MPM); |
| 146 | |
Rafael Espindola | c684e83 | 2011-08-02 21:50:27 +0000 | [diff] [blame] | 147 | MPM.add(createGlobalOptimizerPass()); // Optimize out global vars |
| 148 | |
| 149 | MPM.add(createIPSCCPPass()); // IP SCCP |
| 150 | MPM.add(createDeadArgEliminationPass()); // Dead argument elimination |
| 151 | |
| 152 | MPM.add(createInstructionCombiningPass());// Clean up after IPCP & DAE |
| 153 | MPM.add(createCFGSimplificationPass()); // Clean up after IPCP & DAE |
| 154 | } |
| 155 | |
| 156 | // Start of CallGraph SCC passes. |
| 157 | if (!DisableUnitAtATime) |
| 158 | MPM.add(createPruneEHPass()); // Remove dead EH info |
| 159 | if (Inliner) { |
| 160 | MPM.add(Inliner); |
| 161 | Inliner = 0; |
| 162 | } |
| 163 | if (!DisableUnitAtATime) |
| 164 | MPM.add(createFunctionAttrsPass()); // Set readonly/readnone attrs |
| 165 | if (OptLevel > 2) |
| 166 | MPM.add(createArgumentPromotionPass()); // Scalarize uninlined fn args |
| 167 | |
| 168 | // Start of function pass. |
| 169 | // Break up aggregate allocas, using SSAUpdater. |
Chandler Carruth | 1c8db50 | 2012-09-15 11:43:14 +0000 | [diff] [blame] | 170 | if (UseNewSROA) |
| 171 | MPM.add(createSROAPass(/*RequiresDomTree*/ false)); |
| 172 | else |
| 173 | MPM.add(createScalarReplAggregatesPass(-1, false)); |
Rafael Espindola | c684e83 | 2011-08-02 21:50:27 +0000 | [diff] [blame] | 174 | MPM.add(createEarlyCSEPass()); // Catch trivial redundancies |
| 175 | if (!DisableSimplifyLibCalls) |
| 176 | MPM.add(createSimplifyLibCallsPass()); // Library Call Optimizations |
| 177 | MPM.add(createJumpThreadingPass()); // Thread jumps. |
| 178 | MPM.add(createCorrelatedValuePropagationPass()); // Propagate conditionals |
| 179 | MPM.add(createCFGSimplificationPass()); // Merge & remove BBs |
| 180 | MPM.add(createInstructionCombiningPass()); // Combine silly seq's |
| 181 | |
| 182 | MPM.add(createTailCallEliminationPass()); // Eliminate tail calls |
| 183 | MPM.add(createCFGSimplificationPass()); // Merge & remove BBs |
| 184 | MPM.add(createReassociatePass()); // Reassociate expressions |
| 185 | MPM.add(createLoopRotatePass()); // Rotate Loop |
| 186 | MPM.add(createLICMPass()); // Hoist loop invariants |
| 187 | MPM.add(createLoopUnswitchPass(SizeLevel || OptLevel < 3)); |
| 188 | MPM.add(createInstructionCombiningPass()); |
| 189 | MPM.add(createIndVarSimplifyPass()); // Canonicalize indvars |
| 190 | MPM.add(createLoopIdiomPass()); // Recognize idioms like memset. |
| 191 | MPM.add(createLoopDeletionPass()); // Delete dead loops |
Nadav Rotem | d15c0c7 | 2012-10-17 18:25:06 +0000 | [diff] [blame] | 192 | |
Nadav Rotem | 3d1a975 | 2012-11-29 19:28:29 +0000 | [diff] [blame^] | 193 | if (LoopVectorize) |
Nadav Rotem | d15c0c7 | 2012-10-17 18:25:06 +0000 | [diff] [blame] | 194 | MPM.add(createLoopVectorizePass()); |
Nadav Rotem | d15c0c7 | 2012-10-17 18:25:06 +0000 | [diff] [blame] | 195 | |
Rafael Espindola | c684e83 | 2011-08-02 21:50:27 +0000 | [diff] [blame] | 196 | if (!DisableUnrollLoops) |
| 197 | MPM.add(createLoopUnrollPass()); // Unroll small loops |
| 198 | addExtensionsToPM(EP_LoopOptimizerEnd, MPM); |
| 199 | |
| 200 | if (OptLevel > 1) |
| 201 | MPM.add(createGVNPass()); // Remove redundancies |
| 202 | MPM.add(createMemCpyOptPass()); // Remove memcpy / form memset |
| 203 | MPM.add(createSCCPPass()); // Constant prop with SCCP |
| 204 | |
| 205 | // Run instcombine after redundancy elimination to exploit opportunities |
| 206 | // opened up by them. |
| 207 | MPM.add(createInstructionCombiningPass()); |
| 208 | MPM.add(createJumpThreadingPass()); // Thread jumps |
| 209 | MPM.add(createCorrelatedValuePropagationPass()); |
| 210 | MPM.add(createDeadStoreEliminationPass()); // Delete dead stores |
| 211 | |
| 212 | addExtensionsToPM(EP_ScalarOptimizerLate, MPM); |
| 213 | |
Nadav Rotem | 2459bf2 | 2012-10-29 18:01:14 +0000 | [diff] [blame] | 214 | if (Vectorize) { |
Hal Finkel | de5e5ec | 2012-02-01 03:51:43 +0000 | [diff] [blame] | 215 | MPM.add(createBBVectorizePass()); |
| 216 | MPM.add(createInstructionCombiningPass()); |
Hal Finkel | 064551e | 2012-04-13 17:15:33 +0000 | [diff] [blame] | 217 | if (OptLevel > 1 && UseGVNAfterVectorization) |
| 218 | MPM.add(createGVNPass()); // Remove redundancies |
| 219 | else |
| 220 | MPM.add(createEarlyCSEPass()); // Catch trivial redundancies |
Hal Finkel | de5e5ec | 2012-02-01 03:51:43 +0000 | [diff] [blame] | 221 | } |
| 222 | |
Rafael Espindola | c684e83 | 2011-08-02 21:50:27 +0000 | [diff] [blame] | 223 | MPM.add(createAggressiveDCEPass()); // Delete dead instructions |
| 224 | MPM.add(createCFGSimplificationPass()); // Merge & remove BBs |
| 225 | MPM.add(createInstructionCombiningPass()); // Clean up after everything. |
| 226 | |
| 227 | if (!DisableUnitAtATime) { |
| 228 | // FIXME: We shouldn't bother with this anymore. |
| 229 | MPM.add(createStripDeadPrototypesPass()); // Get rid of dead prototypes |
| 230 | |
Evan Cheng | f5fdc14 | 2012-09-28 21:23:26 +0000 | [diff] [blame] | 231 | // GlobalOpt already deletes dead functions and globals, at -O2 try a |
Rafael Espindola | c684e83 | 2011-08-02 21:50:27 +0000 | [diff] [blame] | 232 | // late pass of GlobalDCE. It is capable of deleting dead cycles. |
Evan Cheng | f5fdc14 | 2012-09-28 21:23:26 +0000 | [diff] [blame] | 233 | if (OptLevel > 1) { |
Rafael Espindola | c684e83 | 2011-08-02 21:50:27 +0000 | [diff] [blame] | 234 | MPM.add(createGlobalDCEPass()); // Remove dead fns and globals. |
Rafael Espindola | c684e83 | 2011-08-02 21:50:27 +0000 | [diff] [blame] | 235 | MPM.add(createConstantMergePass()); // Merge dup global constants |
Evan Cheng | f5fdc14 | 2012-09-28 21:23:26 +0000 | [diff] [blame] | 236 | } |
Rafael Espindola | c684e83 | 2011-08-02 21:50:27 +0000 | [diff] [blame] | 237 | } |
Kostya Serebryany | 1db3949 | 2012-03-23 23:22:59 +0000 | [diff] [blame] | 238 | addExtensionsToPM(EP_OptimizerLast, MPM); |
Rafael Espindola | c684e83 | 2011-08-02 21:50:27 +0000 | [diff] [blame] | 239 | } |
| 240 | |
| 241 | void PassManagerBuilder::populateLTOPassManager(PassManagerBase &PM, |
| 242 | bool Internalize, |
Bill Wendling | 3197b44 | 2012-04-02 22:16:50 +0000 | [diff] [blame] | 243 | bool RunInliner, |
| 244 | bool DisableGVNLoadPRE) { |
Rafael Espindola | c684e83 | 2011-08-02 21:50:27 +0000 | [diff] [blame] | 245 | // Provide AliasAnalysis services for optimizations. |
| 246 | addInitialAliasAnalysisPasses(PM); |
| 247 | |
| 248 | // Now that composite has been compiled, scan through the module, looking |
| 249 | // for a main function. If main is defined, mark all other functions |
| 250 | // internal. |
Rafael Espindola | e5551ed | 2012-10-26 18:47:48 +0000 | [diff] [blame] | 251 | if (Internalize) { |
| 252 | std::vector<const char*> E; |
| 253 | E.push_back("main"); |
| 254 | PM.add(createInternalizePass(E)); |
| 255 | } |
Rafael Espindola | c684e83 | 2011-08-02 21:50:27 +0000 | [diff] [blame] | 256 | |
| 257 | // Propagate constants at call sites into the functions they call. This |
| 258 | // opens opportunities for globalopt (and inlining) by substituting function |
| 259 | // pointers passed as arguments to direct uses of functions. |
| 260 | PM.add(createIPSCCPPass()); |
| 261 | |
| 262 | // Now that we internalized some globals, see if we can hack on them! |
| 263 | PM.add(createGlobalOptimizerPass()); |
| 264 | |
| 265 | // Linking modules together can lead to duplicated global constants, only |
| 266 | // keep one copy of each constant. |
| 267 | PM.add(createConstantMergePass()); |
| 268 | |
| 269 | // Remove unused arguments from functions. |
| 270 | PM.add(createDeadArgEliminationPass()); |
| 271 | |
| 272 | // Reduce the code after globalopt and ipsccp. Both can open up significant |
| 273 | // simplification opportunities, and both can propagate functions through |
| 274 | // function pointers. When this happens, we often have to resolve varargs |
| 275 | // calls, etc, so let instcombine do this. |
| 276 | PM.add(createInstructionCombiningPass()); |
| 277 | |
| 278 | // Inline small functions |
| 279 | if (RunInliner) |
| 280 | PM.add(createFunctionInliningPass()); |
| 281 | |
| 282 | PM.add(createPruneEHPass()); // Remove dead EH info. |
| 283 | |
| 284 | // Optimize globals again if we ran the inliner. |
| 285 | if (RunInliner) |
| 286 | PM.add(createGlobalOptimizerPass()); |
| 287 | PM.add(createGlobalDCEPass()); // Remove dead functions. |
| 288 | |
| 289 | // If we didn't decide to inline a function, check to see if we can |
| 290 | // transform it to pass arguments by value instead of by reference. |
| 291 | PM.add(createArgumentPromotionPass()); |
| 292 | |
| 293 | // The IPO passes may leave cruft around. Clean up after them. |
| 294 | PM.add(createInstructionCombiningPass()); |
| 295 | PM.add(createJumpThreadingPass()); |
| 296 | // Break up allocas |
Chandler Carruth | 713aa94 | 2012-09-14 09:22:59 +0000 | [diff] [blame] | 297 | if (UseNewSROA) |
| 298 | PM.add(createSROAPass()); |
| 299 | else |
| 300 | PM.add(createScalarReplAggregatesPass()); |
Rafael Espindola | c684e83 | 2011-08-02 21:50:27 +0000 | [diff] [blame] | 301 | |
| 302 | // Run a few AA driven optimizations here and now, to cleanup the code. |
| 303 | PM.add(createFunctionAttrsPass()); // Add nocapture. |
| 304 | PM.add(createGlobalsModRefPass()); // IP alias analysis. |
| 305 | |
Bill Wendling | 3197b44 | 2012-04-02 22:16:50 +0000 | [diff] [blame] | 306 | PM.add(createLICMPass()); // Hoist loop invariants. |
| 307 | PM.add(createGVNPass(DisableGVNLoadPRE)); // Remove redundancies. |
| 308 | PM.add(createMemCpyOptPass()); // Remove dead memcpys. |
Rafael Espindola | c684e83 | 2011-08-02 21:50:27 +0000 | [diff] [blame] | 309 | // Nuke dead stores. |
| 310 | PM.add(createDeadStoreEliminationPass()); |
| 311 | |
| 312 | // Cleanup and simplify the code after the scalar optimizations. |
| 313 | PM.add(createInstructionCombiningPass()); |
| 314 | |
| 315 | PM.add(createJumpThreadingPass()); |
| 316 | |
| 317 | // Delete basic blocks, which optimization passes may have killed. |
| 318 | PM.add(createCFGSimplificationPass()); |
| 319 | |
| 320 | // Now that we have optimized the program, discard unreachable functions. |
| 321 | PM.add(createGlobalDCEPass()); |
| 322 | } |
Rafael Espindola | 69cb216 | 2011-08-09 22:17:34 +0000 | [diff] [blame] | 323 | |
Dmitri Gribenko | 79c07d2 | 2012-11-15 16:51:49 +0000 | [diff] [blame] | 324 | LLVMPassManagerBuilderRef LLVMPassManagerBuilderCreate() { |
Rafael Espindola | 69cb216 | 2011-08-09 22:17:34 +0000 | [diff] [blame] | 325 | PassManagerBuilder *PMB = new PassManagerBuilder(); |
| 326 | return wrap(PMB); |
| 327 | } |
| 328 | |
| 329 | void LLVMPassManagerBuilderDispose(LLVMPassManagerBuilderRef PMB) { |
| 330 | PassManagerBuilder *Builder = unwrap(PMB); |
| 331 | delete Builder; |
| 332 | } |
| 333 | |
| 334 | void |
| 335 | LLVMPassManagerBuilderSetOptLevel(LLVMPassManagerBuilderRef PMB, |
| 336 | unsigned OptLevel) { |
| 337 | PassManagerBuilder *Builder = unwrap(PMB); |
| 338 | Builder->OptLevel = OptLevel; |
| 339 | } |
| 340 | |
| 341 | void |
| 342 | LLVMPassManagerBuilderSetSizeLevel(LLVMPassManagerBuilderRef PMB, |
| 343 | unsigned SizeLevel) { |
| 344 | PassManagerBuilder *Builder = unwrap(PMB); |
| 345 | Builder->SizeLevel = SizeLevel; |
| 346 | } |
| 347 | |
| 348 | void |
| 349 | LLVMPassManagerBuilderSetDisableUnitAtATime(LLVMPassManagerBuilderRef PMB, |
| 350 | LLVMBool Value) { |
| 351 | PassManagerBuilder *Builder = unwrap(PMB); |
| 352 | Builder->DisableUnitAtATime = Value; |
| 353 | } |
| 354 | |
| 355 | void |
| 356 | LLVMPassManagerBuilderSetDisableUnrollLoops(LLVMPassManagerBuilderRef PMB, |
| 357 | LLVMBool Value) { |
| 358 | PassManagerBuilder *Builder = unwrap(PMB); |
| 359 | Builder->DisableUnrollLoops = Value; |
| 360 | } |
| 361 | |
| 362 | void |
| 363 | LLVMPassManagerBuilderSetDisableSimplifyLibCalls(LLVMPassManagerBuilderRef PMB, |
| 364 | LLVMBool Value) { |
| 365 | PassManagerBuilder *Builder = unwrap(PMB); |
| 366 | Builder->DisableSimplifyLibCalls = Value; |
| 367 | } |
| 368 | |
| 369 | void |
| 370 | LLVMPassManagerBuilderUseInlinerWithThreshold(LLVMPassManagerBuilderRef PMB, |
| 371 | unsigned Threshold) { |
| 372 | PassManagerBuilder *Builder = unwrap(PMB); |
| 373 | Builder->Inliner = createFunctionInliningPass(Threshold); |
| 374 | } |
| 375 | |
| 376 | void |
| 377 | LLVMPassManagerBuilderPopulateFunctionPassManager(LLVMPassManagerBuilderRef PMB, |
| 378 | LLVMPassManagerRef PM) { |
| 379 | PassManagerBuilder *Builder = unwrap(PMB); |
| 380 | FunctionPassManager *FPM = unwrap<FunctionPassManager>(PM); |
| 381 | Builder->populateFunctionPassManager(*FPM); |
| 382 | } |
| 383 | |
| 384 | void |
| 385 | LLVMPassManagerBuilderPopulateModulePassManager(LLVMPassManagerBuilderRef PMB, |
| 386 | LLVMPassManagerRef PM) { |
| 387 | PassManagerBuilder *Builder = unwrap(PMB); |
| 388 | PassManagerBase *MPM = unwrap(PM); |
| 389 | Builder->populateModulePassManager(*MPM); |
| 390 | } |
| 391 | |
| 392 | void LLVMPassManagerBuilderPopulateLTOPassManager(LLVMPassManagerBuilderRef PMB, |
| 393 | LLVMPassManagerRef PM, |
| 394 | bool Internalize, |
| 395 | bool RunInliner) { |
| 396 | PassManagerBuilder *Builder = unwrap(PMB); |
| 397 | PassManagerBase *LPM = unwrap(PM); |
| 398 | Builder->populateLTOPassManager(*LPM, Internalize, RunInliner); |
| 399 | } |