llvm.org GIT mirror llvm / 2ffea51
[PM] Introduce a reasonable port of the main per-module pass pipeline from the old pass manager in the new one. I'm not trying to support (initially) the numerous options that are currently available to customize the pass pipeline. If we end up really wanting them, we can add them later, but I suspect many are no longer interesting. The simplicity of omitting them will help a lot as we sort out what the pipeline should look like in the new PM. I've also documented to the best of my ability *why* each pass or group of passes is used so that reading the pipeline is more helpful. In many cases I think we have some questionable choices of ordering and I've left FIXME comments in place so we know what to come back and revisit going forward. But for now, I've left it as similar to the current pipeline as I could. Lastly, I've had to comment out several places where passes are not ported to the new pass manager or where the loop pass infrastructure is not yet ready. I did at least fix a few bugs in the loop pass infrastructure uncovered by running the full pipeline, but I didn't want to go too far in this patch -- I'll come back and re-enable these as the infrastructure comes online. But I'd like to keep the comments in place because I don't want to lose track of which passes need to be enabled and where they go. One thing that seemed like a significant API improvement was to require that we don't build pipelines for O0. It seems to have no real benefit. I've also switched back to returning pass managers by value as at this API layer it feels much more natural to me for composition. But if others disagree, I'm happy to go back to an output parameter. I'm not 100% happy with the testing strategy currently, but it seems at least OK. I may come back and try to refactor or otherwise improve this in subsequent patches but I wanted to at least get a good starting point in place. Differential Revision: https://reviews.llvm.org/D28042 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@290325 91177308-0d34-0410-b5e6-96231b3b80d8 Chandler Carruth 2 years ago
8 changed file(s) with 440 addition(s) and 48 deletion(s). Raw diff Collapse all Expand all
1515 #define LLVM_ANALYSIS_LOOPPASSMANAGER_H
1616
1717 #include "llvm/ADT/STLExtras.h"
18 #include "llvm/Analysis/AliasAnalysis.h"
1819 #include "llvm/Analysis/LoopInfo.h"
20 #include "llvm/Analysis/ScalarEvolution.h"
21 #include "llvm/Analysis/TargetLibraryInfo.h"
22 #include "llvm/IR/Dominators.h"
1923 #include "llvm/IR/PassManager.h"
2024
2125 namespace llvm {
8286 // Get the loop structure for this function
8387 LoopInfo &LI = AM.getResult(F);
8488
89 // Also precompute all of the function analyses used by loop passes.
90 // FIXME: These should be handed into the loop passes when the loop pass
91 // management layer is reworked to follow the design of CGSCC.
92 (void)AM.getResult(F);
93 (void)AM.getResult(F);
94 (void)AM.getResult(F);
95 (void)AM.getResult(F);
96
8597 PreservedAnalyses PA = PreservedAnalyses::all();
8698
8799 // We want to visit the loops in reverse post-order. We'll build the stack
164164 /// additional analyses.
165165 void registerLoopAnalyses(LoopAnalysisManager &LAM);
166166
167 /// \brief Add a per-module default optimization pipeline to a pass manager.
167 /// Construct the core LLVM function canonicalization and simplification
168 /// pipeline.
169 ///
170 /// This is a long pipeline and uses most of the per-function optimization
171 /// passes in LLVM to canonicalize and simplify the IR. It is suitable to run
172 /// repeatedly over the IR and is not expected to destroy important
173 /// information about the semantics of the IR.
174 ///
175 /// Note that \p Level cannot be `O0` here. The pipelines produced are
176 /// only intended for use when attempting to optimize code. If frontends
177 /// require some transformations for semantic reasons, they should explicitly
178 /// build them.
179 FunctionPassManager
180 buildFunctionSimplificationPipeline(OptimizationLevel Level,
181 bool DebugLogging = false);
182
183 /// Build a per-module default optimization pipeline.
168184 ///
169185 /// This provides a good default optimization pipeline for per-module
170186 /// optimization and code generation without any link-time optimization. It
171187 /// typically correspond to frontend "-O[123]" options for optimization
172188 /// levels \c O1, \c O2 and \c O3 resp.
173 void addPerModuleDefaultPipeline(ModulePassManager &MPM,
174 OptimizationLevel Level,
175 bool DebugLogging = false);
176
177 /// \brief Add a pre-link, LTO-targeting default optimization pipeline to
178 /// a pass manager.
189 ///
190 /// Note that \p Level cannot be `O0` here. The pipelines produced are
191 /// only intended for use when attempting to optimize code. If frontends
192 /// require some transformations for semantic reasons, they should explicitly
193 /// build them.
194 ModulePassManager buildPerModuleDefaultPipeline(OptimizationLevel Level,
195 bool DebugLogging = false);
196
197 /// Build a pre-link, LTO-targeting default optimization pipeline to a pass
198 /// manager.
179199 ///
180200 /// This adds the pre-link optimizations tuned to work well with a later LTO
181201 /// run. It works to minimize the IR which needs to be analyzed without
182202 /// making irreversible decisions which could be made better during the LTO
183203 /// run.
184 void addLTOPreLinkDefaultPipeline(ModulePassManager &MPM,
185 OptimizationLevel Level,
186 bool DebugLogging = false);
187
188 /// \brief Add an LTO default optimization pipeline to a pass manager.
204 ///
205 /// Note that \p Level cannot be `O0` here. The pipelines produced are
206 /// only intended for use when attempting to optimize code. If frontends
207 /// require some transformations for semantic reasons, they should explicitly
208 /// build them.
209 ModulePassManager buildLTOPreLinkDefaultPipeline(OptimizationLevel Level,
210 bool DebugLogging = false);
211
212 /// Build an LTO default optimization pipeline to a pass manager.
189213 ///
190214 /// This provides a good default optimization pipeline for link-time
191215 /// optimization and code generation. It is particularly tuned to fit well
192216 /// when IR coming into the LTO phase was first run through \c
193217 /// addPreLinkLTODefaultPipeline, and the two coordinate closely.
194 void addLTODefaultPipeline(ModulePassManager &MPM, OptimizationLevel Level,
195 bool DebugLogging = false);
218 ///
219 /// Note that \p Level cannot be `O0` here. The pipelines produced are
220 /// only intended for use when attempting to optimize code. If frontends
221 /// require some transformations for semantic reasons, they should explicitly
222 /// build them.
223 ModulePassManager buildLTODefaultPipeline(OptimizationLevel Level,
224 bool DebugLogging = false);
196225
197226 /// \brief Parse a textual pass pipeline description into a \c ModulePassManager.
198227 ///
2222 /// A simple loop rotation transformation.
2323 class LoopRotatePass : public PassInfoMixin {
2424 public:
25 LoopRotatePass();
25 LoopRotatePass(bool EnableHeaderDuplication = true);
2626 PreservedAnalyses run(Loop &L, LoopAnalysisManager &AM);
27
28 private:
29 const bool EnableHeaderDuplication;
2730 };
2831 }
2932
4949 PA.preserve();
5050 // TODO: What we really want to do here is preserve an AA category, but that
5151 // concept doesn't exist yet.
52 PA.preserve();
5253 PA.preserve();
5354 PA.preserve();
5455 PA.preserve();
139139
140140 static Regex DefaultAliasRegex("^(default|lto-pre-link|lto)<(O[0123sz])>$");
141141
142 static bool isOptimizingForSize(PassBuilder::OptimizationLevel Level) {
143 switch (Level) {
144 case PassBuilder::O0:
145 case PassBuilder::O1:
146 case PassBuilder::O2:
147 case PassBuilder::O3:
148 return false;
149
150 case PassBuilder::Os:
151 case PassBuilder::Oz:
152 return true;
153 }
154 llvm_unreachable("Invalid optimization level!");
155 }
156
142157 namespace {
143158
144159 /// \brief No-op module pass which does nothing.
251266 #include "PassRegistry.def"
252267 }
253268
254 void PassBuilder::addPerModuleDefaultPipeline(ModulePassManager &MPM,
255 OptimizationLevel Level,
256 bool DebugLogging) {
257 // FIXME: Finish fleshing this out to match the legacy pipelines.
269 FunctionPassManager
270 PassBuilder::buildFunctionSimplificationPipeline(OptimizationLevel Level,
271 bool DebugLogging) {
272 assert(Level != O0 && "Must request optimizations!");
273 FunctionPassManager FPM(DebugLogging);
274
275 // Form SSA out of local memory accesses after breaking apart aggregates into
276 // scalars.
277 FPM.addPass(SROA());
278
279 // Catch trivial redundancies
280 FPM.addPass(EarlyCSEPass());
281
282 // Speculative execution if the target has divergent branches; otherwise nop.
283 FPM.addPass(SpeculativeExecutionPass());
284
285 // Optimize based on known information about branches, and cleanup afterward.
286 FPM.addPass(JumpThreadingPass());
287 FPM.addPass(CorrelatedValuePropagationPass());
288 FPM.addPass(SimplifyCFGPass());
289 FPM.addPass(InstCombinePass());
290
291 if (!isOptimizingForSize(Level))
292 FPM.addPass(LibCallsShrinkWrapPass());
293
294 FPM.addPass(TailCallElimPass());
295 FPM.addPass(SimplifyCFGPass());
296
297 // Form canonically associated expression trees, and simplify the trees using
298 // basic mathematical properties. For example, this will form (nearly)
299 // minimal multiplication trees.
300 FPM.addPass(ReassociatePass());
301
302 // Add the primary loop simplification pipeline.
303 // FIXME: Currently this is split into two loop pass pipelines because we run
304 // some function passes in between them. These can and should be replaced by
305 // loop pass equivalenst but those aren't ready yet. Specifically,
306 // `SimplifyCFGPass` and `InstCombinePass` are used. We have
307 // `LoopSimplifyCFGPass` which isn't yet powerful enough, and the closest to
308 // the other we have is `LoopInstSimplify`.
309 LoopPassManager LPM1(DebugLogging), LPM2(DebugLogging);
310
311 // Rotate Loop - disable header duplication at -Oz
312 LPM1.addPass(LoopRotatePass(Level != Oz));
313 LPM1.addPass(LICMPass());
314 // FIXME: Enable these when the loop pass manager can support updating the
315 // loop nest after transformations and we finsih porting the loop passes.
316 #if 0
317 LPM1.addPass(LoopUnswitchPass(/* OptimizeForSize */ Level != O3));
318 LPM2.addPass(IndVarSimplifyPass());
319 LPM2.addPass(LoopIdiomPass());
320 LPM2.addPass(LoopDeletionPass());
321 LPM2.addPass(SimpleLoopUnrollPass());
322 #endif
323 FPM.addPass(createFunctionToLoopPassAdaptor(std::move(LPM1)));
324 FPM.addPass(SimplifyCFGPass());
325 FPM.addPass(InstCombinePass());
326 FPM.addPass(createFunctionToLoopPassAdaptor(std::move(LPM2)));
327
328 // Eliminate redundancies.
329 if (Level != O1) {
330 // These passes add substantial compile time so skip them at O1.
331 FPM.addPass(MergedLoadStoreMotionPass());
332 FPM.addPass(GVN());
333 }
334
335 // Specially optimize memory movement as it doesn't look like dataflow in SSA.
336 FPM.addPass(MemCpyOptPass());
337
338 // Sparse conditional constant propagation.
339 // FIXME: It isn't clear why we do this *after* loop passes rather than
340 // before...
341 FPM.addPass(SCCPPass());
342
343 // Delete dead bit computations (instcombine runs after to fold away the dead
344 // computations, and then ADCE will run later to exploit any new DCE
345 // opportunities that creates).
346 FPM.addPass(BDCEPass());
347
348 // Run instcombine after redundancy and dead bit elimination to exploit
349 // opportunities opened up by them.
350 FPM.addPass(InstCombinePass());
351
352 // Re-consider control flow based optimizations after redundancy elimination,
353 // redo DCE, etc.
354 FPM.addPass(JumpThreadingPass());
355 FPM.addPass(CorrelatedValuePropagationPass());
356 FPM.addPass(DSEPass());
357 FPM.addPass(createFunctionToLoopPassAdaptor(LICMPass()));
358
359 // Finally, do an expensive DCE pass to catch all the dead code exposed by
360 // the simplifications and basic cleanup after all the simplifications.
361 FPM.addPass(ADCEPass());
362 FPM.addPass(SimplifyCFGPass());
363 FPM.addPass(InstCombinePass());
364
365 return FPM;
366 }
367
368 ModulePassManager
369 PassBuilder::buildPerModuleDefaultPipeline(OptimizationLevel Level,
370 bool DebugLogging) {
371 assert(Level != O0 && "Must request optimizations for the default pipeline!");
372 ModulePassManager MPM(DebugLogging);
373
374 // Force any function attributes we want the rest of the pipeline te observe.
375 MPM.addPass(ForceFunctionAttrsPass());
376
377 // Do basic inference of function attributes from known properties of system
378 // libraries and other oracles.
379 MPM.addPass(InferFunctionAttrsPass());
380
381 // Create an early function pass manager to cleanup the output of the
382 // frontend.
258383 FunctionPassManager EarlyFPM(DebugLogging);
259384 EarlyFPM.addPass(SimplifyCFGPass());
260385 EarlyFPM.addPass(SROA());
261386 EarlyFPM.addPass(EarlyCSEPass());
262387 EarlyFPM.addPass(LowerExpectIntrinsicPass());
263
388 EarlyFPM.addPass(GVNHoistPass());
264389 MPM.addPass(createModuleToFunctionPassAdaptor(std::move(EarlyFPM)));
265 }
266
267 void PassBuilder::addLTOPreLinkDefaultPipeline(ModulePassManager &MPM,
268 OptimizationLevel Level,
269 bool DebugLogging) {
390
391 // Interprocedural constant propagation now that basic cleanup has occured
392 // and prior to optimizing globals.
393 // FIXME: This position in the pipeline hasn't been carefully considered in
394 // years, it should be re-analyzed.
395 MPM.addPass(IPSCCPPass());
396
397 // Optimize globals to try and fold them into constants.
398 MPM.addPass(GlobalOptPass());
399
400 // Promote any localized globals to SSA registers.
401 // FIXME: Should this instead by a run of SROA?
402 // FIXME: We should probably run instcombine and simplify-cfg afterward to
403 // delete control flows that are dead once globals have been folded to
404 // constants.
405 MPM.addPass(createModuleToFunctionPassAdaptor(PromotePass()));
406
407 // Remove any dead arguments exposed by cleanups and constand folding
408 // globals.
409 MPM.addPass(DeadArgumentEliminationPass());
410
411 // Create a small function pass pipeline to cleanup after all the global
412 // optimizations.
413 FunctionPassManager GlobalCleanupPM(DebugLogging);
414 GlobalCleanupPM.addPass(InstCombinePass());
415 GlobalCleanupPM.addPass(SimplifyCFGPass());
416 MPM.addPass(createModuleToFunctionPassAdaptor(std::move(GlobalCleanupPM)));
417
418 // FIXME: Enable this when cross-IR-unit analysis invalidation is working.
419 #if 0
420 MPM.addPass(RequireAnalysisPass());
421 #endif
422
423 // Now begin the main postorder CGSCC pipeline.
424 // FIXME: The current CGSCC pipeline has its origins in the legacy pass
425 // manager and trying to emulate its precise behavior. Much of this doesn't
426 // make a lot of sense and we should revisit the core CGSCC structure.
427 CGSCCPassManager MainCGPipeline(DebugLogging);
428
429 // Note: historically, the PruneEH pass was run first to deduce nounwind and
430 // generally clean up exception handling overhead. It isn't clear this is
431 // valuable as the inliner doesn't currently care whether it is inlining an
432 // invoke or a call.
433
434 // Run the inliner first. The theory is that we are walking bottom-up and so
435 // the callees have already been fully optimized, and we want to inline them
436 // into the callers so that our optimizations can reflect that.
437 // FIXME; Customize the threshold based on optimization level.
438 MainCGPipeline.addPass(InlinerPass());
439
440 // Now deduce any function attributes based in the current code.
441 MainCGPipeline.addPass(PostOrderFunctionAttrsPass());
442
443 // Lastly, add the core function simplification pipeline nested inside the
444 // CGSCC walk.
445 MainCGPipeline.addPass(createCGSCCToFunctionPassAdaptor(
446 buildFunctionSimplificationPipeline(Level, DebugLogging)));
447
448 MPM.addPass(
449 createModuleToPostOrderCGSCCPassAdaptor(std::move(MainCGPipeline)));
450
451 // This ends the canonicalization and simplification phase of the pipeline.
452 // At this point, we expect to have canonical and simple IR which we begin
453 // *optimizing* for efficient execution going forward.
454
455 // Eliminate externally available functions now that inlining is over -- we
456 // won't emit these anyways.
457 MPM.addPass(EliminateAvailableExternallyPass());
458
459 // Do RPO function attribute inference across the module to forward-propagate
460 // attributes where applicable.
461 // FIXME: Is this really an optimization rather than a canonicalization?
462 MPM.addPass(ReversePostOrderFunctionAttrsPass());
463
464 // Recompute GloblasAA here prior to function passes. This is particularly
465 // useful as the above will have inlined, DCE'ed, and function-attr
466 // propagated everything. We should at this point have a reasonably minimal
467 // and richly annotated call graph. By computing aliasing and mod/ref
468 // information for all local globals here, the late loop passes and notably
469 // the vectorizer will be able to use them to help recognize vectorizable
470 // memory operations.
471 // FIXME: Enable this once analysis invalidation is fully supported.
472 #if 0
473 MPM.addPass(Require());
474 #endif
475
476 FunctionPassManager OptimizePM(DebugLogging);
477 OptimizePM.addPass(Float2IntPass());
478 // FIXME: We need to run some loop optimizations to re-rotate loops after
479 // simplify-cfg and others undo their rotation.
480
481 // Optimize the loop execution. These passes operate on entire loop nests
482 // rather than on each loop in an inside-out manner, and so they are actually
483 // function passes.
484 OptimizePM.addPass(LoopDistributePass());
485 OptimizePM.addPass(LoopVectorizePass());
486 // FIXME: Need to port Loop Load Elimination and add it here.
487 OptimizePM.addPass(InstCombinePass());
488
489 // Optimize parallel scalar instruction chains into SIMD instructions.
490 OptimizePM.addPass(SLPVectorizerPass());
491
492 // Cleanup after vectorizers.
493 OptimizePM.addPass(SimplifyCFGPass());
494 OptimizePM.addPass(InstCombinePass());
495
496 // Unroll small loops to hide loop backedge latency and saturate any parallel
497 // execution resources of an out-of-order processor.
498 // FIXME: Need to add once loop pass pipeline is available.
499
500 // FIXME: Add the loop sink pass when ported.
501
502 // FIXME: Add cleanup from the loop pass manager when we're forming LCSSA
503 // here.
504
505 // Now that we've vectorized and unrolled loops, we may have more refined
506 // alignment information, try to re-derive it here.
507 OptimizePM.addPass(AlignmentFromAssumptionsPass());
508
509 // ADd the core optimizing pipeline.
510 MPM.addPass(createModuleToFunctionPassAdaptor(std::move(OptimizePM)));
511
512 // Now we need to do some global optimization transforms.
513 // FIXME: It would seem like these should come first in the optimization
514 // pipeline and maybe be the bottom of the canonicalization pipeline? Weird
515 // ordering here.
516 MPM.addPass(GlobalDCEPass());
517 MPM.addPass(ConstantMergePass());
518
519 return MPM;
520 }
521
522 ModulePassManager
523 PassBuilder::buildLTOPreLinkDefaultPipeline(OptimizationLevel Level,
524 bool DebugLogging) {
525 assert(Level != O0 && "Must request optimizations for the default pipeline!");
270526 // FIXME: We should use a customized pre-link pipeline!
271 addPerModuleDefaultPipeline(MPM, Level, DebugLogging);
272 }
273
274 void PassBuilder::addLTODefaultPipeline(ModulePassManager &MPM,
275 OptimizationLevel Level,
276 bool DebugLogging) {
527 return buildPerModuleDefaultPipeline(Level, DebugLogging);
528 }
529
530 ModulePassManager PassBuilder::buildLTODefaultPipeline(OptimizationLevel Level,
531 bool DebugLogging) {
532 assert(Level != O0 && "Must request optimizations for the default pipeline!");
533 ModulePassManager MPM(DebugLogging);
534
277535 // FIXME: Finish fleshing this out to match the legacy LTO pipelines.
278536 FunctionPassManager LateFPM(DebugLogging);
279537 LateFPM.addPass(InstCombinePass());
280538 LateFPM.addPass(SimplifyCFGPass());
281539
282540 MPM.addPass(createModuleToFunctionPassAdaptor(std::move(LateFPM)));
541
542 return MPM;
283543 }
284544
285545 static Optional parseRepeatPassName(StringRef Name) {
499759 .Case("O3", O3)
500760 .Case("Os", Os)
501761 .Case("Oz", Oz);
762 if (L == O0)
763 // At O0 we do nothing at all!
764 return true;
502765
503766 if (Matches[1] == "default") {
504 addPerModuleDefaultPipeline(MPM, L, DebugLogging);
767 MPM.addPass(buildPerModuleDefaultPipeline(L, DebugLogging));
505768 } else if (Matches[1] == "lto-pre-link") {
506 addLTOPreLinkDefaultPipeline(MPM, L, DebugLogging);
769 MPM.addPass(buildLTOPreLinkDefaultPipeline(L, DebugLogging));
507770 } else {
508771 assert(Matches[1] == "lto" && "Not one of the matched options!");
509 addLTODefaultPipeline(MPM, L, DebugLogging);
772 MPM.addPass(buildLTODefaultPipeline(L, DebugLogging));
510773 }
511774 return true;
512775 }
621621 return MadeChange;
622622 }
623623
624 LoopRotatePass::LoopRotatePass() {}
624 LoopRotatePass::LoopRotatePass(bool EnableHeaderDuplication)
625 : EnableHeaderDuplication(EnableHeaderDuplication) {}
625626
626627 PreservedAnalyses LoopRotatePass::run(Loop &L, LoopAnalysisManager &AM) {
627628 auto &FAM = AM.getResult(L).getManager();
635636 // Optional analyses.
636637 auto *DT = FAM.getCachedResult(*F);
637638 auto *SE = FAM.getCachedResult(*F);
638 LoopRotate LR(DefaultRotationThreshold, LI, TTI, AC, DT, SE);
639 int Threshold = EnableHeaderDuplication ? DefaultRotationThreshold : 0;
640 LoopRotate LR(Threshold, LI, TTI, AC, DT, SE);
639641
640642 bool Changed = LR.processLoop(&L);
641643 if (!Changed)
328328
329329 ; RUN: opt -disable-output -disable-verify -debug-pass-manager \
330330 ; RUN: -passes='default' %s 2>&1 \
331 ; RUN: | FileCheck %s --check-prefix=CHECK-O2
331 ; RUN: | FileCheck %s --check-prefix=CHECK-O0
332 ; CHECK-O0: Starting llvm::Module pass manager run
333 ; CHECK-O0-NEXT: Finished llvm::Module pass manager run
334
332335 ; RUN: opt -disable-output -disable-verify -debug-pass-manager \
333336 ; RUN: -passes='default' %s 2>&1 \
334 ; RUN: | FileCheck %s --check-prefix=CHECK-O2
337 ; RUN: | FileCheck %s --check-prefix=CHECK-O --check-prefix=CHECK-O1
335338 ; RUN: opt -disable-output -disable-verify -debug-pass-manager \
336339 ; RUN: -passes='default' %s 2>&1 \
337 ; RUN: | FileCheck %s --check-prefix=CHECK-O2
340 ; RUN: | FileCheck %s --check-prefix=CHECK-O --check-prefix=CHECK-O2
338341 ; RUN: opt -disable-output -disable-verify -debug-pass-manager \
339342 ; RUN: -passes='default' %s 2>&1 \
340 ; RUN: | FileCheck %s --check-prefix=CHECK-O2
343 ; RUN: | FileCheck %s --check-prefix=CHECK-O --check-prefix=CHECK-Os
341344 ; RUN: opt -disable-output -disable-verify -debug-pass-manager \
342345 ; RUN: -passes='default' %s 2>&1 \
343 ; RUN: | FileCheck %s --check-prefix=CHECK-O2
346 ; RUN: | FileCheck %s --check-prefix=CHECK-O --check-prefix=CHECK-Oz
344347 ; RUN: opt -disable-output -disable-verify -debug-pass-manager \
345348 ; RUN: -passes='lto-pre-link' %s 2>&1 \
346 ; RUN: | FileCheck %s --check-prefix=CHECK-O2
347 ; CHECK-O2: Starting llvm::Module pass manager run
348 ; CHECK-O2: Running pass: SimplifyCFGPass
349 ; CHECK-O2: Running pass: SROA
350 ; CHECK-O2: Running pass: EarlyCSEPass
351 ; CHECK-O2: Running pass: LowerExpectIntrinsicPass
349 ; RUN: | FileCheck %s --check-prefix=CHECK-O --check-prefix=CHECK-O2
350 ; CHECK-O: Starting llvm::Module pass manager run
351 ; CHECK-O: Starting llvm::Module pass manager run
352 ; CHECK-O: Running pass: ForceFunctionAttrsPass
353 ; CHECK-O: Running pass: InferFunctionAttrsPass
354 ; CHECK-O: Starting llvm::Function pass manager run.
355 ; CHECK-O: Running pass: SimplifyCFGPass
356 ; CHECK-O: Running pass: SROA
357 ; CHECK-O: Running pass: EarlyCSEPass
358 ; CHECK-O: Running pass: LowerExpectIntrinsicPass
359 ; CHECK-O: Running pass: GVNHoistPass
360 ; CHECK-O: Finished llvm::Function pass manager run.
361 ; CHECK-O: Running pass: IPSCCPPass
362 ; CHECK-O: Running pass: GlobalOptPass
363 ; CHECK-O: Running pass: ModuleToFunctionPassAdaptor<{{.*}}PromotePass>
364 ; CHECK-O: Running pass: DeadArgumentEliminationPass
365 ; CHECK-O: Starting llvm::Function pass manager run.
366 ; CHECK-O: Running pass: InstCombinePass
367 ; CHECK-O: Running pass: SimplifyCFGPass
368 ; CHECK-O: Finished llvm::Function pass manager run.
369 ; CHECK-O: Starting CGSCC pass manager run.
370 ; CHECK-O: Starting llvm::Function pass manager run.
371 ; CHECK-O: Running pass: SROA
372 ; CHECK-O: Running pass: EarlyCSEPass
373 ; CHECK-O: Running pass: SpeculativeExecutionPass
374 ; CHECK-O: Running pass: JumpThreadingPass
375 ; CHECK-O: Running pass: CorrelatedValuePropagationPass
376 ; CHECK-O: Running pass: SimplifyCFGPass
377 ; CHECK-O: Running pass: InstCombinePass
378 ; CHECK-O1: Running pass: LibCallsShrinkWrapPass
379 ; CHECK-O2: Running pass: LibCallsShrinkWrapPass
380 ; CHECK-Os-NOT: Running pass: LibCallsShrinkWrapPass
381 ; CHECK-Oz-NOT: Running pass: LibCallsShrinkWrapPass
382 ; CHECK-O: Running pass: TailCallElimPass
383 ; CHECK-O: Running pass: SimplifyCFGPass
384 ; CHECK-O: Running pass: ReassociatePass
385 ; CHECK-O: Starting llvm::Loop pass manager run.
386 ; CHECK-O: Running pass: LoopRotatePass
387 ; CHECK-O: Running pass: LICMPass
388 ; CHECK-O: Finished llvm::Loop pass manager run.
389 ; CHECK-O: Running pass: SimplifyCFGPass
390 ; CHECK-O: Running pass: InstCombinePass
391 ; CHECK-O: Starting llvm::Loop pass manager run.
392 ; CHECK-O: Finished llvm::Loop pass manager run.
393 ; CHECK-O: Running pass: MemCpyOptPass
394 ; CHECK-O: Running pass: SCCPPass
395 ; CHECK-O: Running pass: BDCEPass
396 ; CHECK-O: Running pass: InstCombinePass
397 ; CHECK-O: Running pass: JumpThreadingPass
398 ; CHECK-O: Running pass: CorrelatedValuePropagationPass
399 ; CHECK-O: Running pass: DSEPass
400 ; CHECK-O: Running pass: FunctionToLoopPassAdaptor<{{.*}}LICMPass>
401 ; CHECK-O: Running pass: ADCEPass
402 ; CHECK-O: Running pass: SimplifyCFGPass
403 ; CHECK-O: Running pass: InstCombinePass
404 ; CHECK-O: Finished llvm::Function pass manager run.
405 ; CHECK-O: Finished CGSCC pass manager run.
406 ; CHECK-O: Running pass: EliminateAvailableExternallyPass
407 ; CHECK-O: Running pass: ReversePostOrderFunctionAttrsPass
408 ; CHECK-O: Starting llvm::Function pass manager run.
409 ; CHECK-O: Running pass: Float2IntPass
410 ; CHECK-O: Running pass: LoopDistributePass
411 ; CHECK-O: Running pass: LoopVectorizePass
412 ; CHECK-O: Running pass: InstCombinePass
413 ; CHECK-O: Running pass: SLPVectorizerPass
414 ; CHECK-O: Running pass: SimplifyCFGPass
415 ; CHECK-O: Running pass: InstCombinePass
416 ; CHECK-O: Running pass: AlignmentFromAssumptionsPass
417 ; CHECK-O: Finished llvm::Function pass manager run.
418 ; CHECK-O: Running pass: GlobalDCEPass
419 ; CHECK-O: Running pass: ConstantMergePass
352420
353421 ; RUN: opt -disable-output -disable-verify -debug-pass-manager \
354422 ; RUN: -passes='lto' %s 2>&1 \
427495 ; CHECK-REPEAT-LOOP-PASS-NEXT: Running analysis: InnerAnalysisManagerProxy<{{.*}}>
428496 ; CHECK-REPEAT-LOOP-PASS-NEXT: Running analysis: LoopAnalysis
429497 ; CHECK-REPEAT-LOOP-PASS-NEXT: Running analysis: DominatorTreeAnalysis
498 ; CHECK-REPEAT-LOOP-PASS-NEXT: Running analysis: AAManager
499 ; CHECK-REPEAT-LOOP-PASS-NEXT: Running analysis: TargetLibraryAnalysis
500 ; CHECK-REPEAT-LOOP-PASS-NEXT: Running analysis: ScalarEvolutionAnalysis
501 ; CHECK-REPEAT-LOOP-PASS-NEXT: Running analysis: AssumptionAnalysis
430502 ; CHECK-REPEAT-LOOP-PASS-NEXT: Starting llvm::Loop pass manager run
431503 ; CHECK-REPEAT-LOOP-PASS-NEXT: Running pass: RepeatedPass
432504 ; CHECK-REPEAT-LOOP-PASS-NEXT: Starting llvm::Loop pass manager run
66 //
77 //===----------------------------------------------------------------------===//
88
9 #include "gtest/gtest.h"
9 #include "llvm/Analysis/AliasAnalysis.h"
10 #include "llvm/Analysis/AssumptionCache.h"
1011 #include "llvm/Analysis/LoopPassManager.h"
12 #include "llvm/Analysis/ScalarEvolution.h"
13 #include "llvm/Analysis/TargetLibraryInfo.h"
1114 #include "llvm/AsmParser/Parser.h"
1215 #include "llvm/IR/Dominators.h"
1316 #include "llvm/IR/Function.h"
1518 #include "llvm/IR/Module.h"
1619 #include "llvm/IR/PassManager.h"
1720 #include "llvm/Support/SourceMgr.h"
21 #include "gtest/gtest.h"
1822
1923 using namespace llvm;
2024
145149 // We need DominatorTreeAnalysis for LoopAnalysis.
146150 FAM.registerPass([&] { return DominatorTreeAnalysis(); });
147151 FAM.registerPass([&] { return LoopAnalysis(); });
152 // We also allow loop passes to assume a set of other analyses and so need
153 // those.
154 FAM.registerPass([&] { return AAManager(); });
155 FAM.registerPass([&] { return TargetLibraryAnalysis(); });
156 FAM.registerPass([&] { return ScalarEvolutionAnalysis(); });
157 FAM.registerPass([&] { return AssumptionAnalysis(); });
148158 FAM.registerPass([&] { return LoopAnalysisManagerFunctionProxy(LAM); });
149159 LAM.registerPass([&] { return FunctionAnalysisManagerLoopProxy(FAM); });
150160