blob: 5399e6865a7c64052577bad61fa11c2f40bacdec [file] [log] [blame]
Rafael Espindolac684e832011-08-02 21:50:27 +00001//===- 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"
Rafael Espindola69cb2162011-08-09 22:17:34 +000017#include "llvm-c/Transforms/PassManagerBuilder.h"
Chandler Carruthd04a8d42012-12-03 16:50:05 +000018#include "llvm/ADT/SmallVector.h"
Rafael Espindolac684e832011-08-02 21:50:27 +000019#include "llvm/Analysis/Passes.h"
Hal Finkelde5e5ec2012-02-01 03:51:43 +000020#include "llvm/Analysis/Verifier.h"
Chandler Carruthd04a8d42012-12-03 16:50:05 +000021#include "llvm/PassManager.h"
Hal Finkelde5e5ec2012-02-01 03:51:43 +000022#include "llvm/Support/CommandLine.h"
Chandler Carruthd04a8d42012-12-03 16:50:05 +000023#include "llvm/Support/ManagedStatic.h"
Rafael Espindolac684e832011-08-02 21:50:27 +000024#include "llvm/Target/TargetLibraryInfo.h"
Chandler Carruthd04a8d42012-12-03 16:50:05 +000025#include "llvm/Transforms/IPO.h"
Rafael Espindolac684e832011-08-02 21:50:27 +000026#include "llvm/Transforms/Scalar.h"
Hal Finkelde5e5ec2012-02-01 03:51:43 +000027#include "llvm/Transforms/Vectorize.h"
Rafael Espindolac684e832011-08-02 21:50:27 +000028
29using namespace llvm;
30
Hal Finkelde5e5ec2012-02-01 03:51:43 +000031static cl::opt<bool>
Nadav Rotemfe168482013-10-18 23:38:13 +000032RunLoopVectorization("vectorize-loops", cl::Hidden,
Nadav Rotem9210cc32012-10-30 18:37:43 +000033 cl::desc("Run the Loop vectorization passes"));
Nadav Rotemd233b782012-10-29 16:36:25 +000034
35static cl::opt<bool>
Nadav Rotem7b15c0a2013-09-03 21:33:17 +000036LateVectorization("late-vectorize", cl::init(true), cl::Hidden,
Chandler Carruth6bf3a052013-06-24 07:21:47 +000037 cl::desc("Run the vectorization pasess late in the pass "
38 "pipeline (after the inliner)"));
39
40static cl::opt<bool>
Nadav Rotemfe168482013-10-18 23:38:13 +000041RunSLPVectorization("vectorize-slp", cl::Hidden,
Nadav Rotem1129a832013-04-15 05:39:58 +000042 cl::desc("Run the SLP vectorization passes"));
43
44static cl::opt<bool>
Nadav Rotemfe168482013-10-18 23:38:13 +000045RunBBVectorization("vectorize-slp-aggressive", cl::Hidden,
Nadav Rotem1129a832013-04-15 05:39:58 +000046 cl::desc("Run the BB vectorization passes"));
Hal Finkelde5e5ec2012-02-01 03:51:43 +000047
Hal Finkel064551e2012-04-13 17:15:33 +000048static cl::opt<bool>
49UseGVNAfterVectorization("use-gvn-after-vectorization",
50 cl::init(false), cl::Hidden,
51 cl::desc("Run GVN instead of Early CSE after vectorization passes"));
52
Chandler Carruth713aa942012-09-14 09:22:59 +000053static cl::opt<bool> UseNewSROA("use-new-sroa",
Chandler Carruth1fe4fae2012-10-02 04:24:01 +000054 cl::init(true), cl::Hidden,
Chandler Carruth713aa942012-09-14 09:22:59 +000055 cl::desc("Enable the new, experimental SROA pass"));
56
Hal Finkelbebe48d2013-11-16 23:59:05 +000057static cl::opt<bool>
58RunLoopRerolling("reroll-loops", cl::Hidden,
59 cl::desc("Run the loop rerolling pass"));
60
Rafael Espindolac684e832011-08-02 21:50:27 +000061PassManagerBuilder::PassManagerBuilder() {
62 OptLevel = 2;
63 SizeLevel = 0;
64 LibraryInfo = 0;
65 Inliner = 0;
Rafael Espindolac684e832011-08-02 21:50:27 +000066 DisableUnitAtATime = false;
67 DisableUnrollLoops = false;
Nadav Rotem1129a832013-04-15 05:39:58 +000068 BBVectorize = RunBBVectorization;
Nadav Rotem88498382013-04-15 04:54:42 +000069 SLPVectorize = RunSLPVectorization;
Nadav Rotemd233b782012-10-29 16:36:25 +000070 LoopVectorize = RunLoopVectorization;
Chandler Carruth6bf3a052013-06-24 07:21:47 +000071 LateVectorize = LateVectorization;
Rafael Espindolac684e832011-08-02 21:50:27 +000072}
73
74PassManagerBuilder::~PassManagerBuilder() {
75 delete LibraryInfo;
76 delete Inliner;
77}
78
David Chisnall7a817ea2011-08-16 13:58:41 +000079/// Set of global extensions, automatically added as part of the standard set.
80static ManagedStatic<SmallVector<std::pair<PassManagerBuilder::ExtensionPointTy,
81 PassManagerBuilder::ExtensionFn>, 8> > GlobalExtensions;
82
83void PassManagerBuilder::addGlobalExtension(
84 PassManagerBuilder::ExtensionPointTy Ty,
85 PassManagerBuilder::ExtensionFn Fn) {
86 GlobalExtensions->push_back(std::make_pair(Ty, Fn));
87}
88
Rafael Espindolac684e832011-08-02 21:50:27 +000089void PassManagerBuilder::addExtension(ExtensionPointTy Ty, ExtensionFn Fn) {
90 Extensions.push_back(std::make_pair(Ty, Fn));
91}
92
93void PassManagerBuilder::addExtensionsToPM(ExtensionPointTy ETy,
94 PassManagerBase &PM) const {
David Chisnall7a817ea2011-08-16 13:58:41 +000095 for (unsigned i = 0, e = GlobalExtensions->size(); i != e; ++i)
96 if ((*GlobalExtensions)[i].first == ETy)
97 (*GlobalExtensions)[i].second(*this, PM);
Rafael Espindolac684e832011-08-02 21:50:27 +000098 for (unsigned i = 0, e = Extensions.size(); i != e; ++i)
99 if (Extensions[i].first == ETy)
100 Extensions[i].second(*this, PM);
101}
102
103void
104PassManagerBuilder::addInitialAliasAnalysisPasses(PassManagerBase &PM) const {
105 // Add TypeBasedAliasAnalysis before BasicAliasAnalysis so that
106 // BasicAliasAnalysis wins if they disagree. This is intended to help
107 // support "obvious" type-punning idioms.
108 PM.add(createTypeBasedAliasAnalysisPass());
109 PM.add(createBasicAliasAnalysisPass());
110}
111
112void PassManagerBuilder::populateFunctionPassManager(FunctionPassManager &FPM) {
113 addExtensionsToPM(EP_EarlyAsPossible, FPM);
114
115 // Add LibraryInfo if we have some.
116 if (LibraryInfo) FPM.add(new TargetLibraryInfo(*LibraryInfo));
117
118 if (OptLevel == 0) return;
119
120 addInitialAliasAnalysisPasses(FPM);
121
122 FPM.add(createCFGSimplificationPass());
Chandler Carruth713aa942012-09-14 09:22:59 +0000123 if (UseNewSROA)
124 FPM.add(createSROAPass());
125 else
126 FPM.add(createScalarReplAggregatesPass());
Rafael Espindolac684e832011-08-02 21:50:27 +0000127 FPM.add(createEarlyCSEPass());
128 FPM.add(createLowerExpectIntrinsicPass());
129}
130
131void PassManagerBuilder::populateModulePassManager(PassManagerBase &MPM) {
132 // If all optimizations are disabled, just run the always-inline pass.
133 if (OptLevel == 0) {
134 if (Inliner) {
135 MPM.add(Inliner);
136 Inliner = 0;
137 }
Chandler Carruth63a1eb62012-10-18 08:05:46 +0000138
139 // FIXME: This is a HACK! The inliner pass above implicitly creates a CGSCC
140 // pass manager, but we don't want to add extensions into that pass manager.
141 // To prevent this we must insert a no-op module pass to reset the pass
142 // manager to get the same behavior as EP_OptimizerLast in non-O0 builds.
143 if (!GlobalExtensions->empty() || !Extensions.empty())
144 MPM.add(createBarrierNoopPass());
145
Kostya Serebryanyaf65a8c2011-11-30 22:19:26 +0000146 addExtensionsToPM(EP_EnabledOnOptLevel0, MPM);
Rafael Espindolac684e832011-08-02 21:50:27 +0000147 return;
148 }
149
150 // Add LibraryInfo if we have some.
151 if (LibraryInfo) MPM.add(new TargetLibraryInfo(*LibraryInfo));
152
153 addInitialAliasAnalysisPasses(MPM);
154
155 if (!DisableUnitAtATime) {
Dan Gohman7d4c87e2012-01-17 20:51:32 +0000156 addExtensionsToPM(EP_ModuleOptimizerEarly, MPM);
157
Rafael Espindolac684e832011-08-02 21:50:27 +0000158 MPM.add(createGlobalOptimizerPass()); // Optimize out global vars
159
160 MPM.add(createIPSCCPPass()); // IP SCCP
161 MPM.add(createDeadArgEliminationPass()); // Dead argument elimination
162
163 MPM.add(createInstructionCombiningPass());// Clean up after IPCP & DAE
164 MPM.add(createCFGSimplificationPass()); // Clean up after IPCP & DAE
165 }
166
167 // Start of CallGraph SCC passes.
168 if (!DisableUnitAtATime)
169 MPM.add(createPruneEHPass()); // Remove dead EH info
170 if (Inliner) {
171 MPM.add(Inliner);
172 Inliner = 0;
173 }
174 if (!DisableUnitAtATime)
175 MPM.add(createFunctionAttrsPass()); // Set readonly/readnone attrs
176 if (OptLevel > 2)
177 MPM.add(createArgumentPromotionPass()); // Scalarize uninlined fn args
178
179 // Start of function pass.
180 // Break up aggregate allocas, using SSAUpdater.
Chandler Carruth1c8db502012-09-15 11:43:14 +0000181 if (UseNewSROA)
182 MPM.add(createSROAPass(/*RequiresDomTree*/ false));
183 else
184 MPM.add(createScalarReplAggregatesPass(-1, false));
Rafael Espindolac684e832011-08-02 21:50:27 +0000185 MPM.add(createEarlyCSEPass()); // Catch trivial redundancies
Rafael Espindolac684e832011-08-02 21:50:27 +0000186 MPM.add(createJumpThreadingPass()); // Thread jumps.
187 MPM.add(createCorrelatedValuePropagationPass()); // Propagate conditionals
188 MPM.add(createCFGSimplificationPass()); // Merge & remove BBs
189 MPM.add(createInstructionCombiningPass()); // Combine silly seq's
190
191 MPM.add(createTailCallEliminationPass()); // Eliminate tail calls
192 MPM.add(createCFGSimplificationPass()); // Merge & remove BBs
193 MPM.add(createReassociatePass()); // Reassociate expressions
194 MPM.add(createLoopRotatePass()); // Rotate Loop
195 MPM.add(createLICMPass()); // Hoist loop invariants
196 MPM.add(createLoopUnswitchPass(SizeLevel || OptLevel < 3));
197 MPM.add(createInstructionCombiningPass());
198 MPM.add(createIndVarSimplifyPass()); // Canonicalize indvars
199 MPM.add(createLoopIdiomPass()); // Recognize idioms like memset.
200 MPM.add(createLoopDeletionPass()); // Delete dead loops
Nadav Rotemd15c0c72012-10-17 18:25:06 +0000201
Arnold Schwaighoferb6171c52013-08-13 15:51:25 +0000202 if (!LateVectorize && LoopVectorize)
Hal Finkel435798e2013-08-28 18:33:10 +0000203 MPM.add(createLoopVectorizePass(DisableUnrollLoops));
Nadav Rotemd15c0c72012-10-17 18:25:06 +0000204
Rafael Espindolac684e832011-08-02 21:50:27 +0000205 if (!DisableUnrollLoops)
206 MPM.add(createLoopUnrollPass()); // Unroll small loops
207 addExtensionsToPM(EP_LoopOptimizerEnd, MPM);
208
209 if (OptLevel > 1)
210 MPM.add(createGVNPass()); // Remove redundancies
211 MPM.add(createMemCpyOptPass()); // Remove memcpy / form memset
212 MPM.add(createSCCPPass()); // Constant prop with SCCP
213
214 // Run instcombine after redundancy elimination to exploit opportunities
215 // opened up by them.
216 MPM.add(createInstructionCombiningPass());
217 MPM.add(createJumpThreadingPass()); // Thread jumps
218 MPM.add(createCorrelatedValuePropagationPass());
219 MPM.add(createDeadStoreEliminationPass()); // Delete dead stores
220
221 addExtensionsToPM(EP_ScalarOptimizerLate, MPM);
222
Hal Finkelbebe48d2013-11-16 23:59:05 +0000223 if (RunLoopRerolling)
224 MPM.add(createLoopRerollPass());
Nadav Rotemf1cd7982013-08-28 23:40:29 +0000225 if (SLPVectorize)
226 MPM.add(createSLPVectorizerPass()); // Vectorize parallel scalar chains.
Nadav Rotem1129a832013-04-15 05:39:58 +0000227
Nadav Rotemf1cd7982013-08-28 23:40:29 +0000228 if (BBVectorize) {
229 MPM.add(createBBVectorizePass());
230 MPM.add(createInstructionCombiningPass());
231 if (OptLevel > 1 && UseGVNAfterVectorization)
232 MPM.add(createGVNPass()); // Remove redundancies
233 else
234 MPM.add(createEarlyCSEPass()); // Catch trivial redundancies
Hal Finkelc0b3d4c2013-01-29 00:22:49 +0000235
Nadav Rotemf1cd7982013-08-28 23:40:29 +0000236 // BBVectorize may have significantly shortened a loop body; unroll again.
237 if (!DisableUnrollLoops)
238 MPM.add(createLoopUnrollPass());
Hal Finkelde5e5ec2012-02-01 03:51:43 +0000239 }
240
Rafael Espindolac684e832011-08-02 21:50:27 +0000241 MPM.add(createAggressiveDCEPass()); // Delete dead instructions
Tom Stellard01d72032013-08-06 02:43:45 +0000242 MPM.add(createCFGSimplificationPass()); // Merge & remove BBs
Rafael Espindolac684e832011-08-02 21:50:27 +0000243 MPM.add(createInstructionCombiningPass()); // Clean up after everything.
244
Chandler Carruth6bf3a052013-06-24 07:21:47 +0000245 // As an experimental mode, run any vectorization passes in a separate
246 // pipeline from the CGSCC pass manager that runs iteratively with the
247 // inliner.
Nadav Rotemf1cd7982013-08-28 23:40:29 +0000248 if (LateVectorize && LoopVectorize) {
Chandler Carruth6bf3a052013-06-24 07:21:47 +0000249 // FIXME: This is a HACK! The inliner pass above implicitly creates a CGSCC
250 // pass manager that we are specifically trying to avoid. To prevent this
251 // we must insert a no-op module pass to reset the pass manager.
252 MPM.add(createBarrierNoopPass());
253
254 // Add the various vectorization passes and relevant cleanup passes for
255 // them since we are no longer in the middle of the main scalar pipeline.
Nadav Rotemf1cd7982013-08-28 23:40:29 +0000256 MPM.add(createLoopVectorizePass(DisableUnrollLoops));
257 MPM.add(createInstructionCombiningPass());
258 MPM.add(createCFGSimplificationPass());
Chandler Carruth6bf3a052013-06-24 07:21:47 +0000259 }
260
Rafael Espindolac684e832011-08-02 21:50:27 +0000261 if (!DisableUnitAtATime) {
262 // FIXME: We shouldn't bother with this anymore.
263 MPM.add(createStripDeadPrototypesPass()); // Get rid of dead prototypes
264
Evan Chengf5fdc142012-09-28 21:23:26 +0000265 // GlobalOpt already deletes dead functions and globals, at -O2 try a
Rafael Espindolac684e832011-08-02 21:50:27 +0000266 // late pass of GlobalDCE. It is capable of deleting dead cycles.
Evan Chengf5fdc142012-09-28 21:23:26 +0000267 if (OptLevel > 1) {
Rafael Espindolac684e832011-08-02 21:50:27 +0000268 MPM.add(createGlobalDCEPass()); // Remove dead fns and globals.
Rafael Espindolac684e832011-08-02 21:50:27 +0000269 MPM.add(createConstantMergePass()); // Merge dup global constants
Evan Chengf5fdc142012-09-28 21:23:26 +0000270 }
Rafael Espindolac684e832011-08-02 21:50:27 +0000271 }
Kostya Serebryany1db39492012-03-23 23:22:59 +0000272 addExtensionsToPM(EP_OptimizerLast, MPM);
Rafael Espindolac684e832011-08-02 21:50:27 +0000273}
274
275void PassManagerBuilder::populateLTOPassManager(PassManagerBase &PM,
276 bool Internalize,
Bill Wendling3197b442012-04-02 22:16:50 +0000277 bool RunInliner,
278 bool DisableGVNLoadPRE) {
Rafael Espindolac684e832011-08-02 21:50:27 +0000279 // Provide AliasAnalysis services for optimizations.
280 addInitialAliasAnalysisPasses(PM);
281
282 // Now that composite has been compiled, scan through the module, looking
283 // for a main function. If main is defined, mark all other functions
284 // internal.
Bill Wendling6e4d93b2013-08-30 00:48:37 +0000285 if (Internalize)
Rafael Espindola7e667c52013-10-31 20:51:58 +0000286 PM.add(createInternalizePass("main"));
Rafael Espindolac684e832011-08-02 21:50:27 +0000287
288 // Propagate constants at call sites into the functions they call. This
289 // opens opportunities for globalopt (and inlining) by substituting function
290 // pointers passed as arguments to direct uses of functions.
291 PM.add(createIPSCCPPass());
292
293 // Now that we internalized some globals, see if we can hack on them!
294 PM.add(createGlobalOptimizerPass());
295
296 // Linking modules together can lead to duplicated global constants, only
297 // keep one copy of each constant.
298 PM.add(createConstantMergePass());
299
300 // Remove unused arguments from functions.
301 PM.add(createDeadArgEliminationPass());
302
303 // Reduce the code after globalopt and ipsccp. Both can open up significant
304 // simplification opportunities, and both can propagate functions through
305 // function pointers. When this happens, we often have to resolve varargs
306 // calls, etc, so let instcombine do this.
307 PM.add(createInstructionCombiningPass());
308
309 // Inline small functions
310 if (RunInliner)
311 PM.add(createFunctionInliningPass());
312
313 PM.add(createPruneEHPass()); // Remove dead EH info.
314
315 // Optimize globals again if we ran the inliner.
316 if (RunInliner)
317 PM.add(createGlobalOptimizerPass());
318 PM.add(createGlobalDCEPass()); // Remove dead functions.
319
320 // If we didn't decide to inline a function, check to see if we can
321 // transform it to pass arguments by value instead of by reference.
322 PM.add(createArgumentPromotionPass());
323
324 // The IPO passes may leave cruft around. Clean up after them.
325 PM.add(createInstructionCombiningPass());
326 PM.add(createJumpThreadingPass());
Bill Wendling6e4d93b2013-08-30 00:48:37 +0000327
Rafael Espindolac684e832011-08-02 21:50:27 +0000328 // Break up allocas
Chandler Carruth713aa942012-09-14 09:22:59 +0000329 if (UseNewSROA)
330 PM.add(createSROAPass());
331 else
332 PM.add(createScalarReplAggregatesPass());
Rafael Espindolac684e832011-08-02 21:50:27 +0000333
334 // Run a few AA driven optimizations here and now, to cleanup the code.
335 PM.add(createFunctionAttrsPass()); // Add nocapture.
336 PM.add(createGlobalsModRefPass()); // IP alias analysis.
337
Bill Wendling3197b442012-04-02 22:16:50 +0000338 PM.add(createLICMPass()); // Hoist loop invariants.
339 PM.add(createGVNPass(DisableGVNLoadPRE)); // Remove redundancies.
340 PM.add(createMemCpyOptPass()); // Remove dead memcpys.
Bill Wendling6e4d93b2013-08-30 00:48:37 +0000341
Rafael Espindolac684e832011-08-02 21:50:27 +0000342 // Nuke dead stores.
343 PM.add(createDeadStoreEliminationPass());
344
345 // Cleanup and simplify the code after the scalar optimizations.
346 PM.add(createInstructionCombiningPass());
347
348 PM.add(createJumpThreadingPass());
349
350 // Delete basic blocks, which optimization passes may have killed.
Tom Stellard01d72032013-08-06 02:43:45 +0000351 PM.add(createCFGSimplificationPass());
Rafael Espindolac684e832011-08-02 21:50:27 +0000352
353 // Now that we have optimized the program, discard unreachable functions.
354 PM.add(createGlobalDCEPass());
355}
Rafael Espindola69cb2162011-08-09 22:17:34 +0000356
Eric Christopher3e397312013-04-22 22:47:22 +0000357inline PassManagerBuilder *unwrap(LLVMPassManagerBuilderRef P) {
358 return reinterpret_cast<PassManagerBuilder*>(P);
359}
360
361inline LLVMPassManagerBuilderRef wrap(PassManagerBuilder *P) {
362 return reinterpret_cast<LLVMPassManagerBuilderRef>(P);
363}
364
Dmitri Gribenko79c07d22012-11-15 16:51:49 +0000365LLVMPassManagerBuilderRef LLVMPassManagerBuilderCreate() {
Rafael Espindola69cb2162011-08-09 22:17:34 +0000366 PassManagerBuilder *PMB = new PassManagerBuilder();
367 return wrap(PMB);
368}
369
370void LLVMPassManagerBuilderDispose(LLVMPassManagerBuilderRef PMB) {
371 PassManagerBuilder *Builder = unwrap(PMB);
372 delete Builder;
373}
374
375void
376LLVMPassManagerBuilderSetOptLevel(LLVMPassManagerBuilderRef PMB,
377 unsigned OptLevel) {
378 PassManagerBuilder *Builder = unwrap(PMB);
379 Builder->OptLevel = OptLevel;
380}
381
382void
383LLVMPassManagerBuilderSetSizeLevel(LLVMPassManagerBuilderRef PMB,
384 unsigned SizeLevel) {
385 PassManagerBuilder *Builder = unwrap(PMB);
386 Builder->SizeLevel = SizeLevel;
387}
388
389void
390LLVMPassManagerBuilderSetDisableUnitAtATime(LLVMPassManagerBuilderRef PMB,
391 LLVMBool Value) {
392 PassManagerBuilder *Builder = unwrap(PMB);
393 Builder->DisableUnitAtATime = Value;
394}
395
396void
397LLVMPassManagerBuilderSetDisableUnrollLoops(LLVMPassManagerBuilderRef PMB,
398 LLVMBool Value) {
399 PassManagerBuilder *Builder = unwrap(PMB);
400 Builder->DisableUnrollLoops = Value;
401}
402
403void
404LLVMPassManagerBuilderSetDisableSimplifyLibCalls(LLVMPassManagerBuilderRef PMB,
405 LLVMBool Value) {
Meador Ingebe87bce2013-06-20 19:48:07 +0000406 // NOTE: The simplify-libcalls pass has been removed.
Rafael Espindola69cb2162011-08-09 22:17:34 +0000407}
408
409void
410LLVMPassManagerBuilderUseInlinerWithThreshold(LLVMPassManagerBuilderRef PMB,
411 unsigned Threshold) {
412 PassManagerBuilder *Builder = unwrap(PMB);
413 Builder->Inliner = createFunctionInliningPass(Threshold);
414}
415
416void
417LLVMPassManagerBuilderPopulateFunctionPassManager(LLVMPassManagerBuilderRef PMB,
418 LLVMPassManagerRef PM) {
419 PassManagerBuilder *Builder = unwrap(PMB);
420 FunctionPassManager *FPM = unwrap<FunctionPassManager>(PM);
421 Builder->populateFunctionPassManager(*FPM);
422}
423
424void
425LLVMPassManagerBuilderPopulateModulePassManager(LLVMPassManagerBuilderRef PMB,
426 LLVMPassManagerRef PM) {
427 PassManagerBuilder *Builder = unwrap(PMB);
428 PassManagerBase *MPM = unwrap(PM);
429 Builder->populateModulePassManager(*MPM);
430}
431
432void LLVMPassManagerBuilderPopulateLTOPassManager(LLVMPassManagerBuilderRef PMB,
433 LLVMPassManagerRef PM,
Nick Lewycky0ebc0842013-03-10 21:58:22 +0000434 LLVMBool Internalize,
435 LLVMBool RunInliner) {
Rafael Espindola69cb2162011-08-09 22:17:34 +0000436 PassManagerBuilder *Builder = unwrap(PMB);
437 PassManagerBase *LPM = unwrap(PM);
Nick Lewycky0ebc0842013-03-10 21:58:22 +0000438 Builder->populateLTOPassManager(*LPM, Internalize != 0, RunInliner != 0);
Rafael Espindola69cb2162011-08-09 22:17:34 +0000439}