LLVM  4.0.0
PassBuilder.cpp
Go to the documentation of this file.
1 //===- Parsing, selection, and construction of pass pipelines -------------===//
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 /// \file
10 ///
11 /// This file provides the implementation of the PassBuilder based on our
12 /// static pass registry as well as related functionality. It also provides
13 /// helpers to aid in analyzing, debugging, and testing passes and pass
14 /// pipelines.
15 ///
16 //===----------------------------------------------------------------------===//
17 
19 #include "llvm/ADT/StringSwitch.h"
36 #include "llvm/Analysis/IVUsers.h"
40 #include "llvm/Analysis/LoopInfo.h"
55 #include "llvm/IR/Dominators.h"
57 #include "llvm/IR/PassManager.h"
58 #include "llvm/IR/Verifier.h"
59 #include "llvm/Support/Debug.h"
60 #include "llvm/Support/Regex.h"
140 
141 #include <type_traits>
142 
143 using namespace llvm;
144 
145 static Regex DefaultAliasRegex("^(default|lto-pre-link|lto)<(O[0123sz])>$");
146 
148  switch (Level) {
149  case PassBuilder::O0:
150  case PassBuilder::O1:
151  case PassBuilder::O2:
152  case PassBuilder::O3:
153  return false;
154 
155  case PassBuilder::Os:
156  case PassBuilder::Oz:
157  return true;
158  }
159  llvm_unreachable("Invalid optimization level!");
160 }
161 
162 namespace {
163 
164 /// \brief No-op module pass which does nothing.
165 struct NoOpModulePass {
167  return PreservedAnalyses::all();
168  }
169  static StringRef name() { return "NoOpModulePass"; }
170 };
171 
172 /// \brief No-op module analysis.
173 class NoOpModuleAnalysis : public AnalysisInfoMixin<NoOpModuleAnalysis> {
175  static AnalysisKey Key;
176 
177 public:
178  struct Result {};
179  Result run(Module &, ModuleAnalysisManager &) { return Result(); }
180  static StringRef name() { return "NoOpModuleAnalysis"; }
181 };
182 
183 /// \brief No-op CGSCC pass which does nothing.
184 struct NoOpCGSCCPass {
187  return PreservedAnalyses::all();
188  }
189  static StringRef name() { return "NoOpCGSCCPass"; }
190 };
191 
192 /// \brief No-op CGSCC analysis.
193 class NoOpCGSCCAnalysis : public AnalysisInfoMixin<NoOpCGSCCAnalysis> {
195  static AnalysisKey Key;
196 
197 public:
198  struct Result {};
200  return Result();
201  }
202  static StringRef name() { return "NoOpCGSCCAnalysis"; }
203 };
204 
205 /// \brief No-op function pass which does nothing.
206 struct NoOpFunctionPass {
208  return PreservedAnalyses::all();
209  }
210  static StringRef name() { return "NoOpFunctionPass"; }
211 };
212 
213 /// \brief No-op function analysis.
214 class NoOpFunctionAnalysis : public AnalysisInfoMixin<NoOpFunctionAnalysis> {
216  static AnalysisKey Key;
217 
218 public:
219  struct Result {};
220  Result run(Function &, FunctionAnalysisManager &) { return Result(); }
221  static StringRef name() { return "NoOpFunctionAnalysis"; }
222 };
223 
224 /// \brief No-op loop pass which does nothing.
225 struct NoOpLoopPass {
228  return PreservedAnalyses::all();
229  }
230  static StringRef name() { return "NoOpLoopPass"; }
231 };
232 
233 /// \brief No-op loop analysis.
234 class NoOpLoopAnalysis : public AnalysisInfoMixin<NoOpLoopAnalysis> {
236  static AnalysisKey Key;
237 
238 public:
239  struct Result {};
241  return Result();
242  }
243  static StringRef name() { return "NoOpLoopAnalysis"; }
244 };
245 
246 AnalysisKey NoOpModuleAnalysis::Key;
247 AnalysisKey NoOpCGSCCAnalysis::Key;
248 AnalysisKey NoOpFunctionAnalysis::Key;
249 AnalysisKey NoOpLoopAnalysis::Key;
250 
251 } // End anonymous namespace.
252 
254 #define MODULE_ANALYSIS(NAME, CREATE_PASS) \
255  MAM.registerPass([&] { return CREATE_PASS; });
256 #include "PassRegistry.def"
257 }
258 
260 #define CGSCC_ANALYSIS(NAME, CREATE_PASS) \
261  CGAM.registerPass([&] { return CREATE_PASS; });
262 #include "PassRegistry.def"
263 }
264 
266 #define FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
267  FAM.registerPass([&] { return CREATE_PASS; });
268 #include "PassRegistry.def"
269 }
270 
272 #define LOOP_ANALYSIS(NAME, CREATE_PASS) \
273  LAM.registerPass([&] { return CREATE_PASS; });
274 #include "PassRegistry.def"
275 }
276 
279  bool DebugLogging) {
280  assert(Level != O0 && "Must request optimizations!");
281  FunctionPassManager FPM(DebugLogging);
282 
283  // Form SSA out of local memory accesses after breaking apart aggregates into
284  // scalars.
285  FPM.addPass(SROA());
286 
287  // Catch trivial redundancies
288  FPM.addPass(EarlyCSEPass());
289 
290  // Speculative execution if the target has divergent branches; otherwise nop.
292 
293  // Optimize based on known information about branches, and cleanup afterward.
294  FPM.addPass(JumpThreadingPass());
296  FPM.addPass(SimplifyCFGPass());
297  FPM.addPass(InstCombinePass());
298 
299  if (!isOptimizingForSize(Level))
301 
302  FPM.addPass(TailCallElimPass());
303  FPM.addPass(SimplifyCFGPass());
304 
305  // Form canonically associated expression trees, and simplify the trees using
306  // basic mathematical properties. For example, this will form (nearly)
307  // minimal multiplication trees.
308  FPM.addPass(ReassociatePass());
309 
310  // Add the primary loop simplification pipeline.
311  // FIXME: Currently this is split into two loop pass pipelines because we run
312  // some function passes in between them. These can and should be replaced by
313  // loop pass equivalenst but those aren't ready yet. Specifically,
314  // `SimplifyCFGPass` and `InstCombinePass` are used. We have
315  // `LoopSimplifyCFGPass` which isn't yet powerful enough, and the closest to
316  // the other we have is `LoopInstSimplify`.
317  LoopPassManager LPM1(DebugLogging), LPM2(DebugLogging);
318 
319  // FIXME: Enable these when the loop pass manager can support enforcing loop
320  // simplified and LCSSA form as well as updating the loop nest after
321  // transformations and we finsih porting the loop passes.
322 #if 0
323  // Rotate Loop - disable header duplication at -Oz
324  LPM1.addPass(LoopRotatePass(Level != Oz));
325  LPM1.addPass(LICMPass());
326  LPM1.addPass(LoopUnswitchPass(/* OptimizeForSize */ Level != O3));
327  LPM2.addPass(IndVarSimplifyPass());
328  LPM2.addPass(LoopIdiomPass());
329  LPM2.addPass(LoopDeletionPass());
330  LPM2.addPass(SimpleLoopUnrollPass());
331 #endif
332  FPM.addPass(createFunctionToLoopPassAdaptor(std::move(LPM1)));
333  FPM.addPass(SimplifyCFGPass());
334  FPM.addPass(InstCombinePass());
335  FPM.addPass(createFunctionToLoopPassAdaptor(std::move(LPM2)));
336 
337  // Eliminate redundancies.
338  if (Level != O1) {
339  // These passes add substantial compile time so skip them at O1.
341  FPM.addPass(GVN());
342  }
343 
344  // Specially optimize memory movement as it doesn't look like dataflow in SSA.
345  FPM.addPass(MemCpyOptPass());
346 
347  // Sparse conditional constant propagation.
348  // FIXME: It isn't clear why we do this *after* loop passes rather than
349  // before...
350  FPM.addPass(SCCPPass());
351 
352  // Delete dead bit computations (instcombine runs after to fold away the dead
353  // computations, and then ADCE will run later to exploit any new DCE
354  // opportunities that creates).
355  FPM.addPass(BDCEPass());
356 
357  // Run instcombine after redundancy and dead bit elimination to exploit
358  // opportunities opened up by them.
359  FPM.addPass(InstCombinePass());
360 
361  // Re-consider control flow based optimizations after redundancy elimination,
362  // redo DCE, etc.
363  FPM.addPass(JumpThreadingPass());
365  FPM.addPass(DSEPass());
366  // FIXME: Enable this when the loop pass manager can support enforcing loop
367  // simplified and LCSSA form as well as updating the loop nest after
368  // transformations and we finsih porting the loop passes.
369 #if 0
371 #endif
372 
373  // Finally, do an expensive DCE pass to catch all the dead code exposed by
374  // the simplifications and basic cleanup after all the simplifications.
375  FPM.addPass(ADCEPass());
376  FPM.addPass(SimplifyCFGPass());
377  FPM.addPass(InstCombinePass());
378 
379  return FPM;
380 }
381 
384  bool DebugLogging) {
385  assert(Level != O0 && "Must request optimizations for the default pipeline!");
386  ModulePassManager MPM(DebugLogging);
387 
388  // Force any function attributes we want the rest of the pipeline te observe.
390 
391  // Do basic inference of function attributes from known properties of system
392  // libraries and other oracles.
394 
395  // Create an early function pass manager to cleanup the output of the
396  // frontend.
397  FunctionPassManager EarlyFPM(DebugLogging);
398  EarlyFPM.addPass(SimplifyCFGPass());
399  EarlyFPM.addPass(SROA());
400  EarlyFPM.addPass(EarlyCSEPass());
401  EarlyFPM.addPass(LowerExpectIntrinsicPass());
402  EarlyFPM.addPass(GVNHoistPass());
403  MPM.addPass(createModuleToFunctionPassAdaptor(std::move(EarlyFPM)));
404 
405  // Interprocedural constant propagation now that basic cleanup has occured
406  // and prior to optimizing globals.
407  // FIXME: This position in the pipeline hasn't been carefully considered in
408  // years, it should be re-analyzed.
409  MPM.addPass(IPSCCPPass());
410 
411  // Optimize globals to try and fold them into constants.
412  MPM.addPass(GlobalOptPass());
413 
414  // Promote any localized globals to SSA registers.
415  // FIXME: Should this instead by a run of SROA?
416  // FIXME: We should probably run instcombine and simplify-cfg afterward to
417  // delete control flows that are dead once globals have been folded to
418  // constants.
420 
421  // Remove any dead arguments exposed by cleanups and constand folding
422  // globals.
424 
425  // Create a small function pass pipeline to cleanup after all the global
426  // optimizations.
427  FunctionPassManager GlobalCleanupPM(DebugLogging);
428  GlobalCleanupPM.addPass(InstCombinePass());
429  GlobalCleanupPM.addPass(SimplifyCFGPass());
430  MPM.addPass(createModuleToFunctionPassAdaptor(std::move(GlobalCleanupPM)));
431 
432  // FIXME: Enable this when cross-IR-unit analysis invalidation is working.
433 #if 0
435 #endif
436 
437  // Now begin the main postorder CGSCC pipeline.
438  // FIXME: The current CGSCC pipeline has its origins in the legacy pass
439  // manager and trying to emulate its precise behavior. Much of this doesn't
440  // make a lot of sense and we should revisit the core CGSCC structure.
441  CGSCCPassManager MainCGPipeline(DebugLogging);
442 
443  // Note: historically, the PruneEH pass was run first to deduce nounwind and
444  // generally clean up exception handling overhead. It isn't clear this is
445  // valuable as the inliner doesn't currently care whether it is inlining an
446  // invoke or a call.
447 
448  // Run the inliner first. The theory is that we are walking bottom-up and so
449  // the callees have already been fully optimized, and we want to inline them
450  // into the callers so that our optimizations can reflect that.
451  // FIXME; Customize the threshold based on optimization level.
452  MainCGPipeline.addPass(InlinerPass());
453 
454  // Now deduce any function attributes based in the current code.
455  MainCGPipeline.addPass(PostOrderFunctionAttrsPass());
456 
457  // Lastly, add the core function simplification pipeline nested inside the
458  // CGSCC walk.
460  buildFunctionSimplificationPipeline(Level, DebugLogging)));
461 
462  MPM.addPass(
463  createModuleToPostOrderCGSCCPassAdaptor(std::move(MainCGPipeline)));
464 
465  // This ends the canonicalization and simplification phase of the pipeline.
466  // At this point, we expect to have canonical and simple IR which we begin
467  // *optimizing* for efficient execution going forward.
468 
469  // Eliminate externally available functions now that inlining is over -- we
470  // won't emit these anyways.
472 
473  // Do RPO function attribute inference across the module to forward-propagate
474  // attributes where applicable.
475  // FIXME: Is this really an optimization rather than a canonicalization?
477 
478  // Recompute GloblasAA here prior to function passes. This is particularly
479  // useful as the above will have inlined, DCE'ed, and function-attr
480  // propagated everything. We should at this point have a reasonably minimal
481  // and richly annotated call graph. By computing aliasing and mod/ref
482  // information for all local globals here, the late loop passes and notably
483  // the vectorizer will be able to use them to help recognize vectorizable
484  // memory operations.
485  // FIXME: Enable this once analysis invalidation is fully supported.
486 #if 0
487  MPM.addPass(Require<GlobalsAA>());
488 #endif
489 
490  FunctionPassManager OptimizePM(DebugLogging);
491  OptimizePM.addPass(Float2IntPass());
492  // FIXME: We need to run some loop optimizations to re-rotate loops after
493  // simplify-cfg and others undo their rotation.
494 
495  // Optimize the loop execution. These passes operate on entire loop nests
496  // rather than on each loop in an inside-out manner, and so they are actually
497  // function passes.
498  OptimizePM.addPass(LoopDistributePass());
499 #if 0
500  // FIXME: LoopVectorize relies on "requiring" LCSSA which isn't supported in
501  // the new PM.
502  OptimizePM.addPass(LoopVectorizePass());
503 #endif
504  // FIXME: Need to port Loop Load Elimination and add it here.
505  OptimizePM.addPass(InstCombinePass());
506 
507  // Optimize parallel scalar instruction chains into SIMD instructions.
508  OptimizePM.addPass(SLPVectorizerPass());
509 
510  // Cleanup after vectorizers.
511  OptimizePM.addPass(SimplifyCFGPass());
512  OptimizePM.addPass(InstCombinePass());
513 
514  // Unroll small loops to hide loop backedge latency and saturate any parallel
515  // execution resources of an out-of-order processor.
516  // FIXME: Need to add once loop pass pipeline is available.
517 
518  // FIXME: Add the loop sink pass when ported.
519 
520  // FIXME: Add cleanup from the loop pass manager when we're forming LCSSA
521  // here.
522 
523  // Now that we've vectorized and unrolled loops, we may have more refined
524  // alignment information, try to re-derive it here.
526 
527  // ADd the core optimizing pipeline.
528  MPM.addPass(createModuleToFunctionPassAdaptor(std::move(OptimizePM)));
529 
530  // Now we need to do some global optimization transforms.
531  // FIXME: It would seem like these should come first in the optimization
532  // pipeline and maybe be the bottom of the canonicalization pipeline? Weird
533  // ordering here.
534  MPM.addPass(GlobalDCEPass());
535  MPM.addPass(ConstantMergePass());
536 
537  return MPM;
538 }
539 
542  bool DebugLogging) {
543  assert(Level != O0 && "Must request optimizations for the default pipeline!");
544  // FIXME: We should use a customized pre-link pipeline!
545  return buildPerModuleDefaultPipeline(Level, DebugLogging);
546 }
547 
549  bool DebugLogging) {
550  assert(Level != O0 && "Must request optimizations for the default pipeline!");
551  ModulePassManager MPM(DebugLogging);
552 
553  // FIXME: Finish fleshing this out to match the legacy LTO pipelines.
554  FunctionPassManager LateFPM(DebugLogging);
555  LateFPM.addPass(InstCombinePass());
556  LateFPM.addPass(SimplifyCFGPass());
557 
558  MPM.addPass(createModuleToFunctionPassAdaptor(std::move(LateFPM)));
559 
560  return MPM;
561 }
562 
564  AAManager AA;
565 
566  // The order in which these are registered determines their priority when
567  // being queried.
568 
569  // First we register the basic alias analysis that provides the majority of
570  // per-function local AA logic. This is a stateless, on-demand local set of
571  // AA techniques.
573 
574  // Next we query fast, specialized alias analyses that wrap IR-embedded
575  // information about aliasing.
578 
579  // Add support for querying global aliasing information when available.
580  // Because the `AAManager` is a function analysis and `GlobalsAA` is a module
581  // analysis, all that the `AAManager` can do is query for any *cached*
582  // results from `GlobalsAA` through a readonly proxy..
583 #if 0
584  // FIXME: Enable once the invalidation logic supports this. Currently, the
585  // `AAManager` will hold stale references to the module analyses.
587 #endif
588 
589  return AA;
590 }
591 
593  if (!Name.consume_front("repeat<") || !Name.consume_back(">"))
594  return None;
595  int Count;
596  if (Name.getAsInteger(0, Count) || Count <= 0)
597  return None;
598  return Count;
599 }
600 
602  if (!Name.consume_front("devirt<") || !Name.consume_back(">"))
603  return None;
604  int Count;
605  if (Name.getAsInteger(0, Count) || Count <= 0)
606  return None;
607  return Count;
608 }
609 
611  // Manually handle aliases for pre-configured pipeline fragments.
612  if (Name.startswith("default") || Name.startswith("lto"))
613  return DefaultAliasRegex.match(Name);
614 
615  // Explicitly handle pass manager names.
616  if (Name == "module")
617  return true;
618  if (Name == "cgscc")
619  return true;
620  if (Name == "function")
621  return true;
622 
623  // Explicitly handle custom-parsed pass names.
624  if (parseRepeatPassName(Name))
625  return true;
626 
627 #define MODULE_PASS(NAME, CREATE_PASS) \
628  if (Name == NAME) \
629  return true;
630 #define MODULE_ANALYSIS(NAME, CREATE_PASS) \
631  if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
632  return true;
633 #include "PassRegistry.def"
634 
635  return false;
636 }
637 
639  // Explicitly handle pass manager names.
640  if (Name == "cgscc")
641  return true;
642  if (Name == "function")
643  return true;
644 
645  // Explicitly handle custom-parsed pass names.
646  if (parseRepeatPassName(Name))
647  return true;
648  if (parseDevirtPassName(Name))
649  return true;
650 
651 #define CGSCC_PASS(NAME, CREATE_PASS) \
652  if (Name == NAME) \
653  return true;
654 #define CGSCC_ANALYSIS(NAME, CREATE_PASS) \
655  if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
656  return true;
657 #include "PassRegistry.def"
658 
659  return false;
660 }
661 
663  // Explicitly handle pass manager names.
664  if (Name == "function")
665  return true;
666  if (Name == "loop")
667  return true;
668 
669  // Explicitly handle custom-parsed pass names.
670  if (parseRepeatPassName(Name))
671  return true;
672 
673 #define FUNCTION_PASS(NAME, CREATE_PASS) \
674  if (Name == NAME) \
675  return true;
676 #define FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
677  if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
678  return true;
679 #include "PassRegistry.def"
680 
681  return false;
682 }
683 
685  // Explicitly handle pass manager names.
686  if (Name == "loop")
687  return true;
688 
689  // Explicitly handle custom-parsed pass names.
690  if (parseRepeatPassName(Name))
691  return true;
692 
693 #define LOOP_PASS(NAME, CREATE_PASS) \
694  if (Name == NAME) \
695  return true;
696 #define LOOP_ANALYSIS(NAME, CREATE_PASS) \
697  if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
698  return true;
699 #include "PassRegistry.def"
700 
701  return false;
702 }
703 
705 PassBuilder::parsePipelineText(StringRef Text) {
706  std::vector<PipelineElement> ResultPipeline;
707 
708  SmallVector<std::vector<PipelineElement> *, 4> PipelineStack = {
709  &ResultPipeline};
710  for (;;) {
711  std::vector<PipelineElement> &Pipeline = *PipelineStack.back();
712  size_t Pos = Text.find_first_of(",()");
713  Pipeline.push_back({Text.substr(0, Pos), {}});
714 
715  // If we have a single terminating name, we're done.
716  if (Pos == Text.npos)
717  break;
718 
719  char Sep = Text[Pos];
720  Text = Text.substr(Pos + 1);
721  if (Sep == ',')
722  // Just a name ending in a comma, continue.
723  continue;
724 
725  if (Sep == '(') {
726  // Push the inner pipeline onto the stack to continue processing.
727  PipelineStack.push_back(&Pipeline.back().InnerPipeline);
728  continue;
729  }
730 
731  assert(Sep == ')' && "Bogus separator!");
732  // When handling the close parenthesis, we greedily consume them to avoid
733  // empty strings in the pipeline.
734  do {
735  // If we try to pop the outer pipeline we have unbalanced parentheses.
736  if (PipelineStack.size() == 1)
737  return None;
738 
739  PipelineStack.pop_back();
740  } while (Text.consume_front(")"));
741 
742  // Check if we've finished parsing.
743  if (Text.empty())
744  break;
745 
746  // Otherwise, the end of an inner pipeline always has to be followed by
747  // a comma, and then we can continue.
748  if (!Text.consume_front(","))
749  return None;
750  }
751 
752  if (PipelineStack.size() > 1)
753  // Unbalanced paretheses.
754  return None;
755 
756  assert(PipelineStack.back() == &ResultPipeline &&
757  "Wrong pipeline at the bottom of the stack!");
758  return {std::move(ResultPipeline)};
759 }
760 
761 bool PassBuilder::parseModulePass(ModulePassManager &MPM,
762  const PipelineElement &E, bool VerifyEachPass,
763  bool DebugLogging) {
764  auto &Name = E.Name;
765  auto &InnerPipeline = E.InnerPipeline;
766 
767  // First handle complex passes like the pass managers which carry pipelines.
768  if (!InnerPipeline.empty()) {
769  if (Name == "module") {
770  ModulePassManager NestedMPM(DebugLogging);
771  if (!parseModulePassPipeline(NestedMPM, InnerPipeline, VerifyEachPass,
772  DebugLogging))
773  return false;
774  MPM.addPass(std::move(NestedMPM));
775  return true;
776  }
777  if (Name == "cgscc") {
778  CGSCCPassManager CGPM(DebugLogging);
779  if (!parseCGSCCPassPipeline(CGPM, InnerPipeline, VerifyEachPass,
780  DebugLogging))
781  return false;
783  DebugLogging));
784  return true;
785  }
786  if (Name == "function") {
787  FunctionPassManager FPM(DebugLogging);
788  if (!parseFunctionPassPipeline(FPM, InnerPipeline, VerifyEachPass,
789  DebugLogging))
790  return false;
791  MPM.addPass(createModuleToFunctionPassAdaptor(std::move(FPM)));
792  return true;
793  }
794  if (auto Count = parseRepeatPassName(Name)) {
795  ModulePassManager NestedMPM(DebugLogging);
796  if (!parseModulePassPipeline(NestedMPM, InnerPipeline, VerifyEachPass,
797  DebugLogging))
798  return false;
799  MPM.addPass(createRepeatedPass(*Count, std::move(NestedMPM)));
800  return true;
801  }
802  // Normal passes can't have pipelines.
803  return false;
804  }
805 
806  // Manually handle aliases for pre-configured pipeline fragments.
807  if (Name.startswith("default") || Name.startswith("lto")) {
809  if (!DefaultAliasRegex.match(Name, &Matches))
810  return false;
811  assert(Matches.size() == 3 && "Must capture two matched strings!");
812 
814  .Case("O0", O0)
815  .Case("O1", O1)
816  .Case("O2", O2)
817  .Case("O3", O3)
818  .Case("Os", Os)
819  .Case("Oz", Oz);
820  if (L == O0)
821  // At O0 we do nothing at all!
822  return true;
823 
824  if (Matches[1] == "default") {
825  MPM.addPass(buildPerModuleDefaultPipeline(L, DebugLogging));
826  } else if (Matches[1] == "lto-pre-link") {
827  MPM.addPass(buildLTOPreLinkDefaultPipeline(L, DebugLogging));
828  } else {
829  assert(Matches[1] == "lto" && "Not one of the matched options!");
830  MPM.addPass(buildLTODefaultPipeline(L, DebugLogging));
831  }
832  return true;
833  }
834 
835  // Finally expand the basic registered passes from the .inc file.
836 #define MODULE_PASS(NAME, CREATE_PASS) \
837  if (Name == NAME) { \
838  MPM.addPass(CREATE_PASS); \
839  return true; \
840  }
841 #define MODULE_ANALYSIS(NAME, CREATE_PASS) \
842  if (Name == "require<" NAME ">") { \
843  MPM.addPass( \
844  RequireAnalysisPass< \
845  std::remove_reference<decltype(CREATE_PASS)>::type, Module>()); \
846  return true; \
847  } \
848  if (Name == "invalidate<" NAME ">") { \
849  MPM.addPass(InvalidateAnalysisPass< \
850  std::remove_reference<decltype(CREATE_PASS)>::type>()); \
851  return true; \
852  }
853 #include "PassRegistry.def"
854 
855  return false;
856 }
857 
858 bool PassBuilder::parseCGSCCPass(CGSCCPassManager &CGPM,
859  const PipelineElement &E, bool VerifyEachPass,
860  bool DebugLogging) {
861  auto &Name = E.Name;
862  auto &InnerPipeline = E.InnerPipeline;
863 
864  // First handle complex passes like the pass managers which carry pipelines.
865  if (!InnerPipeline.empty()) {
866  if (Name == "cgscc") {
867  CGSCCPassManager NestedCGPM(DebugLogging);
868  if (!parseCGSCCPassPipeline(NestedCGPM, InnerPipeline, VerifyEachPass,
869  DebugLogging))
870  return false;
871  // Add the nested pass manager with the appropriate adaptor.
872  CGPM.addPass(std::move(NestedCGPM));
873  return true;
874  }
875  if (Name == "function") {
876  FunctionPassManager FPM(DebugLogging);
877  if (!parseFunctionPassPipeline(FPM, InnerPipeline, VerifyEachPass,
878  DebugLogging))
879  return false;
880  // Add the nested pass manager with the appropriate adaptor.
881  CGPM.addPass(
882  createCGSCCToFunctionPassAdaptor(std::move(FPM), DebugLogging));
883  return true;
884  }
885  if (auto Count = parseRepeatPassName(Name)) {
886  CGSCCPassManager NestedCGPM(DebugLogging);
887  if (!parseCGSCCPassPipeline(NestedCGPM, InnerPipeline, VerifyEachPass,
888  DebugLogging))
889  return false;
890  CGPM.addPass(createRepeatedPass(*Count, std::move(NestedCGPM)));
891  return true;
892  }
893  if (auto MaxRepetitions = parseDevirtPassName(Name)) {
894  CGSCCPassManager NestedCGPM(DebugLogging);
895  if (!parseCGSCCPassPipeline(NestedCGPM, InnerPipeline, VerifyEachPass,
896  DebugLogging))
897  return false;
898  CGPM.addPass(createDevirtSCCRepeatedPass(std::move(NestedCGPM),
899  *MaxRepetitions, DebugLogging));
900  return true;
901  }
902  // Normal passes can't have pipelines.
903  return false;
904  }
905 
906  // Now expand the basic registered passes from the .inc file.
907 #define CGSCC_PASS(NAME, CREATE_PASS) \
908  if (Name == NAME) { \
909  CGPM.addPass(CREATE_PASS); \
910  return true; \
911  }
912 #define CGSCC_ANALYSIS(NAME, CREATE_PASS) \
913  if (Name == "require<" NAME ">") { \
914  CGPM.addPass(RequireAnalysisPass< \
915  std::remove_reference<decltype(CREATE_PASS)>::type, \
916  LazyCallGraph::SCC, CGSCCAnalysisManager, LazyCallGraph &, \
917  CGSCCUpdateResult &>()); \
918  return true; \
919  } \
920  if (Name == "invalidate<" NAME ">") { \
921  CGPM.addPass(InvalidateAnalysisPass< \
922  std::remove_reference<decltype(CREATE_PASS)>::type>()); \
923  return true; \
924  }
925 #include "PassRegistry.def"
926 
927  return false;
928 }
929 
930 bool PassBuilder::parseFunctionPass(FunctionPassManager &FPM,
931  const PipelineElement &E,
932  bool VerifyEachPass, bool DebugLogging) {
933  auto &Name = E.Name;
934  auto &InnerPipeline = E.InnerPipeline;
935 
936  // First handle complex passes like the pass managers which carry pipelines.
937  if (!InnerPipeline.empty()) {
938  if (Name == "function") {
939  FunctionPassManager NestedFPM(DebugLogging);
940  if (!parseFunctionPassPipeline(NestedFPM, InnerPipeline, VerifyEachPass,
941  DebugLogging))
942  return false;
943  // Add the nested pass manager with the appropriate adaptor.
944  FPM.addPass(std::move(NestedFPM));
945  return true;
946  }
947  if (Name == "loop") {
948  LoopPassManager LPM(DebugLogging);
949  if (!parseLoopPassPipeline(LPM, InnerPipeline, VerifyEachPass,
950  DebugLogging))
951  return false;
952  // Add the nested pass manager with the appropriate adaptor.
953  FPM.addPass(createFunctionToLoopPassAdaptor(std::move(LPM)));
954  return true;
955  }
956  if (auto Count = parseRepeatPassName(Name)) {
957  FunctionPassManager NestedFPM(DebugLogging);
958  if (!parseFunctionPassPipeline(NestedFPM, InnerPipeline, VerifyEachPass,
959  DebugLogging))
960  return false;
961  FPM.addPass(createRepeatedPass(*Count, std::move(NestedFPM)));
962  return true;
963  }
964  // Normal passes can't have pipelines.
965  return false;
966  }
967 
968  // Now expand the basic registered passes from the .inc file.
969 #define FUNCTION_PASS(NAME, CREATE_PASS) \
970  if (Name == NAME) { \
971  FPM.addPass(CREATE_PASS); \
972  return true; \
973  }
974 #define FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
975  if (Name == "require<" NAME ">") { \
976  FPM.addPass( \
977  RequireAnalysisPass< \
978  std::remove_reference<decltype(CREATE_PASS)>::type, Function>()); \
979  return true; \
980  } \
981  if (Name == "invalidate<" NAME ">") { \
982  FPM.addPass(InvalidateAnalysisPass< \
983  std::remove_reference<decltype(CREATE_PASS)>::type>()); \
984  return true; \
985  }
986 #include "PassRegistry.def"
987 
988  return false;
989 }
990 
991 bool PassBuilder::parseLoopPass(LoopPassManager &LPM, const PipelineElement &E,
992  bool VerifyEachPass, bool DebugLogging) {
993  StringRef Name = E.Name;
994  auto &InnerPipeline = E.InnerPipeline;
995 
996  // First handle complex passes like the pass managers which carry pipelines.
997  if (!InnerPipeline.empty()) {
998  if (Name == "loop") {
999  LoopPassManager NestedLPM(DebugLogging);
1000  if (!parseLoopPassPipeline(NestedLPM, InnerPipeline, VerifyEachPass,
1001  DebugLogging))
1002  return false;
1003  // Add the nested pass manager with the appropriate adaptor.
1004  LPM.addPass(std::move(NestedLPM));
1005  return true;
1006  }
1007  if (auto Count = parseRepeatPassName(Name)) {
1008  LoopPassManager NestedLPM(DebugLogging);
1009  if (!parseLoopPassPipeline(NestedLPM, InnerPipeline, VerifyEachPass,
1010  DebugLogging))
1011  return false;
1012  LPM.addPass(createRepeatedPass(*Count, std::move(NestedLPM)));
1013  return true;
1014  }
1015  // Normal passes can't have pipelines.
1016  return false;
1017  }
1018 
1019  // Now expand the basic registered passes from the .inc file.
1020 #define LOOP_PASS(NAME, CREATE_PASS) \
1021  if (Name == NAME) { \
1022  LPM.addPass(CREATE_PASS); \
1023  return true; \
1024  }
1025 #define LOOP_ANALYSIS(NAME, CREATE_PASS) \
1026  if (Name == "require<" NAME ">") { \
1027  LPM.addPass(RequireAnalysisPass< \
1028  std::remove_reference<decltype(CREATE_PASS)>::type, Loop, \
1029  LoopAnalysisManager, LoopStandardAnalysisResults &, \
1030  LPMUpdater &>()); \
1031  return true; \
1032  } \
1033  if (Name == "invalidate<" NAME ">") { \
1034  LPM.addPass(InvalidateAnalysisPass< \
1035  std::remove_reference<decltype(CREATE_PASS)>::type>()); \
1036  return true; \
1037  }
1038 #include "PassRegistry.def"
1039 
1040  return false;
1041 }
1042 
1043 bool PassBuilder::parseAAPassName(AAManager &AA, StringRef Name) {
1044 #define MODULE_ALIAS_ANALYSIS(NAME, CREATE_PASS) \
1045  if (Name == NAME) { \
1046  AA.registerModuleAnalysis< \
1047  std::remove_reference<decltype(CREATE_PASS)>::type>(); \
1048  return true; \
1049  }
1050 #define FUNCTION_ALIAS_ANALYSIS(NAME, CREATE_PASS) \
1051  if (Name == NAME) { \
1052  AA.registerFunctionAnalysis< \
1053  std::remove_reference<decltype(CREATE_PASS)>::type>(); \
1054  return true; \
1055  }
1056 #include "PassRegistry.def"
1057 
1058  return false;
1059 }
1060 
1061 bool PassBuilder::parseLoopPassPipeline(LoopPassManager &LPM,
1062  ArrayRef<PipelineElement> Pipeline,
1063  bool VerifyEachPass,
1064  bool DebugLogging) {
1065  for (const auto &Element : Pipeline) {
1066  if (!parseLoopPass(LPM, Element, VerifyEachPass, DebugLogging))
1067  return false;
1068  // FIXME: No verifier support for Loop passes!
1069  }
1070  return true;
1071 }
1072 
1073 bool PassBuilder::parseFunctionPassPipeline(FunctionPassManager &FPM,
1074  ArrayRef<PipelineElement> Pipeline,
1075  bool VerifyEachPass,
1076  bool DebugLogging) {
1077  for (const auto &Element : Pipeline) {
1078  if (!parseFunctionPass(FPM, Element, VerifyEachPass, DebugLogging))
1079  return false;
1080  if (VerifyEachPass)
1081  FPM.addPass(VerifierPass());
1082  }
1083  return true;
1084 }
1085 
1086 bool PassBuilder::parseCGSCCPassPipeline(CGSCCPassManager &CGPM,
1087  ArrayRef<PipelineElement> Pipeline,
1088  bool VerifyEachPass,
1089  bool DebugLogging) {
1090  for (const auto &Element : Pipeline) {
1091  if (!parseCGSCCPass(CGPM, Element, VerifyEachPass, DebugLogging))
1092  return false;
1093  // FIXME: No verifier support for CGSCC passes!
1094  }
1095  return true;
1096 }
1097 
1100  CGSCCAnalysisManager &CGAM,
1101  ModuleAnalysisManager &MAM) {
1102  MAM.registerPass([&] { return FunctionAnalysisManagerModuleProxy(FAM); });
1103  MAM.registerPass([&] { return CGSCCAnalysisManagerModuleProxy(CGAM); });
1104  CGAM.registerPass([&] { return ModuleAnalysisManagerCGSCCProxy(MAM); });
1105  FAM.registerPass([&] { return CGSCCAnalysisManagerFunctionProxy(CGAM); });
1106  FAM.registerPass([&] { return ModuleAnalysisManagerFunctionProxy(MAM); });
1107  FAM.registerPass([&] { return LoopAnalysisManagerFunctionProxy(LAM); });
1108  LAM.registerPass([&] { return FunctionAnalysisManagerLoopProxy(FAM); });
1109 }
1110 
1111 bool PassBuilder::parseModulePassPipeline(ModulePassManager &MPM,
1112  ArrayRef<PipelineElement> Pipeline,
1113  bool VerifyEachPass,
1114  bool DebugLogging) {
1115  for (const auto &Element : Pipeline) {
1116  if (!parseModulePass(MPM, Element, VerifyEachPass, DebugLogging))
1117  return false;
1118  if (VerifyEachPass)
1119  MPM.addPass(VerifierPass());
1120  }
1121  return true;
1122 }
1123 
1124 // Primary pass pipeline description parsing routine.
1125 // FIXME: Should this routine accept a TargetMachine or require the caller to
1126 // pre-populate the analysis managers with target-specific stuff?
1128  StringRef PipelineText, bool VerifyEachPass,
1129  bool DebugLogging) {
1130  auto Pipeline = parsePipelineText(PipelineText);
1131  if (!Pipeline || Pipeline->empty())
1132  return false;
1133 
1134  // If the first name isn't at the module layer, wrap the pipeline up
1135  // automatically.
1136  StringRef FirstName = Pipeline->front().Name;
1137 
1138  if (!isModulePassName(FirstName)) {
1139  if (isCGSCCPassName(FirstName))
1140  Pipeline = {{"cgscc", std::move(*Pipeline)}};
1141  else if (isFunctionPassName(FirstName))
1142  Pipeline = {{"function", std::move(*Pipeline)}};
1143  else if (isLoopPassName(FirstName))
1144  Pipeline = {{"function", {{"loop", std::move(*Pipeline)}}}};
1145  else
1146  // Unknown pass name!
1147  return false;
1148  }
1149 
1150  return parseModulePassPipeline(MPM, *Pipeline, VerifyEachPass, DebugLogging);
1151 }
1152 
1154  // If the pipeline just consists of the word 'default' just replace the AA
1155  // manager with our default one.
1156  if (PipelineText == "default") {
1157  AA = buildDefaultAAPipeline();
1158  return true;
1159  }
1160 
1161  while (!PipelineText.empty()) {
1162  StringRef Name;
1163  std::tie(Name, PipelineText) = PipelineText.split(',');
1164  if (!parseAAPassName(AA, Name))
1165  return false;
1166  }
1167 
1168  return true;
1169 }
Super simple passes to force specific function attrs from the commandline into the IR for debugging p...
MachineLoop * L
This file provides the interface for the pass responsible for both simplifying and canonicalizing the...
Analysis pass providing a never-invalidated alias analysis result.
const NoneType None
Definition: None.h:23
std::enable_if< std::numeric_limits< T >::is_signed, bool >::type getAsInteger(unsigned Radix, T &Result) const
Parse the current string as an integer of the specified radix.
Definition: StringRef.h:494
Computes function attributes in post-order over the call graph.
Definition: FunctionAttrs.h:32
A simple loop rotation transformation.
Definition: LoopRotation.h:24
A simple and fast domtree-based CSE pass.
Definition: EarlyCSE.h:29
Interfaces for registering analysis passes, producing common pass manager configurations, and parsing of pass pipelines.
AAManager buildDefaultAAPipeline()
Build the default AAManager with the default alias analysis pipeline registered.
Eliminate dead arguments (and return values) from functions.
This is the interface for LLVM's inclusion-based alias analysis implemented with CFL graph reachabili...
DevirtSCCRepeatedPass< PassT > createDevirtSCCRepeatedPass(PassT Pass, int MaxIterations, bool DebugLogging=false)
A function to deduce a function pass type and wrap it in the templated adaptor.
static Optional< int > parseRepeatPassName(StringRef Name)
This header provides classes for managing a pipeline of passes over loops in LLVM IR...
This is the interface for a simple mod/ref and alias analysis over globals.
A Module instance is used to store all the information related to an LLVM module. ...
Definition: Module.h:52
This file provides the primary interface to the instcombine pass.
This is the interface to build a ModuleSummaryIndex for a module.
InnerAnalysisManagerProxy< LoopAnalysisManager, Function > LoopAnalysisManagerFunctionProxy
A proxy from a LoopAnalysisManager to a Function.
This file provides the interface for LLVM's Scalar Replacement of Aggregates pass.
This file implements a simple N^2 alias analysis accuracy evaluator.
Implements a lazy call graph analysis and related passes for the new pass manager.
RepeatedPass< PassT > createRepeatedPass(int Count, PassT P)
Definition: PassManager.h:1255
void registerModuleAnalyses(ModuleAnalysisManager &MAM)
Registers all available module analysis passes.
This is the interface for a metadata-based scoped no-alias analysis.
void registerModuleAnalysis()
Register a specific AA result.
OuterAnalysisManagerProxy< CGSCCAnalysisManager, Function > CGSCCAnalysisManagerFunctionProxy
A proxy from a CGSCCAnalysisManager to a Function.
OptimizationLevel
LLVM-provided high-level optimization levels.
Definition: PassBuilder.h:44
This file provides the interface for LLVM's PGO Instrumentation lowering pass.
OuterAnalysisManagerProxy< FunctionAnalysisManager, Loop, LoopStandardAnalysisResults & > FunctionAnalysisManagerLoopProxy
A proxy from a FunctionAnalysisManager to a Loop.
The adaptor from a function pass to a loop pass computes these analyses and makes them available to t...
A DCE pass that assumes instructions are dead until proven otherwise.
Definition: ADCE.h:31
A utility pass template to force an analysis result to be available.
Definition: PassManager.h:1183
Reassociate commutative expressions.
Definition: Reassociate.h:58
Support structure for SCC passes to communicate updates the call graph back to the CGSCC pass manager...
OuterAnalysisManagerProxy< ModuleAnalysisManager, LazyCallGraph::SCC, LazyCallGraph & > ModuleAnalysisManagerCGSCCProxy
A proxy from a ModuleAnalysisManager to an SCC.
A pass that transforms external global definitions into declarations.
A simple and fast domtree-based GVN pass to hoist common expressions from sibling branches...
Definition: GVN.h:237
This is the interface for a SCEV-based alias analysis.
A pass to do RPO deduction and propagation of function attributes.
Definition: FunctionAttrs.h:51
bool parseAAPipeline(AAManager &AA, StringRef PipelineText)
Parse a textual alias analysis pipeline into the provided AA manager.
LLVM_ATTRIBUTE_ALWAYS_INLINE bool consume_back(StringRef Suffix)
Returns true if this StringRef has the given suffix and removes that suffix.
Definition: StringRef.h:678
Similar to O2 but tries to optimize for small code size instead of fast execution without triggering ...
Definition: PassBuilder.h:114
InnerAnalysisManagerProxy< FunctionAnalysisManager, Module > FunctionAnalysisManagerModuleProxy
Provide the FunctionAnalysisManager to Module proxy.
Definition: PassManager.h:984
bool registerPass(PassBuilderT &&PassBuilder)
Register an analysis pass with the manager.
Definition: PassManager.h:702
ModulePassManager buildLTODefaultPipeline(OptimizationLevel Level, bool DebugLogging=false)
Build an LTO default optimization pipeline to a pass manager.
void registerLoopAnalyses(LoopAnalysisManager &LAM)
Registers all available loop analysis passes.
A very specialized mode that will optimize for code size at any and all costs.
Definition: PassBuilder.h:123
This file provides interfaces used to build and manipulate a call graph, which is a very useful tool ...
LLVM_ATTRIBUTE_ALWAYS_INLINE StringSwitch & Case(const char(&S)[N], const T &Value)
Definition: StringSwitch.h:74
This file provides the interface for IR based instrumentation passes ( (profile-gen, and profile-use).
#define F(x, y, z)
Definition: MD5.cpp:51
LLVM_ATTRIBUTE_ALWAYS_INLINE bool consume_front(StringRef Prefix)
Returns true if this StringRef has the given prefix and removes that prefix.
Definition: StringRef.h:667
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool startswith(StringRef Prefix) const
Check if this string starts with the given Prefix.
Definition: StringRef.h:264
This file provides the interface for a simple, fast CSE pass.
This file provides the interface for the GCOV style profiler pass.
Performs Loop Invariant Code Motion Pass.
Definition: LICM.h:43
The core GVN pass object.
Definition: GVN.h:46
void crossRegisterProxies(LoopAnalysisManager &LAM, FunctionAnalysisManager &FAM, CGSCCAnalysisManager &CGAM, ModuleAnalysisManager &MAM)
Cross register the analysis managers through their proxies.
Pass to remove unused function declarations.
Definition: GlobalDCE.h:28
A lazily constructed view of the call graph of a module.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
Definition: APInt.h:33
void registerFunctionAnalysis()
Register a specific AA result.
This class implements a trivial dead store elimination.
LLVM_NODISCARD char front() const
front - Get the first character in the string.
Definition: StringRef.h:139
Pass to perform interprocedural constant propagation.
Definition: IPO/SCCP.h:29
A pass which infers function attributes from the names and signatures of function declarations in a m...
static GCRegistry::Add< CoreCLRGC > E("coreclr","CoreCLR-compatible GC")
static bool isFunctionPassName(StringRef Name)
A switch()-like statement whose cases are string literals.
Definition: StringSwitch.h:43
This is the interface for LLVM's unification-based alias analysis implemented with CFL graph reachabi...
static bool isLoopPassName(StringRef Name)
static bool isOptimizingForSize(PassBuilder::OptimizationLevel Level)
A set of analyses that are preserved following a run of a transformation pass.
Definition: PassManager.h:107
This is the interface for a metadata-based TBAA.
ModuleToFunctionPassAdaptor< FunctionPassT > createModuleToFunctionPassAdaptor(FunctionPassT Pass)
A function to deduce a function pass type and wrap it in the templated adaptor.
Definition: PassManager.h:1167
CGSCCToFunctionPassAdaptor< FunctionPassT > createCGSCCToFunctionPassAdaptor(FunctionPassT Pass, bool DebugLogging=false)
A function to deduce a function pass type and wrap it in the templated adaptor.
This file provides the interface for LLVM's Global Value Numbering pass which eliminates fully redund...
Disable as many optimizations as possible.
Definition: PassBuilder.h:48
A manager for alias analyses.
ModulePassManager buildLTOPreLinkDefaultPipeline(OptimizationLevel Level, bool DebugLogging=false)
Build a pre-link, LTO-targeting default optimization pipeline to a pass manager.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE StringRef substr(size_t Start, size_t N=npos) const
Return a reference to the substring from [Start, Start + N).
Definition: StringRef.h:587
A CRTP mix-in that provides informational APIs needed for analysis passes.
Definition: PassManager.h:328
The inliner pass for the new pass manager.
Definition: Inliner.h:94
void registerFunctionAnalyses(FunctionAnalysisManager &FAM)
Registers all available function analysis passes.
Analysis pass providing a never-invalidated alias analysis result.
This file provides the interface for LLVM's Global Value Numbering pass.
Optimize for fast execution as much as possible.
Definition: PassBuilder.h:102
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
Definition: PassManager.h:113
Create a verifier pass.
Definition: Verifier.h:129
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
FunctionPassManager buildFunctionSimplificationPipeline(OptimizationLevel Level, bool DebugLogging=false)
Construct the core LLVM function canonicalization and simplification pipeline.
This file provides the interface for LLVM's Loop Data Prefetching Pass.
Provides passes to inlining "always_inline" functions.
FunctionToLoopPassAdaptor< LoopPassT > createFunctionToLoopPassAdaptor(LoopPassT Pass)
A function to deduce a loop pass type and wrap it in the templated adaptor.
This class provides an interface for updating the loop pass manager based on mutations to the loop ne...
static bool isModulePassName(StringRef Name)
static Optional< int > parseDevirtPassName(StringRef Name)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
Definition: SmallVector.h:843
Optimize for fast execution as much as possible without triggering significant incremental compile ti...
Definition: PassBuilder.h:86
This pass performs 'jump threading', which looks at blocks that have multiple predecessors and multip...
Definition: JumpThreading.h:59
bool parsePassPipeline(ModulePassManager &MPM, StringRef PipelineText, bool VerifyEachPass=true, bool DebugLogging=false)
Parse a textual pass pipeline description into a ModulePassManager.
A pass to simplify and canonicalize the CFG of a function.
Definition: SimplifyCFG.h:28
const DataFlowGraph & G
Definition: RDFGraph.cpp:206
static GCRegistry::Add< ShadowStackGC > C("shadow-stack","Very portable GC for uncooperative code generators")
OuterAnalysisManagerProxy< ModuleAnalysisManager, Function > ModuleAnalysisManagerFunctionProxy
Provide the ModuleAnalysisManager to Function proxy.
Definition: PassManager.h:1095
LLVM_NODISCARD std::pair< StringRef, StringRef > split(char Separator) const
Split into two substrings around the first occurrence of a separator character.
Definition: StringRef.h:716
A pass that merges duplicate global constants into a single constant.
Definition: ConstantMerge.h:29
Analysis pass providing a never-invalidated alias analysis result.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool empty() const
empty - Check if the string is empty.
Definition: StringRef.h:130
This pass performs merges of loads and stores on both sides of a.
Interfaces for passes which infer implicit function attributes from the name and signature of functio...
Analysis pass providing a never-invalidated alias analysis result.
static const size_t npos
Definition: StringRef.h:51
Manages a sequence of passes over a particular unit of IR.
Definition: PassManager.h:389
Represents a single loop in the control flow graph.
Definition: LoopInfo.h:368
static bool isCGSCCPassName(StringRef Name)
Pass which forces specific function attributes into the IR, primarily as a debugging tool...
LLVM_ATTRIBUTE_ALWAYS_INLINE size_type size() const
Definition: SmallVector.h:135
The header file for the LowerExpectIntrinsic pass as used by the new pass manager.
Provides passes for computing function attributes based on interprocedural analyses.
This header provides classes for managing passes over SCCs of the call graph.
This file defines passes to print out IR in various granularities.
ModuleToPostOrderCGSCCPassAdaptor< CGSCCPassT > createModuleToPostOrderCGSCCPassAdaptor(CGSCCPassT Pass, bool DebugLogging=false)
A function to deduce a function pass type and wrap it in the templated adaptor.
void registerCGSCCAnalyses(CGSCCAnalysisManager &CGAM)
Registers all available CGSCC analysis passes.
LLVM_NODISCARD size_t find_first_of(char C, size_t From=0) const
Find the first character in the string that is C, or npos if not found.
Definition: StringRef.h:392
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Optimize quickly without destroying debuggability.
Definition: PassBuilder.h:68
See the comments on JumpThreadingPass.
An SCC of the call graph.
static const char * name
The LoopVectorize Pass.
Definition: LoopVectorize.h:71
static Regex DefaultAliasRegex("^(default|lto-pre-link|lto)<(O[0123sz])>$")
bool match(StringRef String, SmallVectorImpl< StringRef > *Matches=nullptr)
matches - Match the regex against a given String.
Definition: Regex.cpp:68
An optimization pass providing Scalar Replacement of Aggregates.
Definition: SROA.h:54
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:47
This is the interface for LLVM's primary stateless and local alias analysis.
ModulePassManager buildPerModuleDefaultPipeline(OptimizationLevel Level, bool DebugLogging=false)
Build a per-module default optimization pipeline.
A container for analyses that lazily runs them and caches their results.
void addPass(PassT Pass)
Definition: PassManager.h:454
This pass exposes codegen information to IR-level passes.
This pass performs function-level constant propagation and merging.
Definition: Scalar/SCCP.h:30
This header defines various interfaces for pass management in LLVM.
InnerAnalysisManagerProxy< CGSCCAnalysisManager, Module > CGSCCAnalysisManagerModuleProxy
A proxy from a CGSCCAnalysisManager to a Module.
A special type used by analysis passes to provide an address that identifies that particular analysis...
Definition: PassManager.h:64
This file provides the interface for the sampled PGO loader pass.
Optimize globals that never have their address taken.
Definition: GlobalOpt.h:25