LLVM  9.0.0svn
PassBuilder.cpp
Go to the documentation of this file.
1 //===- Parsing, selection, and construction of pass pipelines -------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 /// \file
9 ///
10 /// This file provides the implementation of the PassBuilder based on our
11 /// static pass registry as well as related functionality. It also provides
12 /// helpers to aid in analyzing, debugging, and testing passes and pass
13 /// pipelines.
14 ///
15 //===----------------------------------------------------------------------===//
16 
18 #include "llvm/ADT/StringSwitch.h"
34 #include "llvm/Analysis/IVUsers.h"
38 #include "llvm/Analysis/LoopInfo.h"
56 #include "llvm/IR/Dominators.h"
58 #include "llvm/IR/PassManager.h"
59 #include "llvm/IR/Verifier.h"
60 #include "llvm/Support/Debug.h"
62 #include "llvm/Support/Regex.h"
170 
171 using namespace llvm;
172 
173 static cl::opt<unsigned> MaxDevirtIterations("pm-max-devirt-iterations",
175 static cl::opt<bool>
176  RunPartialInlining("enable-npm-partial-inlining", cl::init(false),
178  cl::desc("Run Partial inlinining pass"));
179 
180 static cl::opt<bool>
181  RunNewGVN("enable-npm-newgvn", cl::init(false),
183  cl::desc("Run NewGVN instead of GVN"));
184 
186  "enable-npm-earlycse-memssa", cl::init(true), cl::Hidden,
187  cl::desc("Enable the EarlyCSE w/ MemorySSA pass for the new PM (default = on)"));
188 
190  "enable-npm-gvn-hoist", cl::init(false), cl::Hidden,
191  cl::desc("Enable the GVN hoisting pass for the new PM (default = off)"));
192 
194  "enable-npm-gvn-sink", cl::init(false), cl::Hidden,
195  cl::desc("Enable the GVN hoisting pass for the new PM (default = off)"));
196 
198  "enable-npm-unroll-and-jam", cl::init(false), cl::Hidden,
199  cl::desc("Enable the Unroll and Jam pass for the new PM (default = off)"));
200 
202  "enable-npm-synthetic-counts", cl::init(false), cl::Hidden, cl::ZeroOrMore,
203  cl::desc("Run synthetic function entry count generation "
204  "pass"));
205 
206 static Regex DefaultAliasRegex(
207  "^(default|thinlto-pre-link|thinlto|lto-pre-link|lto)<(O[0123sz])>$");
208 
209 static cl::opt<bool>
210  EnableCHR("enable-chr-npm", cl::init(true), cl::Hidden,
211  cl::desc("Enable control height reduction optimization (CHR)"));
212 
214 
216 
218  switch (Level) {
219  case PassBuilder::O0:
220  case PassBuilder::O1:
221  case PassBuilder::O2:
222  case PassBuilder::O3:
223  return false;
224 
225  case PassBuilder::Os:
226  case PassBuilder::Oz:
227  return true;
228  }
229  llvm_unreachable("Invalid optimization level!");
230 }
231 
232 namespace {
233 
234 /// No-op module pass which does nothing.
235 struct NoOpModulePass {
237  return PreservedAnalyses::all();
238  }
239  static StringRef name() { return "NoOpModulePass"; }
240 };
241 
242 /// No-op module analysis.
243 class NoOpModuleAnalysis : public AnalysisInfoMixin<NoOpModuleAnalysis> {
245  static AnalysisKey Key;
246 
247 public:
248  struct Result {};
249  Result run(Module &, ModuleAnalysisManager &) { return Result(); }
250  static StringRef name() { return "NoOpModuleAnalysis"; }
251 };
252 
253 /// No-op CGSCC pass which does nothing.
254 struct NoOpCGSCCPass {
257  return PreservedAnalyses::all();
258  }
259  static StringRef name() { return "NoOpCGSCCPass"; }
260 };
261 
262 /// No-op CGSCC analysis.
263 class NoOpCGSCCAnalysis : public AnalysisInfoMixin<NoOpCGSCCAnalysis> {
265  static AnalysisKey Key;
266 
267 public:
268  struct Result {};
270  return Result();
271  }
272  static StringRef name() { return "NoOpCGSCCAnalysis"; }
273 };
274 
275 /// No-op function pass which does nothing.
276 struct NoOpFunctionPass {
278  return PreservedAnalyses::all();
279  }
280  static StringRef name() { return "NoOpFunctionPass"; }
281 };
282 
283 /// No-op function analysis.
284 class NoOpFunctionAnalysis : public AnalysisInfoMixin<NoOpFunctionAnalysis> {
286  static AnalysisKey Key;
287 
288 public:
289  struct Result {};
290  Result run(Function &, FunctionAnalysisManager &) { return Result(); }
291  static StringRef name() { return "NoOpFunctionAnalysis"; }
292 };
293 
294 /// No-op loop pass which does nothing.
295 struct NoOpLoopPass {
298  return PreservedAnalyses::all();
299  }
300  static StringRef name() { return "NoOpLoopPass"; }
301 };
302 
303 /// No-op loop analysis.
304 class NoOpLoopAnalysis : public AnalysisInfoMixin<NoOpLoopAnalysis> {
306  static AnalysisKey Key;
307 
308 public:
309  struct Result {};
311  return Result();
312  }
313  static StringRef name() { return "NoOpLoopAnalysis"; }
314 };
315 
320 
321 } // End anonymous namespace.
322 
323 void PassBuilder::invokePeepholeEPCallbacks(
325  for (auto &C : PeepholeEPCallbacks)
326  C(FPM, Level);
327 }
328 
330 #define MODULE_ANALYSIS(NAME, CREATE_PASS) \
331  MAM.registerPass([&] { return CREATE_PASS; });
332 #include "PassRegistry.def"
333 
334  for (auto &C : ModuleAnalysisRegistrationCallbacks)
335  C(MAM);
336 }
337 
339 #define CGSCC_ANALYSIS(NAME, CREATE_PASS) \
340  CGAM.registerPass([&] { return CREATE_PASS; });
341 #include "PassRegistry.def"
342 
343  for (auto &C : CGSCCAnalysisRegistrationCallbacks)
344  C(CGAM);
345 }
346 
348 #define FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
349  FAM.registerPass([&] { return CREATE_PASS; });
350 #include "PassRegistry.def"
351 
352  for (auto &C : FunctionAnalysisRegistrationCallbacks)
353  C(FAM);
354 }
355 
357 #define LOOP_ANALYSIS(NAME, CREATE_PASS) \
358  LAM.registerPass([&] { return CREATE_PASS; });
359 #include "PassRegistry.def"
360 
361  for (auto &C : LoopAnalysisRegistrationCallbacks)
362  C(LAM);
363 }
364 
368  bool DebugLogging) {
369  assert(Level != O0 && "Must request optimizations!");
370  FunctionPassManager FPM(DebugLogging);
371 
372  // Form SSA out of local memory accesses after breaking apart aggregates into
373  // scalars.
374  FPM.addPass(SROA());
375 
376  // Catch trivial redundancies
378 
379  // Hoisting of scalars and load expressions.
380  if (EnableGVNHoist)
381  FPM.addPass(GVNHoistPass());
382 
383  // Global value numbering based sinking.
384  if (EnableGVNSink) {
385  FPM.addPass(GVNSinkPass());
386  FPM.addPass(SimplifyCFGPass());
387  }
388 
389  // Speculative execution if the target has divergent branches; otherwise nop.
391 
392  // Optimize based on known information about branches, and cleanup afterward.
393  FPM.addPass(JumpThreadingPass());
395  FPM.addPass(SimplifyCFGPass());
396  if (Level == O3)
398  FPM.addPass(InstCombinePass());
399 
400  if (!isOptimizingForSize(Level))
402 
403  invokePeepholeEPCallbacks(FPM, Level);
404 
405  // For PGO use pipeline, try to optimize memory intrinsics such as memcpy
406  // using the size value profile. Don't perform this when optimizing for size.
407  if (PGOOpt && !PGOOpt->ProfileUseFile.empty() &&
408  !isOptimizingForSize(Level))
409  FPM.addPass(PGOMemOPSizeOpt());
410 
411  FPM.addPass(TailCallElimPass());
412  FPM.addPass(SimplifyCFGPass());
413 
414  // Form canonically associated expression trees, and simplify the trees using
415  // basic mathematical properties. For example, this will form (nearly)
416  // minimal multiplication trees.
417  FPM.addPass(ReassociatePass());
418 
419  // Add the primary loop simplification pipeline.
420  // FIXME: Currently this is split into two loop pass pipelines because we run
421  // some function passes in between them. These can and should be removed
422  // and/or replaced by scheduling the loop pass equivalents in the correct
423  // positions. But those equivalent passes aren't powerful enough yet.
424  // Specifically, `SimplifyCFGPass` and `InstCombinePass` are currently still
425  // used. We have `LoopSimplifyCFGPass` which isn't yet powerful enough yet to
426  // fully replace `SimplifyCFGPass`, and the closest to the other we have is
427  // `LoopInstSimplify`.
428  LoopPassManager LPM1(DebugLogging), LPM2(DebugLogging);
429 
430  // Simplify the loop body. We do this initially to clean up after other loop
431  // passes run, either when iterating on a loop or on inner loops with
432  // implications on the outer loop.
433  LPM1.addPass(LoopInstSimplifyPass());
434  LPM1.addPass(LoopSimplifyCFGPass());
435 
436  // Rotate Loop - disable header duplication at -Oz
437  LPM1.addPass(LoopRotatePass(Level != Oz));
438  LPM1.addPass(LICMPass());
439  LPM1.addPass(SimpleLoopUnswitchPass());
440  LPM2.addPass(IndVarSimplifyPass());
442 
443  for (auto &C : LateLoopOptimizationsEPCallbacks)
444  C(LPM2, Level);
445 
446  LPM2.addPass(LoopDeletionPass());
447  // Do not enable unrolling in PreLinkThinLTO phase during sample PGO
448  // because it changes IR to makes profile annotation in back compile
449  // inaccurate.
450  if (Phase != ThinLTOPhase::PreLink ||
451  !PGOOpt || PGOOpt->SampleProfileFile.empty())
452  LPM2.addPass(LoopFullUnrollPass(Level));
453 
454  for (auto &C : LoopOptimizerEndEPCallbacks)
455  C(LPM2, Level);
456 
457  // We provide the opt remark emitter pass for LICM to use. We only need to do
458  // this once as it is immutable.
460  FPM.addPass(createFunctionToLoopPassAdaptor(std::move(LPM1), DebugLogging));
461  FPM.addPass(SimplifyCFGPass());
462  FPM.addPass(InstCombinePass());
463  FPM.addPass(createFunctionToLoopPassAdaptor(std::move(LPM2), DebugLogging));
464 
465  // Eliminate redundancies.
466  if (Level != O1) {
467  // These passes add substantial compile time so skip them at O1.
469  if (RunNewGVN)
470  FPM.addPass(NewGVNPass());
471  else
472  FPM.addPass(GVN());
473  }
474 
475  // Specially optimize memory movement as it doesn't look like dataflow in SSA.
476  FPM.addPass(MemCpyOptPass());
477 
478  // Sparse conditional constant propagation.
479  // FIXME: It isn't clear why we do this *after* loop passes rather than
480  // before...
481  FPM.addPass(SCCPPass());
482 
483  // Delete dead bit computations (instcombine runs after to fold away the dead
484  // computations, and then ADCE will run later to exploit any new DCE
485  // opportunities that creates).
486  FPM.addPass(BDCEPass());
487 
488  // Run instcombine after redundancy and dead bit elimination to exploit
489  // opportunities opened up by them.
490  FPM.addPass(InstCombinePass());
491  invokePeepholeEPCallbacks(FPM, Level);
492 
493  // Re-consider control flow based optimizations after redundancy elimination,
494  // redo DCE, etc.
495  FPM.addPass(JumpThreadingPass());
497  FPM.addPass(DSEPass());
498  FPM.addPass(createFunctionToLoopPassAdaptor(LICMPass(), DebugLogging));
499 
500  for (auto &C : ScalarOptimizerLateEPCallbacks)
501  C(FPM, Level);
502 
503  // Finally, do an expensive DCE pass to catch all the dead code exposed by
504  // the simplifications and basic cleanup after all the simplifications.
505  FPM.addPass(ADCEPass());
506  FPM.addPass(SimplifyCFGPass());
507  FPM.addPass(InstCombinePass());
508  invokePeepholeEPCallbacks(FPM, Level);
509 
510  if (EnableCHR && Level == O3 && PGOOpt &&
511  (!PGOOpt->ProfileUseFile.empty() || !PGOOpt->SampleProfileFile.empty()))
513 
514  return FPM;
515 }
516 
517 void PassBuilder::addPGOInstrPasses(ModulePassManager &MPM, bool DebugLogging,
519  bool RunProfileGen,
520  std::string ProfileGenFile,
521  std::string ProfileUseFile,
522  std::string ProfileRemappingFile) {
523  // Generally running simplification passes and the inliner with an high
524  // threshold results in smaller executables, but there may be cases where
525  // the size grows, so let's be conservative here and skip this simplification
526  // at -Os/Oz.
527  if (!isOptimizingForSize(Level)) {
528  InlineParams IP;
529 
530  // In the old pass manager, this is a cl::opt. Should still this be one?
531  IP.DefaultThreshold = 75;
532 
533  // FIXME: The hint threshold has the same value used by the regular inliner.
534  // This should probably be lowered after performance testing.
535  // FIXME: this comment is cargo culted from the old pass manager, revisit).
536  IP.HintThreshold = 325;
537 
538  CGSCCPassManager CGPipeline(DebugLogging);
539 
540  CGPipeline.addPass(InlinerPass(IP));
541 
543  FPM.addPass(SROA());
544  FPM.addPass(EarlyCSEPass()); // Catch trivial redundancies.
545  FPM.addPass(SimplifyCFGPass()); // Merge & remove basic blocks.
546  FPM.addPass(InstCombinePass()); // Combine silly sequences.
547  invokePeepholeEPCallbacks(FPM, Level);
548 
549  CGPipeline.addPass(createCGSCCToFunctionPassAdaptor(std::move(FPM)));
550 
551  MPM.addPass(createModuleToPostOrderCGSCCPassAdaptor(std::move(CGPipeline)));
552  }
553 
554  // Delete anything that is now dead to make sure that we don't instrument
555  // dead code. Instrumentation can end up keeping dead code around and
556  // dramatically increase code size.
557  MPM.addPass(GlobalDCEPass());
558 
559  if (RunProfileGen) {
561 
563  FPM.addPass(
565  MPM.addPass(createModuleToFunctionPassAdaptor(std::move(FPM)));
566 
567  // Add the profile lowering pass.
568  InstrProfOptions Options;
569  if (!ProfileGenFile.empty())
570  Options.InstrProfileOutput = ProfileGenFile;
571  Options.DoCounterPromotion = true;
572  MPM.addPass(InstrProfiling(Options));
573  }
574 
575  if (!ProfileUseFile.empty())
576  MPM.addPass(PGOInstrumentationUse(ProfileUseFile, ProfileRemappingFile));
577 }
578 
579 static InlineParams
581  auto O3 = PassBuilder::O3;
582  unsigned OptLevel = Level > O3 ? 2 : Level;
583  unsigned SizeLevel = Level > O3 ? Level - O3 : 0;
584  return getInlineParams(OptLevel, SizeLevel);
585 }
586 
590  bool DebugLogging) {
591  ModulePassManager MPM(DebugLogging);
592 
593  bool HasSampleProfile = PGOOpt && !PGOOpt->SampleProfileFile.empty();
594 
595  // In ThinLTO mode, when flattened profile is used, all the available
596  // profile information will be annotated in PreLink phase so there is
597  // no need to load the profile again in PostLink.
598  bool LoadSampleProfile =
599  HasSampleProfile &&
600  !(FlattenedProfileUsed && Phase == ThinLTOPhase::PostLink);
601 
602  // During the ThinLTO backend phase we perform early indirect call promotion
603  // here, before globalopt. Otherwise imported available_externally functions
604  // look unreferenced and are removed. If we are going to load the sample
605  // profile then defer until later.
606  // TODO: See if we can move later and consolidate with the location where
607  // we perform ICP when we are loading a sample profile.
608  // TODO: We pass HasSampleProfile (whether there was a sample profile file
609  // passed to the compile) to the SamplePGO flag of ICP. This is used to
610  // determine whether the new direct calls are annotated with prof metadata.
611  // Ideally this should be determined from whether the IR is annotated with
612  // sample profile, and not whether the a sample profile was provided on the
613  // command line. E.g. for flattened profiles where we will not be reloading
614  // the sample profile in the ThinLTO backend, we ideally shouldn't have to
615  // provide the sample profile file.
616  if (Phase == ThinLTOPhase::PostLink && !LoadSampleProfile)
617  MPM.addPass(PGOIndirectCallPromotion(true /* InLTO */, HasSampleProfile));
618 
619  // Do basic inference of function attributes from known properties of system
620  // libraries and other oracles.
622 
623  // Create an early function pass manager to cleanup the output of the
624  // frontend.
625  FunctionPassManager EarlyFPM(DebugLogging);
626  EarlyFPM.addPass(SimplifyCFGPass());
627  EarlyFPM.addPass(SROA());
628  EarlyFPM.addPass(EarlyCSEPass());
629  EarlyFPM.addPass(LowerExpectIntrinsicPass());
630  if (Level == O3)
631  EarlyFPM.addPass(CallSiteSplittingPass());
632 
633  // In SamplePGO ThinLTO backend, we need instcombine before profile annotation
634  // to convert bitcast to direct calls so that they can be inlined during the
635  // profile annotation prepration step.
636  // More details about SamplePGO design can be found in:
637  // https://research.google.com/pubs/pub45290.html
638  // FIXME: revisit how SampleProfileLoad/Inliner/ICP is structured.
639  if (LoadSampleProfile)
640  EarlyFPM.addPass(InstCombinePass());
641  MPM.addPass(createModuleToFunctionPassAdaptor(std::move(EarlyFPM)));
642 
643  if (LoadSampleProfile) {
644  // Annotate sample profile right after early FPM to ensure freshness of
645  // the debug info.
646  MPM.addPass(SampleProfileLoaderPass(PGOOpt->SampleProfileFile,
647  PGOOpt->ProfileRemappingFile,
648  Phase == ThinLTOPhase::PreLink));
649  // Do not invoke ICP in the ThinLTOPrelink phase as it makes it hard
650  // for the profile annotation to be accurate in the ThinLTO backend.
651  if (Phase != ThinLTOPhase::PreLink)
652  // We perform early indirect call promotion here, before globalopt.
653  // This is important for the ThinLTO backend phase because otherwise
654  // imported available_externally functions look unreferenced and are
655  // removed.
656  MPM.addPass(PGOIndirectCallPromotion(Phase == ThinLTOPhase::PostLink,
657  true /* SamplePGO */));
658  }
659 
660  // Interprocedural constant propagation now that basic cleanup has occurred
661  // and prior to optimizing globals.
662  // FIXME: This position in the pipeline hasn't been carefully considered in
663  // years, it should be re-analyzed.
664  MPM.addPass(IPSCCPPass());
665 
666  // Attach metadata to indirect call sites indicating the set of functions
667  // they may target at run-time. This should follow IPSCCP.
669 
670  // Optimize globals to try and fold them into constants.
671  MPM.addPass(GlobalOptPass());
672 
673  // Promote any localized globals to SSA registers.
674  // FIXME: Should this instead by a run of SROA?
675  // FIXME: We should probably run instcombine and simplify-cfg afterward to
676  // delete control flows that are dead once globals have been folded to
677  // constants.
679 
680  // Remove any dead arguments exposed by cleanups and constand folding
681  // globals.
683 
684  // Create a small function pass pipeline to cleanup after all the global
685  // optimizations.
686  FunctionPassManager GlobalCleanupPM(DebugLogging);
687  GlobalCleanupPM.addPass(InstCombinePass());
688  invokePeepholeEPCallbacks(GlobalCleanupPM, Level);
689 
690  GlobalCleanupPM.addPass(SimplifyCFGPass());
691  MPM.addPass(createModuleToFunctionPassAdaptor(std::move(GlobalCleanupPM)));
692 
693  // Add all the requested passes for instrumentation PGO, if requested.
694  if (PGOOpt && Phase != ThinLTOPhase::PostLink &&
695  (!PGOOpt->ProfileGenFile.empty() || !PGOOpt->ProfileUseFile.empty())) {
696  addPGOInstrPasses(MPM, DebugLogging, Level, PGOOpt->RunProfileGen,
697  PGOOpt->ProfileGenFile, PGOOpt->ProfileUseFile,
698  PGOOpt->ProfileRemappingFile);
699  MPM.addPass(PGOIndirectCallPromotion(false, false));
700  }
701 
702  // Synthesize function entry counts for non-PGO compilation.
703  if (EnableSyntheticCounts && !PGOOpt)
705 
706  // Require the GlobalsAA analysis for the module so we can query it within
707  // the CGSCC pipeline.
709 
710  // Require the ProfileSummaryAnalysis for the module so we can query it within
711  // the inliner pass.
713 
714  // Now begin the main postorder CGSCC pipeline.
715  // FIXME: The current CGSCC pipeline has its origins in the legacy pass
716  // manager and trying to emulate its precise behavior. Much of this doesn't
717  // make a lot of sense and we should revisit the core CGSCC structure.
718  CGSCCPassManager MainCGPipeline(DebugLogging);
719 
720  // Note: historically, the PruneEH pass was run first to deduce nounwind and
721  // generally clean up exception handling overhead. It isn't clear this is
722  // valuable as the inliner doesn't currently care whether it is inlining an
723  // invoke or a call.
724 
725  // Run the inliner first. The theory is that we are walking bottom-up and so
726  // the callees have already been fully optimized, and we want to inline them
727  // into the callers so that our optimizations can reflect that.
728  // For PreLinkThinLTO pass, we disable hot-caller heuristic for sample PGO
729  // because it makes profile annotation in the backend inaccurate.
731  if (Phase == ThinLTOPhase::PreLink &&
732  PGOOpt && !PGOOpt->SampleProfileFile.empty())
733  IP.HotCallSiteThreshold = 0;
734  MainCGPipeline.addPass(InlinerPass(IP));
735 
736  // Now deduce any function attributes based in the current code.
737  MainCGPipeline.addPass(PostOrderFunctionAttrsPass());
738 
739  // When at O3 add argument promotion to the pass pipeline.
740  // FIXME: It isn't at all clear why this should be limited to O3.
741  if (Level == O3)
742  MainCGPipeline.addPass(ArgumentPromotionPass());
743 
744  // Lastly, add the core function simplification pipeline nested inside the
745  // CGSCC walk.
747  buildFunctionSimplificationPipeline(Level, Phase, DebugLogging)));
748 
749  for (auto &C : CGSCCOptimizerLateEPCallbacks)
750  C(MainCGPipeline, Level);
751 
752  // We wrap the CGSCC pipeline in a devirtualization repeater. This will try
753  // to detect when we devirtualize indirect calls and iterate the SCC passes
754  // in that case to try and catch knock-on inlining or function attrs
755  // opportunities. Then we add it to the module pipeline by walking the SCCs
756  // in postorder (or bottom-up).
757  MPM.addPass(
759  std::move(MainCGPipeline), MaxDevirtIterations)));
760 
761  return MPM;
762 }
763 
765  OptimizationLevel Level, bool DebugLogging, bool LTOPreLink) {
766  ModulePassManager MPM(DebugLogging);
767 
768  // Optimize globals now that the module is fully simplified.
769  MPM.addPass(GlobalOptPass());
770  MPM.addPass(GlobalDCEPass());
771 
772  // Run partial inlining pass to partially inline functions that have
773  // large bodies.
774  if (RunPartialInlining)
776 
777  // Remove avail extern fns and globals definitions since we aren't compiling
778  // an object file for later LTO. For LTO we want to preserve these so they
779  // are eligible for inlining at link-time. Note if they are unreferenced they
780  // will be removed by GlobalDCE later, so this only impacts referenced
781  // available externally globals. Eventually they will be suppressed during
782  // codegen, but eliminating here enables more opportunity for GlobalDCE as it
783  // may make globals referenced by available external functions dead and saves
784  // running remaining passes on the eliminated functions.
786 
787  // Do RPO function attribute inference across the module to forward-propagate
788  // attributes where applicable.
789  // FIXME: Is this really an optimization rather than a canonicalization?
791 
792  // Re-require GloblasAA here prior to function passes. This is particularly
793  // useful as the above will have inlined, DCE'ed, and function-attr
794  // propagated everything. We should at this point have a reasonably minimal
795  // and richly annotated call graph. By computing aliasing and mod/ref
796  // information for all local globals here, the late loop passes and notably
797  // the vectorizer will be able to use them to help recognize vectorizable
798  // memory operations.
800 
801  FunctionPassManager OptimizePM(DebugLogging);
802  OptimizePM.addPass(Float2IntPass());
803  // FIXME: We need to run some loop optimizations to re-rotate loops after
804  // simplify-cfg and others undo their rotation.
805 
806  // Optimize the loop execution. These passes operate on entire loop nests
807  // rather than on each loop in an inside-out manner, and so they are actually
808  // function passes.
809 
810  for (auto &C : VectorizerStartEPCallbacks)
811  C(OptimizePM, Level);
812 
813  // First rotate loops that may have been un-rotated by prior passes.
814  OptimizePM.addPass(
816 
817  // Distribute loops to allow partial vectorization. I.e. isolate dependences
818  // into separate loop that would otherwise inhibit vectorization. This is
819  // currently only performed for loops marked with the metadata
820  // llvm.loop.distribute=true or when -enable-loop-distribute is specified.
821  OptimizePM.addPass(LoopDistributePass());
822 
823  // Now run the core loop vectorizer.
824  OptimizePM.addPass(LoopVectorizePass());
825 
826  // Eliminate loads by forwarding stores from the previous iteration to loads
827  // of the current iteration.
828  OptimizePM.addPass(LoopLoadEliminationPass());
829 
830  // Cleanup after the loop optimization passes.
831  OptimizePM.addPass(InstCombinePass());
832 
833  // Now that we've formed fast to execute loop structures, we do further
834  // optimizations. These are run afterward as they might block doing complex
835  // analyses and transforms such as what are needed for loop vectorization.
836 
837  // Cleanup after loop vectorization, etc. Simplification passes like CVP and
838  // GVN, loop transforms, and others have already run, so it's now better to
839  // convert to more optimized IR using more aggressive simplify CFG options.
840  // The extra sinking transform can create larger basic blocks, so do this
841  // before SLP vectorization.
843  forwardSwitchCondToPhi(true).
844  convertSwitchToLookupTable(true).
845  needCanonicalLoops(false).
846  sinkCommonInsts(true)));
847 
848  // Optimize parallel scalar instruction chains into SIMD instructions.
849  OptimizePM.addPass(SLPVectorizerPass());
850 
851  OptimizePM.addPass(InstCombinePass());
852 
853  // Unroll small loops to hide loop backedge latency and saturate any parallel
854  // execution resources of an out-of-order processor. We also then need to
855  // clean up redundancies and loop invariant code.
856  // FIXME: It would be really good to use a loop-integrated instruction
857  // combiner for cleanup here so that the unrolling and LICM can be pipelined
858  // across the loop nests.
859  // We do UnrollAndJam in a separate LPM to ensure it happens before unroll
860  if (EnableUnrollAndJam) {
861  OptimizePM.addPass(
863  }
864  OptimizePM.addPass(LoopUnrollPass(LoopUnrollOptions(Level)));
866  OptimizePM.addPass(InstCombinePass());
868  OptimizePM.addPass(createFunctionToLoopPassAdaptor(LICMPass(), DebugLogging));
869 
870  // Now that we've vectorized and unrolled loops, we may have more refined
871  // alignment information, try to re-derive it here.
873 
874  // Split out cold code. Splitting is done late to avoid hiding context from
875  // other optimizations and inadvertently regressing performance. The tradeoff
876  // is that this has a higher code size cost than splitting early.
877  if (EnableHotColdSplit && !LTOPreLink)
879 
880  // LoopSink pass sinks instructions hoisted by LICM, which serves as a
881  // canonicalization pass that enables other optimizations. As a result,
882  // LoopSink pass needs to be a very late IR pass to avoid undoing LICM
883  // result too early.
884  OptimizePM.addPass(LoopSinkPass());
885 
886  // And finally clean up LCSSA form before generating code.
887  OptimizePM.addPass(InstSimplifyPass());
888 
889  // This hoists/decomposes div/rem ops. It should run after other sink/hoist
890  // passes to avoid re-sinking, but before SimplifyCFG because it can allow
891  // flattening of blocks.
892  OptimizePM.addPass(DivRemPairsPass());
893 
894  // LoopSink (and other loop passes since the last simplifyCFG) might have
895  // resulted in single-entry-single-exit or empty blocks. Clean up the CFG.
896  OptimizePM.addPass(SimplifyCFGPass());
897 
898  // Optimize PHIs by speculating around them when profitable. Note that this
899  // pass needs to be run after any PRE or similar pass as it is essentially
900  // inserting redudnancies into the progrem. This even includes SimplifyCFG.
901  OptimizePM.addPass(SpeculateAroundPHIsPass());
902 
903  for (auto &C : OptimizerLastEPCallbacks)
904  C(OptimizePM, Level);
905 
906  // Add the core optimizing pipeline.
907  MPM.addPass(createModuleToFunctionPassAdaptor(std::move(OptimizePM)));
908 
909  MPM.addPass(CGProfilePass());
910 
911  // Now we need to do some global optimization transforms.
912  // FIXME: It would seem like these should come first in the optimization
913  // pipeline and maybe be the bottom of the canonicalization pipeline? Weird
914  // ordering here.
915  MPM.addPass(GlobalDCEPass());
916  MPM.addPass(ConstantMergePass());
917 
918  return MPM;
919 }
920 
923  bool DebugLogging, bool LTOPreLink) {
924  assert(Level != O0 && "Must request optimizations for the default pipeline!");
925 
926  ModulePassManager MPM(DebugLogging);
927 
928  // Force any function attributes we want the rest of the pipeline to observe.
930 
931  // Apply module pipeline start EP callback.
932  for (auto &C : PipelineStartEPCallbacks)
933  C(MPM);
934 
935  if (PGOOpt && PGOOpt->SamplePGOSupport)
937 
938  // Add the core simplification pipeline.
939  MPM.addPass(buildModuleSimplificationPipeline(Level, ThinLTOPhase::None,
940  DebugLogging));
941 
942  // Now add the optimization pipeline.
943  MPM.addPass(buildModuleOptimizationPipeline(Level, DebugLogging, LTOPreLink));
944 
945  return MPM;
946 }
947 
950  bool DebugLogging) {
951  assert(Level != O0 && "Must request optimizations for the default pipeline!");
952 
953  ModulePassManager MPM(DebugLogging);
954 
955  // Force any function attributes we want the rest of the pipeline to observe.
957 
958  if (PGOOpt && PGOOpt->SamplePGOSupport)
960 
961  // Apply module pipeline start EP callback.
962  for (auto &C : PipelineStartEPCallbacks)
963  C(MPM);
964 
965  // If we are planning to perform ThinLTO later, we don't bloat the code with
966  // unrolling/vectorization/... now. Just simplify the module as much as we
967  // can.
968  MPM.addPass(buildModuleSimplificationPipeline(Level, ThinLTOPhase::PreLink,
969  DebugLogging));
970 
971  // Run partial inlining pass to partially inline functions that have
972  // large bodies.
973  // FIXME: It isn't clear whether this is really the right place to run this
974  // in ThinLTO. Because there is another canonicalization and simplification
975  // phase that will run after the thin link, running this here ends up with
976  // less information than will be available later and it may grow functions in
977  // ways that aren't beneficial.
978  if (RunPartialInlining)
980 
981  // Reduce the size of the IR as much as possible.
982  MPM.addPass(GlobalOptPass());
983 
984  return MPM;
985 }
986 
988  OptimizationLevel Level, bool DebugLogging,
989  const ModuleSummaryIndex *ImportSummary) {
990  ModulePassManager MPM(DebugLogging);
991 
992  if (ImportSummary) {
993  // These passes import type identifier resolutions for whole-program
994  // devirtualization and CFI. They must run early because other passes may
995  // disturb the specific instruction patterns that these passes look for,
996  // creating dependencies on resolutions that may not appear in the summary.
997  //
998  // For example, GVN may transform the pattern assume(type.test) appearing in
999  // two basic blocks into assume(phi(type.test, type.test)), which would
1000  // transform a dependency on a WPD resolution into a dependency on a type
1001  // identifier resolution for CFI.
1002  //
1003  // Also, WPD has access to more precise information than ICP and can
1004  // devirtualize more effectively, so it should operate on the IR first.
1005  MPM.addPass(WholeProgramDevirtPass(nullptr, ImportSummary));
1006  MPM.addPass(LowerTypeTestsPass(nullptr, ImportSummary));
1007  }
1008 
1009  // Force any function attributes we want the rest of the pipeline to observe.
1011 
1012  // Add the core simplification pipeline.
1013  MPM.addPass(buildModuleSimplificationPipeline(Level, ThinLTOPhase::PostLink,
1014  DebugLogging));
1015 
1016  // Now add the optimization pipeline.
1017  MPM.addPass(buildModuleOptimizationPipeline(Level, DebugLogging));
1018 
1019  return MPM;
1020 }
1021 
1024  bool DebugLogging) {
1025  assert(Level != O0 && "Must request optimizations for the default pipeline!");
1026  // FIXME: We should use a customized pre-link pipeline!
1027  return buildPerModuleDefaultPipeline(Level, DebugLogging,
1028  /*LTOPreLink=*/true);
1029 }
1030 
1033  ModuleSummaryIndex *ExportSummary) {
1034  assert(Level != O0 && "Must request optimizations for the default pipeline!");
1035  ModulePassManager MPM(DebugLogging);
1036 
1037  if (PGOOpt && !PGOOpt->SampleProfileFile.empty()) {
1038  // Load sample profile before running the LTO optimization pipeline.
1039  MPM.addPass(SampleProfileLoaderPass(PGOOpt->SampleProfileFile,
1040  PGOOpt->ProfileRemappingFile,
1041  false /* ThinLTOPhase::PreLink */));
1042  }
1043 
1044  // Remove unused virtual tables to improve the quality of code generated by
1045  // whole-program devirtualization and bitset lowering.
1046  MPM.addPass(GlobalDCEPass());
1047 
1048  // Force any function attributes we want the rest of the pipeline to observe.
1050 
1051  // Do basic inference of function attributes from known properties of system
1052  // libraries and other oracles.
1054 
1055  if (Level > 1) {
1056  FunctionPassManager EarlyFPM(DebugLogging);
1057  EarlyFPM.addPass(CallSiteSplittingPass());
1058  MPM.addPass(createModuleToFunctionPassAdaptor(std::move(EarlyFPM)));
1059 
1060  // Indirect call promotion. This should promote all the targets that are
1061  // left by the earlier promotion pass that promotes intra-module targets.
1062  // This two-step promotion is to save the compile time. For LTO, it should
1063  // produce the same result as if we only do promotion here.
1065  true /* InLTO */, PGOOpt && !PGOOpt->SampleProfileFile.empty()));
1066  // Propagate constants at call sites into the functions they call. This
1067  // opens opportunities for globalopt (and inlining) by substituting function
1068  // pointers passed as arguments to direct uses of functions.
1069  MPM.addPass(IPSCCPPass());
1070 
1071  // Attach metadata to indirect call sites indicating the set of functions
1072  // they may target at run-time. This should follow IPSCCP.
1074  }
1075 
1076  // Now deduce any function attributes based in the current code.
1079 
1080  // Do RPO function attribute inference across the module to forward-propagate
1081  // attributes where applicable.
1082  // FIXME: Is this really an optimization rather than a canonicalization?
1084 
1085  // Use inragne annotations on GEP indices to split globals where beneficial.
1086  MPM.addPass(GlobalSplitPass());
1087 
1088  // Run whole program optimization of virtual call when the list of callees
1089  // is fixed.
1090  MPM.addPass(WholeProgramDevirtPass(ExportSummary, nullptr));
1091 
1092  // Stop here at -O1.
1093  if (Level == 1) {
1094  // The LowerTypeTestsPass needs to run to lower type metadata and the
1095  // type.test intrinsics. The pass does nothing if CFI is disabled.
1096  MPM.addPass(LowerTypeTestsPass(ExportSummary, nullptr));
1097  return MPM;
1098  }
1099 
1100  // Optimize globals to try and fold them into constants.
1101  MPM.addPass(GlobalOptPass());
1102 
1103  // Promote any localized globals to SSA registers.
1105 
1106  // Linking modules together can lead to duplicate global constant, only
1107  // keep one copy of each constant.
1108  MPM.addPass(ConstantMergePass());
1109 
1110  // Remove unused arguments from functions.
1112 
1113  // Reduce the code after globalopt and ipsccp. Both can open up significant
1114  // simplification opportunities, and both can propagate functions through
1115  // function pointers. When this happens, we often have to resolve varargs
1116  // calls, etc, so let instcombine do this.
1117  FunctionPassManager PeepholeFPM(DebugLogging);
1118  if (Level == O3)
1119  PeepholeFPM.addPass(AggressiveInstCombinePass());
1120  PeepholeFPM.addPass(InstCombinePass());
1121  invokePeepholeEPCallbacks(PeepholeFPM, Level);
1122 
1123  MPM.addPass(createModuleToFunctionPassAdaptor(std::move(PeepholeFPM)));
1124 
1125  // Note: historically, the PruneEH pass was run first to deduce nounwind and
1126  // generally clean up exception handling overhead. It isn't clear this is
1127  // valuable as the inliner doesn't currently care whether it is inlining an
1128  // invoke or a call.
1129  // Run the inliner now.
1132 
1133  // Optimize globals again after we ran the inliner.
1134  MPM.addPass(GlobalOptPass());
1135 
1136  // Garbage collect dead functions.
1137  // FIXME: Add ArgumentPromotion pass after once it's ported.
1138  MPM.addPass(GlobalDCEPass());
1139 
1140  FunctionPassManager FPM(DebugLogging);
1141  // The IPO Passes may leave cruft around. Clean up after them.
1142  FPM.addPass(InstCombinePass());
1143  invokePeepholeEPCallbacks(FPM, Level);
1144 
1145  FPM.addPass(JumpThreadingPass());
1146 
1147  // Break up allocas
1148  FPM.addPass(SROA());
1149 
1150  // Run a few AA driver optimizations here and now to cleanup the code.
1151  MPM.addPass(createModuleToFunctionPassAdaptor(std::move(FPM)));
1152 
1155  // FIXME: here we run IP alias analysis in the legacy PM.
1156 
1157  FunctionPassManager MainFPM;
1158 
1159  // FIXME: once we fix LoopPass Manager, add LICM here.
1160  // FIXME: once we provide support for enabling MLSM, add it here.
1161  // FIXME: once we provide support for enabling NewGVN, add it here.
1162  if (RunNewGVN)
1163  MainFPM.addPass(NewGVNPass());
1164  else
1165  MainFPM.addPass(GVN());
1166 
1167  // Remove dead memcpy()'s.
1168  MainFPM.addPass(MemCpyOptPass());
1169 
1170  // Nuke dead stores.
1171  MainFPM.addPass(DSEPass());
1172 
1173  // FIXME: at this point, we run a bunch of loop passes:
1174  // indVarSimplify, loopDeletion, loopInterchange, loopUnrool,
1175  // loopVectorize. Enable them once the remaining issue with LPM
1176  // are sorted out.
1177 
1178  MainFPM.addPass(InstCombinePass());
1179  MainFPM.addPass(SimplifyCFGPass());
1180  MainFPM.addPass(SCCPPass());
1181  MainFPM.addPass(InstCombinePass());
1182  MainFPM.addPass(BDCEPass());
1183 
1184  // FIXME: We may want to run SLPVectorizer here.
1185  // After vectorization, assume intrinsics may tell us more
1186  // about pointer alignments.
1187 #if 0
1188  MainFPM.add(AlignmentFromAssumptionsPass());
1189 #endif
1190 
1191  // FIXME: Conditionally run LoadCombine here, after it's ported
1192  // (in case we still have this pass, given its questionable usefulness).
1193 
1194  MainFPM.addPass(InstCombinePass());
1195  invokePeepholeEPCallbacks(MainFPM, Level);
1196  MainFPM.addPass(JumpThreadingPass());
1197  MPM.addPass(createModuleToFunctionPassAdaptor(std::move(MainFPM)));
1198 
1199  // Create a function that performs CFI checks for cross-DSO calls with
1200  // targets in the current module.
1201  MPM.addPass(CrossDSOCFIPass());
1202 
1203  // Lower type metadata and the type.test intrinsic. This pass supports
1204  // clang's control flow integrity mechanisms (-fsanitize=cfi*) and needs
1205  // to be run at link time if CFI is enabled. This pass does nothing if
1206  // CFI is disabled.
1207  MPM.addPass(LowerTypeTestsPass(ExportSummary, nullptr));
1208 
1209  // Enable splitting late in the FullLTO post-link pipeline. This is done in
1210  // the same stage in the old pass manager (\ref addLateLTOOptimizationPasses).
1211  if (EnableHotColdSplit)
1213 
1214  // Add late LTO optimization passes.
1215  // Delete basic blocks, which optimization passes may have killed.
1217 
1218  // Drop bodies of available eternally objects to improve GlobalDCE.
1220 
1221  // Now that we have optimized the program, discard unreachable functions.
1222  MPM.addPass(GlobalDCEPass());
1223 
1224  // FIXME: Enable MergeFuncs, conditionally, after ported, maybe.
1225  return MPM;
1226 }
1227 
1229  AAManager AA;
1230 
1231  // The order in which these are registered determines their priority when
1232  // being queried.
1233 
1234  // First we register the basic alias analysis that provides the majority of
1235  // per-function local AA logic. This is a stateless, on-demand local set of
1236  // AA techniques.
1238 
1239  // Next we query fast, specialized alias analyses that wrap IR-embedded
1240  // information about aliasing.
1243 
1244  // Add support for querying global aliasing information when available.
1245  // Because the `AAManager` is a function analysis and `GlobalsAA` is a module
1246  // analysis, all that the `AAManager` can do is query for any *cached*
1247  // results from `GlobalsAA` through a readonly proxy.
1249 
1250  return AA;
1251 }
1252 
1254  if (!Name.consume_front("repeat<") || !Name.consume_back(">"))
1255  return None;
1256  int Count;
1257  if (Name.getAsInteger(0, Count) || Count <= 0)
1258  return None;
1259  return Count;
1260 }
1261 
1263  if (!Name.consume_front("devirt<") || !Name.consume_back(">"))
1264  return None;
1265  int Count;
1266  if (Name.getAsInteger(0, Count) || Count <= 0)
1267  return None;
1268  return Count;
1269 }
1270 
1272  if (!Name.consume_front(PassName))
1273  return false;
1274  // normal pass name w/o parameters == default parameters
1275  if (Name.empty())
1276  return true;
1277  return Name.startswith("<") && Name.endswith(">");
1278 }
1279 
1280 namespace {
1281 
1282 /// This performs customized parsing of pass name with parameters.
1283 ///
1284 /// We do not need parametrization of passes in textual pipeline very often,
1285 /// yet on a rare occasion ability to specify parameters right there can be
1286 /// useful.
1287 ///
1288 /// \p Name - parameterized specification of a pass from a textual pipeline
1289 /// is a string in a form of :
1290 /// PassName '<' parameter-list '>'
1291 ///
1292 /// Parameter list is being parsed by the parser callable argument, \p Parser,
1293 /// It takes a string-ref of parameters and returns either StringError or a
1294 /// parameter list in a form of a custom parameters type, all wrapped into
1295 /// Expected<> template class.
1296 ///
1297 template <typename ParametersParseCallableT>
1298 auto parsePassParameters(ParametersParseCallableT &&Parser, StringRef Name,
1299  StringRef PassName) -> decltype(Parser(StringRef{})) {
1300  using ParametersT = typename decltype(Parser(StringRef{}))::value_type;
1301 
1302  StringRef Params = Name;
1303  if (!Params.consume_front(PassName)) {
1304  assert(false &&
1305  "unable to strip pass name from parametrized pass specification");
1306  }
1307  if (Params.empty())
1308  return ParametersT{};
1309  if (!Params.consume_front("<") || !Params.consume_back(">")) {
1310  assert(false && "invalid format for parametrized pass name");
1311  }
1312 
1313  Expected<ParametersT> Result = Parser(Params);
1314  assert((Result || Result.template errorIsA<StringError>()) &&
1315  "Pass parameter parser can only return StringErrors.");
1316  return std::move(Result);
1317 }
1318 
1319 /// Parser of parameters for LoopUnroll pass.
1320 Expected<LoopUnrollOptions> parseLoopUnrollOptions(StringRef Params) {
1321  LoopUnrollOptions UnrollOpts;
1322  while (!Params.empty()) {
1323  StringRef ParamName;
1324  std::tie(ParamName, Params) = Params.split(';');
1325  int OptLevel = StringSwitch<int>(ParamName)
1326  .Case("O0", 0)
1327  .Case("O1", 1)
1328  .Case("O2", 2)
1329  .Case("O3", 3)
1330  .Default(-1);
1331  if (OptLevel >= 0) {
1332  UnrollOpts.setOptLevel(OptLevel);
1333  continue;
1334  }
1335 
1336  bool Enable = !ParamName.consume_front("no-");
1337  if (ParamName == "partial") {
1338  UnrollOpts.setPartial(Enable);
1339  } else if (ParamName == "peeling") {
1340  UnrollOpts.setPeeling(Enable);
1341  } else if (ParamName == "runtime") {
1342  UnrollOpts.setRuntime(Enable);
1343  } else if (ParamName == "upperbound") {
1344  UnrollOpts.setUpperBound(Enable);
1345  } else {
1346  return make_error<StringError>(
1347  formatv("invalid LoopUnrollPass parameter '{0}' ", ParamName).str(),
1349  }
1350  }
1351  return UnrollOpts;
1352 }
1353 
1354 Expected<MemorySanitizerOptions> parseMSanPassOptions(StringRef Params) {
1355  MemorySanitizerOptions Result;
1356  while (!Params.empty()) {
1357  StringRef ParamName;
1358  std::tie(ParamName, Params) = Params.split(';');
1359 
1360  if (ParamName == "recover") {
1361  Result.Recover = true;
1362  } else if (ParamName == "kernel") {
1363  Result.Kernel = true;
1364  } else if (ParamName.consume_front("track-origins=")) {
1365  if (ParamName.getAsInteger(0, Result.TrackOrigins))
1366  return make_error<StringError>(
1367  formatv("invalid argument to MemorySanitizer pass track-origins "
1368  "parameter: '{0}' ",
1369  ParamName)
1370  .str(),
1372  } else {
1373  return make_error<StringError>(
1374  formatv("invalid MemorySanitizer pass parameter '{0}' ", ParamName)
1375  .str(),
1377  }
1378  }
1379  return Result;
1380 }
1381 
1382 } // namespace
1383 
1384 /// Tests whether a pass name starts with a valid prefix for a default pipeline
1385 /// alias.
1387  return Name.startswith("default") || Name.startswith("thinlto") ||
1388  Name.startswith("lto");
1389 }
1390 
1391 /// Tests whether registered callbacks will accept a given pass name.
1392 ///
1393 /// When parsing a pipeline text, the type of the outermost pipeline may be
1394 /// omitted, in which case the type is automatically determined from the first
1395 /// pass name in the text. This may be a name that is handled through one of the
1396 /// callbacks. We check this through the oridinary parsing callbacks by setting
1397 /// up a dummy PassManager in order to not force the client to also handle this
1398 /// type of query.
1399 template <typename PassManagerT, typename CallbacksT>
1400 static bool callbacksAcceptPassName(StringRef Name, CallbacksT &Callbacks) {
1401  if (!Callbacks.empty()) {
1402  PassManagerT DummyPM;
1403  for (auto &CB : Callbacks)
1404  if (CB(Name, DummyPM, {}))
1405  return true;
1406  }
1407  return false;
1408 }
1409 
1410 template <typename CallbacksT>
1411 static bool isModulePassName(StringRef Name, CallbacksT &Callbacks) {
1412  // Manually handle aliases for pre-configured pipeline fragments.
1414  return DefaultAliasRegex.match(Name);
1415 
1416  // Explicitly handle pass manager names.
1417  if (Name == "module")
1418  return true;
1419  if (Name == "cgscc")
1420  return true;
1421  if (Name == "function")
1422  return true;
1423 
1424  // Explicitly handle custom-parsed pass names.
1425  if (parseRepeatPassName(Name))
1426  return true;
1427 
1428 #define MODULE_PASS(NAME, CREATE_PASS) \
1429  if (Name == NAME) \
1430  return true;
1431 #define MODULE_ANALYSIS(NAME, CREATE_PASS) \
1432  if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
1433  return true;
1434 #include "PassRegistry.def"
1435 
1436  return callbacksAcceptPassName<ModulePassManager>(Name, Callbacks);
1437 }
1438 
1439 template <typename CallbacksT>
1440 static bool isCGSCCPassName(StringRef Name, CallbacksT &Callbacks) {
1441  // Explicitly handle pass manager names.
1442  if (Name == "cgscc")
1443  return true;
1444  if (Name == "function")
1445  return true;
1446 
1447  // Explicitly handle custom-parsed pass names.
1448  if (parseRepeatPassName(Name))
1449  return true;
1450  if (parseDevirtPassName(Name))
1451  return true;
1452 
1453 #define CGSCC_PASS(NAME, CREATE_PASS) \
1454  if (Name == NAME) \
1455  return true;
1456 #define CGSCC_ANALYSIS(NAME, CREATE_PASS) \
1457  if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
1458  return true;
1459 #include "PassRegistry.def"
1460 
1461  return callbacksAcceptPassName<CGSCCPassManager>(Name, Callbacks);
1462 }
1463 
1464 template <typename CallbacksT>
1465 static bool isFunctionPassName(StringRef Name, CallbacksT &Callbacks) {
1466  // Explicitly handle pass manager names.
1467  if (Name == "function")
1468  return true;
1469  if (Name == "loop")
1470  return true;
1471 
1472  // Explicitly handle custom-parsed pass names.
1473  if (parseRepeatPassName(Name))
1474  return true;
1475 
1476 #define FUNCTION_PASS(NAME, CREATE_PASS) \
1477  if (Name == NAME) \
1478  return true;
1479 #define FUNCTION_PASS_WITH_PARAMS(NAME, CREATE_PASS, PARSER) \
1480  if (checkParametrizedPassName(Name, NAME)) \
1481  return true;
1482 #define FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
1483  if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
1484  return true;
1485 #include "PassRegistry.def"
1486 
1487  return callbacksAcceptPassName<FunctionPassManager>(Name, Callbacks);
1488 }
1489 
1490 template <typename CallbacksT>
1491 static bool isLoopPassName(StringRef Name, CallbacksT &Callbacks) {
1492  // Explicitly handle pass manager names.
1493  if (Name == "loop")
1494  return true;
1495 
1496  // Explicitly handle custom-parsed pass names.
1497  if (parseRepeatPassName(Name))
1498  return true;
1499 
1500 #define LOOP_PASS(NAME, CREATE_PASS) \
1501  if (Name == NAME) \
1502  return true;
1503 #define LOOP_ANALYSIS(NAME, CREATE_PASS) \
1504  if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
1505  return true;
1506 #include "PassRegistry.def"
1507 
1508  return callbacksAcceptPassName<LoopPassManager>(Name, Callbacks);
1509 }
1510 
1512 PassBuilder::parsePipelineText(StringRef Text) {
1513  std::vector<PipelineElement> ResultPipeline;
1514 
1515  SmallVector<std::vector<PipelineElement> *, 4> PipelineStack = {
1516  &ResultPipeline};
1517  for (;;) {
1518  std::vector<PipelineElement> &Pipeline = *PipelineStack.back();
1519  size_t Pos = Text.find_first_of(",()");
1520  Pipeline.push_back({Text.substr(0, Pos), {}});
1521 
1522  // If we have a single terminating name, we're done.
1523  if (Pos == Text.npos)
1524  break;
1525 
1526  char Sep = Text[Pos];
1527  Text = Text.substr(Pos + 1);
1528  if (Sep == ',')
1529  // Just a name ending in a comma, continue.
1530  continue;
1531 
1532  if (Sep == '(') {
1533  // Push the inner pipeline onto the stack to continue processing.
1534  PipelineStack.push_back(&Pipeline.back().InnerPipeline);
1535  continue;
1536  }
1537 
1538  assert(Sep == ')' && "Bogus separator!");
1539  // When handling the close parenthesis, we greedily consume them to avoid
1540  // empty strings in the pipeline.
1541  do {
1542  // If we try to pop the outer pipeline we have unbalanced parentheses.
1543  if (PipelineStack.size() == 1)
1544  return None;
1545 
1546  PipelineStack.pop_back();
1547  } while (Text.consume_front(")"));
1548 
1549  // Check if we've finished parsing.
1550  if (Text.empty())
1551  break;
1552 
1553  // Otherwise, the end of an inner pipeline always has to be followed by
1554  // a comma, and then we can continue.
1555  if (!Text.consume_front(","))
1556  return None;
1557  }
1558 
1559  if (PipelineStack.size() > 1)
1560  // Unbalanced paretheses.
1561  return None;
1562 
1563  assert(PipelineStack.back() == &ResultPipeline &&
1564  "Wrong pipeline at the bottom of the stack!");
1565  return {std::move(ResultPipeline)};
1566 }
1567 
1568 Error PassBuilder::parseModulePass(ModulePassManager &MPM,
1569  const PipelineElement &E,
1570  bool VerifyEachPass, bool DebugLogging) {
1571  auto &Name = E.Name;
1572  auto &InnerPipeline = E.InnerPipeline;
1573 
1574  // First handle complex passes like the pass managers which carry pipelines.
1575  if (!InnerPipeline.empty()) {
1576  if (Name == "module") {
1577  ModulePassManager NestedMPM(DebugLogging);
1578  if (auto Err = parseModulePassPipeline(NestedMPM, InnerPipeline,
1579  VerifyEachPass, DebugLogging))
1580  return Err;
1581  MPM.addPass(std::move(NestedMPM));
1582  return Error::success();
1583  }
1584  if (Name == "cgscc") {
1585  CGSCCPassManager CGPM(DebugLogging);
1586  if (auto Err = parseCGSCCPassPipeline(CGPM, InnerPipeline, VerifyEachPass,
1587  DebugLogging))
1588  return Err;
1589  MPM.addPass(createModuleToPostOrderCGSCCPassAdaptor(std::move(CGPM)));
1590  return Error::success();
1591  }
1592  if (Name == "function") {
1593  FunctionPassManager FPM(DebugLogging);
1594  if (auto Err = parseFunctionPassPipeline(FPM, InnerPipeline,
1595  VerifyEachPass, DebugLogging))
1596  return Err;
1597  MPM.addPass(createModuleToFunctionPassAdaptor(std::move(FPM)));
1598  return Error::success();
1599  }
1600  if (auto Count = parseRepeatPassName(Name)) {
1601  ModulePassManager NestedMPM(DebugLogging);
1602  if (auto Err = parseModulePassPipeline(NestedMPM, InnerPipeline,
1603  VerifyEachPass, DebugLogging))
1604  return Err;
1605  MPM.addPass(createRepeatedPass(*Count, std::move(NestedMPM)));
1606  return Error::success();
1607  }
1608 
1609  for (auto &C : ModulePipelineParsingCallbacks)
1610  if (C(Name, MPM, InnerPipeline))
1611  return Error::success();
1612 
1613  // Normal passes can't have pipelines.
1614  return make_error<StringError>(
1615  formatv("invalid use of '{0}' pass as module pipeline", Name).str(),
1617  ;
1618  }
1619 
1620  // Manually handle aliases for pre-configured pipeline fragments.
1622  SmallVector<StringRef, 3> Matches;
1623  if (!DefaultAliasRegex.match(Name, &Matches))
1624  return make_error<StringError>(
1625  formatv("unknown default pipeline alias '{0}'", Name).str(),
1627 
1628  assert(Matches.size() == 3 && "Must capture two matched strings!");
1629 
1630  OptimizationLevel L = StringSwitch<OptimizationLevel>(Matches[2])
1631  .Case("O0", O0)
1632  .Case("O1", O1)
1633  .Case("O2", O2)
1634  .Case("O3", O3)
1635  .Case("Os", Os)
1636  .Case("Oz", Oz);
1637  if (L == O0)
1638  // At O0 we do nothing at all!
1639  return Error::success();
1640 
1641  if (Matches[1] == "default") {
1642  MPM.addPass(buildPerModuleDefaultPipeline(L, DebugLogging));
1643  } else if (Matches[1] == "thinlto-pre-link") {
1644  MPM.addPass(buildThinLTOPreLinkDefaultPipeline(L, DebugLogging));
1645  } else if (Matches[1] == "thinlto") {
1646  MPM.addPass(buildThinLTODefaultPipeline(L, DebugLogging, nullptr));
1647  } else if (Matches[1] == "lto-pre-link") {
1648  MPM.addPass(buildLTOPreLinkDefaultPipeline(L, DebugLogging));
1649  } else {
1650  assert(Matches[1] == "lto" && "Not one of the matched options!");
1651  MPM.addPass(buildLTODefaultPipeline(L, DebugLogging, nullptr));
1652  }
1653  return Error::success();
1654  }
1655 
1656  // Finally expand the basic registered passes from the .inc file.
1657 #define MODULE_PASS(NAME, CREATE_PASS) \
1658  if (Name == NAME) { \
1659  MPM.addPass(CREATE_PASS); \
1660  return Error::success(); \
1661  }
1662 #define MODULE_ANALYSIS(NAME, CREATE_PASS) \
1663  if (Name == "require<" NAME ">") { \
1664  MPM.addPass( \
1665  RequireAnalysisPass< \
1666  std::remove_reference<decltype(CREATE_PASS)>::type, Module>()); \
1667  return Error::success(); \
1668  } \
1669  if (Name == "invalidate<" NAME ">") { \
1670  MPM.addPass(InvalidateAnalysisPass< \
1671  std::remove_reference<decltype(CREATE_PASS)>::type>()); \
1672  return Error::success(); \
1673  }
1674 #include "PassRegistry.def"
1675 
1676  for (auto &C : ModulePipelineParsingCallbacks)
1677  if (C(Name, MPM, InnerPipeline))
1678  return Error::success();
1679  return make_error<StringError>(
1680  formatv("unknown module pass '{0}'", Name).str(),
1682 }
1683 
1684 Error PassBuilder::parseCGSCCPass(CGSCCPassManager &CGPM,
1685  const PipelineElement &E, bool VerifyEachPass,
1686  bool DebugLogging) {
1687  auto &Name = E.Name;
1688  auto &InnerPipeline = E.InnerPipeline;
1689 
1690  // First handle complex passes like the pass managers which carry pipelines.
1691  if (!InnerPipeline.empty()) {
1692  if (Name == "cgscc") {
1693  CGSCCPassManager NestedCGPM(DebugLogging);
1694  if (auto Err = parseCGSCCPassPipeline(NestedCGPM, InnerPipeline,
1695  VerifyEachPass, DebugLogging))
1696  return Err;
1697  // Add the nested pass manager with the appropriate adaptor.
1698  CGPM.addPass(std::move(NestedCGPM));
1699  return Error::success();
1700  }
1701  if (Name == "function") {
1702  FunctionPassManager FPM(DebugLogging);
1703  if (auto Err = parseFunctionPassPipeline(FPM, InnerPipeline,
1704  VerifyEachPass, DebugLogging))
1705  return Err;
1706  // Add the nested pass manager with the appropriate adaptor.
1707  CGPM.addPass(createCGSCCToFunctionPassAdaptor(std::move(FPM)));
1708  return Error::success();
1709  }
1710  if (auto Count = parseRepeatPassName(Name)) {
1711  CGSCCPassManager NestedCGPM(DebugLogging);
1712  if (auto Err = parseCGSCCPassPipeline(NestedCGPM, InnerPipeline,
1713  VerifyEachPass, DebugLogging))
1714  return Err;
1715  CGPM.addPass(createRepeatedPass(*Count, std::move(NestedCGPM)));
1716  return Error::success();
1717  }
1718  if (auto MaxRepetitions = parseDevirtPassName(Name)) {
1719  CGSCCPassManager NestedCGPM(DebugLogging);
1720  if (auto Err = parseCGSCCPassPipeline(NestedCGPM, InnerPipeline,
1721  VerifyEachPass, DebugLogging))
1722  return Err;
1723  CGPM.addPass(
1724  createDevirtSCCRepeatedPass(std::move(NestedCGPM), *MaxRepetitions));
1725  return Error::success();
1726  }
1727 
1728  for (auto &C : CGSCCPipelineParsingCallbacks)
1729  if (C(Name, CGPM, InnerPipeline))
1730  return Error::success();
1731 
1732  // Normal passes can't have pipelines.
1733  return make_error<StringError>(
1734  formatv("invalid use of '{0}' pass as cgscc pipeline", Name).str(),
1736  }
1737 
1738 // Now expand the basic registered passes from the .inc file.
1739 #define CGSCC_PASS(NAME, CREATE_PASS) \
1740  if (Name == NAME) { \
1741  CGPM.addPass(CREATE_PASS); \
1742  return Error::success(); \
1743  }
1744 #define CGSCC_ANALYSIS(NAME, CREATE_PASS) \
1745  if (Name == "require<" NAME ">") { \
1746  CGPM.addPass(RequireAnalysisPass< \
1747  std::remove_reference<decltype(CREATE_PASS)>::type, \
1748  LazyCallGraph::SCC, CGSCCAnalysisManager, LazyCallGraph &, \
1749  CGSCCUpdateResult &>()); \
1750  return Error::success(); \
1751  } \
1752  if (Name == "invalidate<" NAME ">") { \
1753  CGPM.addPass(InvalidateAnalysisPass< \
1754  std::remove_reference<decltype(CREATE_PASS)>::type>()); \
1755  return Error::success(); \
1756  }
1757 #include "PassRegistry.def"
1758 
1759  for (auto &C : CGSCCPipelineParsingCallbacks)
1760  if (C(Name, CGPM, InnerPipeline))
1761  return Error::success();
1762  return make_error<StringError>(
1763  formatv("unknown cgscc pass '{0}'", Name).str(),
1765 }
1766 
1767 Error PassBuilder::parseFunctionPass(FunctionPassManager &FPM,
1768  const PipelineElement &E,
1769  bool VerifyEachPass, bool DebugLogging) {
1770  auto &Name = E.Name;
1771  auto &InnerPipeline = E.InnerPipeline;
1772 
1773  // First handle complex passes like the pass managers which carry pipelines.
1774  if (!InnerPipeline.empty()) {
1775  if (Name == "function") {
1776  FunctionPassManager NestedFPM(DebugLogging);
1777  if (auto Err = parseFunctionPassPipeline(NestedFPM, InnerPipeline,
1778  VerifyEachPass, DebugLogging))
1779  return Err;
1780  // Add the nested pass manager with the appropriate adaptor.
1781  FPM.addPass(std::move(NestedFPM));
1782  return Error::success();
1783  }
1784  if (Name == "loop") {
1785  LoopPassManager LPM(DebugLogging);
1786  if (auto Err = parseLoopPassPipeline(LPM, InnerPipeline, VerifyEachPass,
1787  DebugLogging))
1788  return Err;
1789  // Add the nested pass manager with the appropriate adaptor.
1790  FPM.addPass(
1791  createFunctionToLoopPassAdaptor(std::move(LPM), DebugLogging));
1792  return Error::success();
1793  }
1794  if (auto Count = parseRepeatPassName(Name)) {
1795  FunctionPassManager NestedFPM(DebugLogging);
1796  if (auto Err = parseFunctionPassPipeline(NestedFPM, InnerPipeline,
1797  VerifyEachPass, DebugLogging))
1798  return Err;
1799  FPM.addPass(createRepeatedPass(*Count, std::move(NestedFPM)));
1800  return Error::success();
1801  }
1802 
1803  for (auto &C : FunctionPipelineParsingCallbacks)
1804  if (C(Name, FPM, InnerPipeline))
1805  return Error::success();
1806 
1807  // Normal passes can't have pipelines.
1808  return make_error<StringError>(
1809  formatv("invalid use of '{0}' pass as function pipeline", Name).str(),
1811  }
1812 
1813 // Now expand the basic registered passes from the .inc file.
1814 #define FUNCTION_PASS(NAME, CREATE_PASS) \
1815  if (Name == NAME) { \
1816  FPM.addPass(CREATE_PASS); \
1817  return Error::success(); \
1818  }
1819 #define FUNCTION_PASS_WITH_PARAMS(NAME, CREATE_PASS, PARSER) \
1820  if (checkParametrizedPassName(Name, NAME)) { \
1821  auto Params = parsePassParameters(PARSER, Name, NAME); \
1822  if (!Params) \
1823  return Params.takeError(); \
1824  FPM.addPass(CREATE_PASS(Params.get())); \
1825  return Error::success(); \
1826  }
1827 #define FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
1828  if (Name == "require<" NAME ">") { \
1829  FPM.addPass( \
1830  RequireAnalysisPass< \
1831  std::remove_reference<decltype(CREATE_PASS)>::type, Function>()); \
1832  return Error::success(); \
1833  } \
1834  if (Name == "invalidate<" NAME ">") { \
1835  FPM.addPass(InvalidateAnalysisPass< \
1836  std::remove_reference<decltype(CREATE_PASS)>::type>()); \
1837  return Error::success(); \
1838  }
1839 #include "PassRegistry.def"
1840 
1841  for (auto &C : FunctionPipelineParsingCallbacks)
1842  if (C(Name, FPM, InnerPipeline))
1843  return Error::success();
1844  return make_error<StringError>(
1845  formatv("unknown function pass '{0}'", Name).str(),
1847 }
1848 
1849 Error PassBuilder::parseLoopPass(LoopPassManager &LPM, const PipelineElement &E,
1850  bool VerifyEachPass, bool DebugLogging) {
1851  StringRef Name = E.Name;
1852  auto &InnerPipeline = E.InnerPipeline;
1853 
1854  // First handle complex passes like the pass managers which carry pipelines.
1855  if (!InnerPipeline.empty()) {
1856  if (Name == "loop") {
1857  LoopPassManager NestedLPM(DebugLogging);
1858  if (auto Err = parseLoopPassPipeline(NestedLPM, InnerPipeline,
1859  VerifyEachPass, DebugLogging))
1860  return Err;
1861  // Add the nested pass manager with the appropriate adaptor.
1862  LPM.addPass(std::move(NestedLPM));
1863  return Error::success();
1864  }
1865  if (auto Count = parseRepeatPassName(Name)) {
1866  LoopPassManager NestedLPM(DebugLogging);
1867  if (auto Err = parseLoopPassPipeline(NestedLPM, InnerPipeline,
1868  VerifyEachPass, DebugLogging))
1869  return Err;
1870  LPM.addPass(createRepeatedPass(*Count, std::move(NestedLPM)));
1871  return Error::success();
1872  }
1873 
1874  for (auto &C : LoopPipelineParsingCallbacks)
1875  if (C(Name, LPM, InnerPipeline))
1876  return Error::success();
1877 
1878  // Normal passes can't have pipelines.
1879  return make_error<StringError>(
1880  formatv("invalid use of '{0}' pass as loop pipeline", Name).str(),
1882  }
1883 
1884 // Now expand the basic registered passes from the .inc file.
1885 #define LOOP_PASS(NAME, CREATE_PASS) \
1886  if (Name == NAME) { \
1887  LPM.addPass(CREATE_PASS); \
1888  return Error::success(); \
1889  }
1890 #define LOOP_ANALYSIS(NAME, CREATE_PASS) \
1891  if (Name == "require<" NAME ">") { \
1892  LPM.addPass(RequireAnalysisPass< \
1893  std::remove_reference<decltype(CREATE_PASS)>::type, Loop, \
1894  LoopAnalysisManager, LoopStandardAnalysisResults &, \
1895  LPMUpdater &>()); \
1896  return Error::success(); \
1897  } \
1898  if (Name == "invalidate<" NAME ">") { \
1899  LPM.addPass(InvalidateAnalysisPass< \
1900  std::remove_reference<decltype(CREATE_PASS)>::type>()); \
1901  return Error::success(); \
1902  }
1903 #include "PassRegistry.def"
1904 
1905  for (auto &C : LoopPipelineParsingCallbacks)
1906  if (C(Name, LPM, InnerPipeline))
1907  return Error::success();
1908  return make_error<StringError>(formatv("unknown loop pass '{0}'", Name).str(),
1910 }
1911 
1912 bool PassBuilder::parseAAPassName(AAManager &AA, StringRef Name) {
1913 #define MODULE_ALIAS_ANALYSIS(NAME, CREATE_PASS) \
1914  if (Name == NAME) { \
1915  AA.registerModuleAnalysis< \
1916  std::remove_reference<decltype(CREATE_PASS)>::type>(); \
1917  return true; \
1918  }
1919 #define FUNCTION_ALIAS_ANALYSIS(NAME, CREATE_PASS) \
1920  if (Name == NAME) { \
1921  AA.registerFunctionAnalysis< \
1922  std::remove_reference<decltype(CREATE_PASS)>::type>(); \
1923  return true; \
1924  }
1925 #include "PassRegistry.def"
1926 
1927  for (auto &C : AAParsingCallbacks)
1928  if (C(Name, AA))
1929  return true;
1930  return false;
1931 }
1932 
1933 Error PassBuilder::parseLoopPassPipeline(LoopPassManager &LPM,
1934  ArrayRef<PipelineElement> Pipeline,
1935  bool VerifyEachPass,
1936  bool DebugLogging) {
1937  for (const auto &Element : Pipeline) {
1938  if (auto Err = parseLoopPass(LPM, Element, VerifyEachPass, DebugLogging))
1939  return Err;
1940  // FIXME: No verifier support for Loop passes!
1941  }
1942  return Error::success();
1943 }
1944 
1945 Error PassBuilder::parseFunctionPassPipeline(FunctionPassManager &FPM,
1946  ArrayRef<PipelineElement> Pipeline,
1947  bool VerifyEachPass,
1948  bool DebugLogging) {
1949  for (const auto &Element : Pipeline) {
1950  if (auto Err =
1951  parseFunctionPass(FPM, Element, VerifyEachPass, DebugLogging))
1952  return Err;
1953  if (VerifyEachPass)
1954  FPM.addPass(VerifierPass());
1955  }
1956  return Error::success();
1957 }
1958 
1959 Error PassBuilder::parseCGSCCPassPipeline(CGSCCPassManager &CGPM,
1960  ArrayRef<PipelineElement> Pipeline,
1961  bool VerifyEachPass,
1962  bool DebugLogging) {
1963  for (const auto &Element : Pipeline) {
1964  if (auto Err = parseCGSCCPass(CGPM, Element, VerifyEachPass, DebugLogging))
1965  return Err;
1966  // FIXME: No verifier support for CGSCC passes!
1967  }
1968  return Error::success();
1969 }
1970 
1973  CGSCCAnalysisManager &CGAM,
1974  ModuleAnalysisManager &MAM) {
1975  MAM.registerPass([&] { return FunctionAnalysisManagerModuleProxy(FAM); });
1976  MAM.registerPass([&] { return CGSCCAnalysisManagerModuleProxy(CGAM); });
1977  CGAM.registerPass([&] { return ModuleAnalysisManagerCGSCCProxy(MAM); });
1978  FAM.registerPass([&] { return CGSCCAnalysisManagerFunctionProxy(CGAM); });
1979  FAM.registerPass([&] { return ModuleAnalysisManagerFunctionProxy(MAM); });
1980  FAM.registerPass([&] { return LoopAnalysisManagerFunctionProxy(LAM); });
1981  LAM.registerPass([&] { return FunctionAnalysisManagerLoopProxy(FAM); });
1982 }
1983 
1984 Error PassBuilder::parseModulePassPipeline(ModulePassManager &MPM,
1985  ArrayRef<PipelineElement> Pipeline,
1986  bool VerifyEachPass,
1987  bool DebugLogging) {
1988  for (const auto &Element : Pipeline) {
1989  if (auto Err = parseModulePass(MPM, Element, VerifyEachPass, DebugLogging))
1990  return Err;
1991  if (VerifyEachPass)
1992  MPM.addPass(VerifierPass());
1993  }
1994  return Error::success();
1995 }
1996 
1997 // Primary pass pipeline description parsing routine for a \c ModulePassManager
1998 // FIXME: Should this routine accept a TargetMachine or require the caller to
1999 // pre-populate the analysis managers with target-specific stuff?
2001  StringRef PipelineText,
2002  bool VerifyEachPass, bool DebugLogging) {
2003  auto Pipeline = parsePipelineText(PipelineText);
2004  if (!Pipeline || Pipeline->empty())
2005  return make_error<StringError>(
2006  formatv("invalid pipeline '{0}'", PipelineText).str(),
2008 
2009  // If the first name isn't at the module layer, wrap the pipeline up
2010  // automatically.
2011  StringRef FirstName = Pipeline->front().Name;
2012 
2013  if (!isModulePassName(FirstName, ModulePipelineParsingCallbacks)) {
2014  if (isCGSCCPassName(FirstName, CGSCCPipelineParsingCallbacks)) {
2015  Pipeline = {{"cgscc", std::move(*Pipeline)}};
2016  } else if (isFunctionPassName(FirstName,
2017  FunctionPipelineParsingCallbacks)) {
2018  Pipeline = {{"function", std::move(*Pipeline)}};
2019  } else if (isLoopPassName(FirstName, LoopPipelineParsingCallbacks)) {
2020  Pipeline = {{"function", {{"loop", std::move(*Pipeline)}}}};
2021  } else {
2022  for (auto &C : TopLevelPipelineParsingCallbacks)
2023  if (C(MPM, *Pipeline, VerifyEachPass, DebugLogging))
2024  return Error::success();
2025 
2026  // Unknown pass or pipeline name!
2027  auto &InnerPipeline = Pipeline->front().InnerPipeline;
2028  return make_error<StringError>(
2029  formatv("unknown {0} name '{1}'",
2030  (InnerPipeline.empty() ? "pass" : "pipeline"), FirstName)
2031  .str(),
2033  }
2034  }
2035 
2036  if (auto Err =
2037  parseModulePassPipeline(MPM, *Pipeline, VerifyEachPass, DebugLogging))
2038  return Err;
2039  return Error::success();
2040 }
2041 
2042 // Primary pass pipeline description parsing routine for a \c CGSCCPassManager
2044  StringRef PipelineText,
2045  bool VerifyEachPass, bool DebugLogging) {
2046  auto Pipeline = parsePipelineText(PipelineText);
2047  if (!Pipeline || Pipeline->empty())
2048  return make_error<StringError>(
2049  formatv("invalid pipeline '{0}'", PipelineText).str(),
2051 
2052  StringRef FirstName = Pipeline->front().Name;
2053  if (!isCGSCCPassName(FirstName, CGSCCPipelineParsingCallbacks))
2054  return make_error<StringError>(
2055  formatv("unknown cgscc pass '{0}' in pipeline '{1}'", FirstName,
2056  PipelineText)
2057  .str(),
2059 
2060  if (auto Err =
2061  parseCGSCCPassPipeline(CGPM, *Pipeline, VerifyEachPass, DebugLogging))
2062  return Err;
2063  return Error::success();
2064 }
2065 
2066 // Primary pass pipeline description parsing routine for a \c
2067 // FunctionPassManager
2069  StringRef PipelineText,
2070  bool VerifyEachPass, bool DebugLogging) {
2071  auto Pipeline = parsePipelineText(PipelineText);
2072  if (!Pipeline || Pipeline->empty())
2073  return make_error<StringError>(
2074  formatv("invalid pipeline '{0}'", PipelineText).str(),
2076 
2077  StringRef FirstName = Pipeline->front().Name;
2078  if (!isFunctionPassName(FirstName, FunctionPipelineParsingCallbacks))
2079  return make_error<StringError>(
2080  formatv("unknown function pass '{0}' in pipeline '{1}'", FirstName,
2081  PipelineText)
2082  .str(),
2084 
2085  if (auto Err = parseFunctionPassPipeline(FPM, *Pipeline, VerifyEachPass,
2086  DebugLogging))
2087  return Err;
2088  return Error::success();
2089 }
2090 
2091 // Primary pass pipeline description parsing routine for a \c LoopPassManager
2093  StringRef PipelineText,
2094  bool VerifyEachPass, bool DebugLogging) {
2095  auto Pipeline = parsePipelineText(PipelineText);
2096  if (!Pipeline || Pipeline->empty())
2097  return make_error<StringError>(
2098  formatv("invalid pipeline '{0}'", PipelineText).str(),
2100 
2101  if (auto Err =
2102  parseLoopPassPipeline(CGPM, *Pipeline, VerifyEachPass, DebugLogging))
2103  return Err;
2104 
2105  return Error::success();
2106 }
2107 
2109  // If the pipeline just consists of the word 'default' just replace the AA
2110  // manager with our default one.
2111  if (PipelineText == "default") {
2112  AA = buildDefaultAAPipeline();
2113  return Error::success();
2114  }
2115 
2116  while (!PipelineText.empty()) {
2117  StringRef Name;
2118  std::tie(Name, PipelineText) = PipelineText.split(',');
2119  if (!parseAAPassName(AA, Name))
2120  return make_error<StringError>(
2121  formatv("unknown alias analysis name '{0}'", Name).str(),
2123  }
2124 
2125  return Error::success();
2126 }
Super simple passes to force specific function attrs from the commandline into the IR for debugging p...
Defines passes for running instruction simplification across chunks of IR.
This file provides the interface for the pass responsible for both simplifying and canonicalizing the...
const T & front() const
front - Get the first element.
Definition: ArrayRef.h:151
Analysis pass providing a never-invalidated alias analysis result.
A set of parameters used to control various transforms performed by the LoopUnroll pass...
uint64_t CallInst * C
Computes function attributes in post-order over the call graph.
Definition: FunctionAttrs.h:50
ModulePassManager buildPerModuleDefaultPipeline(OptimizationLevel Level, bool DebugLogging=false, bool LTOPreLink=false)
Build a per-module default optimization pipeline.
A simple loop rotation transformation.
Definition: LoopRotation.h:23
A simple and fast domtree-based CSE pass.
Definition: EarlyCSE.h:30
The profile annotation (profile-instr-use) pass for IR based PGO.
Thresholds to tune inline cost analysis.
Definition: InlineCost.h:153
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.
LLVM_NODISCARD bool endswith(StringRef Suffix) const
Check if this string ends with the given Suffix.
Definition: StringRef.h:267
This is the interface for LLVM&#39;s inclusion-based alias analysis implemented with CFL graph reachabili...
This class represents lattice values for constants.
Definition: AllocatorList.h:23
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:64
amdgpu Simplify well known AMD library false FunctionCallee Value const Twine & Name
Error parseAAPipeline(AAManager &AA, StringRef PipelineText)
Parse a textual alias analysis pipeline into the provided AA manager.
This is the interface to build a ModuleSummaryIndex for a module.
LLVM_NODISCARD bool startswith(StringRef Prefix) const
Check if this string starts with the given Prefix.
Definition: StringRef.h:256
Uses an "inverted" value numbering to decide the similarity of expressions and sinks similar expressi...
Definition: GVN.h:305
InnerAnalysisManagerProxy< LoopAnalysisManager, Function > LoopAnalysisManagerFunctionProxy
A proxy from a LoopAnalysisManager to a Function.
Performs basic CFG simplifications to assist other loop passes.
This file provides the interface for LLVM&#39;s Scalar Replacement of Aggregates pass.
This file implements a simple N^2 alias analysis accuracy evaluator.
InnerAnalysisManagerProxy< CGSCCAnalysisManager, Module > CGSCCAnalysisManagerModuleProxy
A proxy from a CGSCCAnalysisManager to a Module.
Implements a lazy call graph analysis and related passes for the new pass manager.
RepeatedPass< PassT > createRepeatedPass(int Count, PassT P)
Definition: PassManager.h:1436
void registerModuleAnalyses(ModuleAnalysisManager &MAM)
Registers all available module analysis passes.
bool consume_front(StringRef Prefix)
Returns true if this StringRef has the given prefix and removes that prefix.
Definition: StringRef.h:649
This is the interface for a metadata-based scoped no-alias analysis.
void registerModuleAnalysis()
Register a specific AA result.
ModulePassManager buildModuleOptimizationPipeline(OptimizationLevel Level, bool DebugLogging=false, bool LTOPreLink=false)
Construct the core LLVM module optimization pipeline.
LoopUnrollOptions & setUpperBound(bool UpperBound)
Enables or disables the use of trip count upper bound in loop unrolling.
ModuleToPostOrderCGSCCPassAdaptor< CGSCCPassT > createModuleToPostOrderCGSCCPassAdaptor(CGSCCPassT Pass)
A function to deduce a function pass type and wrap it in the templated adaptor.
CGSCCToFunctionPassAdaptor< FunctionPassT > createCGSCCToFunctionPassAdaptor(FunctionPassT Pass)
A function to deduce a function pass type and wrap it in the templated adaptor.
auto formatv(const char *Fmt, Ts &&... Vals) -> formatv_object< decltype(std::make_tuple(detail::build_format_adapter(std::forward< Ts >(Vals))...))>
Pass to remove unused function declarations.
OptimizationLevel
LLVM-provided high-level optimization levels.
Definition: PassBuilder.h:97
ModulePassManager buildThinLTOPreLinkDefaultPipeline(OptimizationLevel Level, bool DebugLogging=false)
Build a pre-link, ThinLTO-targeting default optimization pipeline to a pass manager.
This file provides the interface for LLVM&#39;s PGO Instrumentation lowering pass.
OuterAnalysisManagerProxy< FunctionAnalysisManager, Loop, LoopStandardAnalysisResults & > FunctionAnalysisManagerLoopProxy
A proxy from a FunctionAnalysisManager to a Loop.
static cl::opt< bool > EnableEarlyCSEMemSSA("enable-npm-earlycse-memssa", cl::init(true), cl::Hidden, cl::desc("Enable the EarlyCSE w/ MemorySSA pass for the new PM (default = on)"))
The adaptor from a function pass to a loop pass computes these analyses and makes them available to t...
F(f)
Loop unroll pass that only does full loop unrolling.
Loop unroll pass that will support both full and partial unrolling.
Pass to perform split of global variables.
Definition: GlobalSplit.h:26
This pass transforms loops that contain branches or switches on loop- invariant conditions to have mu...
A DCE pass that assumes instructions are dead until proven otherwise.
Definition: ADCE.h:31
static cl::opt< bool > EnableSyntheticCounts("enable-npm-synthetic-counts", cl::init(false), cl::Hidden, cl::ZeroOrMore, cl::desc("Run synthetic function entry count generation " "pass"))
A utility pass template to force an analysis result to be available.
Definition: PassManager.h:1348
static cl::opt< bool > EnableGVNHoist("enable-npm-gvn-hoist", cl::init(false), cl::Hidden, cl::desc("Enable the GVN hoisting pass for the new PM (default = off)"))
Reassociate commutative expressions.
Definition: Reassociate.h:71
Support structure for SCC passes to communicate updates the call graph back to the CGSCC pass manager...
StringSwitch & Case(StringLiteral S, T Value)
Definition: StringSwitch.h:67
cl::opt< bool > EnableHotColdSplit
Run instruction simplification across each instruction in the function.
Pass to forward loads in a loop around the backedge to subsequent iterations.
A pass that transforms external global definitions into declarations.
This pass handles simple speculating of instructions around PHIs when doing so is profitable for a pa...
A simple and fast domtree-based GVN pass to hoist common expressions from sibling branches...
Definition: GVN.h:298
This is the interface for a SCEV-based alias analysis.
ModulePassManager buildModuleSimplificationPipeline(OptimizationLevel Level, ThinLTOPhase Phase, bool DebugLogging=false)
Construct the core LLVM module canonicalization and simplification pipeline.
A pass to do RPO deduction and propagation of function attributes.
Definition: FunctionAttrs.h:69
Optional< int > HintThreshold
Threshold to use for callees with inline hint.
Definition: InlineCost.h:158
Similar to O2 but tries to optimize for small code size instead of fast execution without triggering ...
Definition: PassBuilder.h:167
Instrumentation based profiling lowering pass.
bool registerPass(PassBuilderT &&PassBuilder)
Register an analysis pass with the manager.
Definition: PassManager.h:821
LLVM_NODISCARD R Default(T Value)
Definition: StringSwitch.h:181
static cl::opt< bool > EnableGVNSink("enable-npm-gvn-sink", cl::init(false), cl::Hidden, cl::desc("Enable the GVN hoisting pass for the new PM (default = off)"))
InnerAnalysisManagerProxy< FunctionAnalysisManager, Module > FunctionAnalysisManagerModuleProxy
Provide the FunctionAnalysisManager to Module proxy.
Definition: PassManager.h:1120
Hoist/decompose integer division and remainder instructions to enable CFG improvements and better cod...
Definition: DivRemPairs.h:23
Tagged union holding either a T or a Error.
Definition: CachePruning.h:22
LLVM_NODISCARD StringRef substr(size_t Start, size_t N=npos) const
Return a reference to the substring from [Start, Start + N).
Definition: StringRef.h:578
LLVM_NODISCARD bool empty() const
empty - Check if the string is empty.
Definition: StringRef.h:126
OuterAnalysisManagerProxy< CGSCCAnalysisManager, Function > CGSCCAnalysisManagerFunctionProxy
A proxy from a CGSCCAnalysisManager to a Function.
void registerLoopAnalyses(LoopAnalysisManager &LAM)
Registers all available loop analysis passes.
Key
PAL metadata keys.
A very specialized mode that will optimize for code size at any and all costs.
Definition: PassBuilder.h:176
This file provides interfaces used to build and manipulate a call graph, which is a very useful tool ...
The sample profiler data loader pass.
Definition: SampleProfile.h:25
FunctionToLoopPassAdaptor< LoopPassT > createFunctionToLoopPassAdaptor(LoopPassT Pass, bool DebugLogging=false)
A function to deduce a loop pass type and wrap it in the templated adaptor.
This file provides the interface for IR based instrumentation passes ( (profile-gen, and profile-use).
static bool isModulePassName(StringRef Name, CallbacksT &Callbacks)
falkor hwpf fix Falkor HW Prefetch Fix Late Phase
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:42
The core GVN pass object.
Definition: GVN.h:68
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:29
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:32
A pass that does profile-guided sinking of instructions into loops.
Definition: LoopSink.h:33
void registerFunctionAnalysis()
Register a specific AA result.
This class implements a trivial dead store elimination.
Class to hold module path string table and global value map, and encapsulate methods for operating on...
Argument promotion pass.
OuterAnalysisManagerProxy< ModuleAnalysisManager, LazyCallGraph::SCC, LazyCallGraph & > ModuleAnalysisManagerCGSCCProxy
A proxy from a ModuleAnalysisManager to an SCC.
LoopUnrollOptions & setPartial(bool Partial)
Enables or disables partial unrolling.
Pass to perform interprocedural constant propagation.
Definition: SCCP.h:30
A pass which infers function attributes from the names and signatures of function declarations in a m...
cl::opt< bool > FlattenedProfileUsed
static cl::opt< unsigned > MaxDevirtIterations("pm-max-devirt-iterations", cl::ReallyHidden, cl::init(4))
A switch()-like statement whose cases are string literals.
Definition: StringSwitch.h:42
This is the interface for LLVM&#39;s unification-based alias analysis implemented with CFL graph reachabi...
initializer< Ty > init(const Ty &Val)
Definition: CommandLine.h:422
static bool isOptimizingForSize(PassBuilder::OptimizationLevel Level)
static bool checkParametrizedPassName(StringRef Name, StringRef PassName)
A set of analyses that are preserved following a run of a transformation pass.
Definition: PassManager.h:153
This is the interface for a metadata-based TBAA.
static Regex DefaultAliasRegex("^(default|thinlto-pre-link|thinlto|lto-pre-link|lto)<(O[0123sz])>$")
ModuleToFunctionPassAdaptor< FunctionPassT > createModuleToFunctionPassAdaptor(FunctionPassT Pass)
A function to deduce a function pass type and wrap it in the templated adaptor.
Definition: PassManager.h:1332
This file provides the interface for LLVM&#39;s Global Value Numbering pass which eliminates fully redund...
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This file provides the primary interface to the instcombine pass.
Disable as many optimizations as possible.
Definition: PassBuilder.h:101
FunctionPassManager buildFunctionSimplificationPipeline(OptimizationLevel Level, ThinLTOPhase Phase, bool DebugLogging=false)
Construct the core LLVM function canonicalization and simplification pipeline.
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.
A CRTP mix-in that provides informational APIs needed for analysis passes.
Definition: PassManager.h:382
static bool isFunctionPassName(StringRef Name, CallbacksT &Callbacks)
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&#39;s Global Value Numbering pass.
ThinLTOPhase
ThinLTO phase.
Definition: PassBuilder.h:84
Optimize for fast execution as much as possible.
Definition: PassBuilder.h:155
static cl::opt< bool > EnableCHR("enable-chr-npm", cl::init(true), cl::Hidden, cl::desc("Enable control height reduction optimization (CHR)"))
DevirtSCCRepeatedPass< PassT > createDevirtSCCRepeatedPass(PassT Pass, int MaxIterations)
A function to deduce a function pass type and wrap it in the templated adaptor.
A simple loop rotation transformation.
static bool callbacksAcceptPassName(StringRef Name, CallbacksT &Callbacks)
Tests whether registered callbacks will accept a given pass name.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
Definition: PassManager.h:159
std::string InstrProfileOutput
size_t size() const
Definition: SmallVector.h:52
Create a verifier pass.
Definition: Verifier.h:136
ModulePassManager buildThinLTODefaultPipeline(OptimizationLevel Level, bool DebugLogging, const ModuleSummaryIndex *ImportSummary)
Build an ThinLTO default optimization pipeline to a pass manager.
static cl::opt< bool > EnableUnrollAndJam("enable-npm-unroll-and-jam", cl::init(false), cl::Hidden, cl::desc("Enable the Unroll and Jam pass for the new PM (default = off)"))
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
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:478
This file provides the interface for LLVM&#39;s Loop Data Prefetching Pass.
Provides passes to inlining "always_inline" functions.
This file provides the primary interface to the aggressive instcombine pass.
LoopUnrollOptions & setOptLevel(int O)
This class provides an interface for updating the loop pass manager based on mutations to the loop ne...
This header defines the LoopLoadEliminationPass object.
static ErrorSuccess success()
Create a success value.
Definition: Error.h:326
InlineParams getInlineParams()
Generate the parameters to tune the inline cost analysis based only on the commandline options...
static Optional< int > parseDevirtPassName(StringRef Name)
This is a &#39;vector&#39; (really, a variable-sized array), optimized for the case when the array is small...
Definition: SmallVector.h:839
Optimize for fast execution as much as possible without triggering significant incremental compile ti...
Definition: PassBuilder.h:139
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:696
This pass performs &#39;jump threading&#39;, which looks at blocks that have multiple predecessors and multip...
Definition: JumpThreading.h:77
A pass to simplify and canonicalize the CFG of a function.
Definition: SimplifyCFG.h:29
const DataFlowGraph & G
Definition: RDFGraph.cpp:210
Error parsePassPipeline(ModulePassManager &MPM, StringRef PipelineText, bool VerifyEachPass=true, bool DebugLogging=false)
Parse a textual pass pipeline description into a ModulePassManager.
static InlineParams getInlineParamsFromOptLevel(PassBuilder::OptimizationLevel Level)
The instrumentation (profile-instr-gen) pass for IR based PGO.
This pass converts vector operations into scalar operations, in order to expose optimization opportun...
A pass that merges duplicate global constants into a single constant.
Definition: ConstantMerge.h:29
Analysis pass providing a never-invalidated alias analysis result.
Options for the frontend instrumentation based profiling pass.
This pass performs merges of loads and stores on both sides of a.
The indirect function call promotion pass.
Interfaces for passes which infer implicit function attributes from the name and signature of functio...
Analysis pass providing a never-invalidated alias analysis result.
LoopUnrollOptions & setRuntime(bool Runtime)
Enables or disables unrolling of loops with runtime trip count.
static const size_t npos
Definition: StringRef.h:50
Represents a single loop in the control flow graph.
Definition: LoopInfo.h:464
Pass which forces specific function attributes into the IR, primarily as a debugging tool...
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:380
The header file for the LowerExpectIntrinsic pass as used by the new pass manager.
Pass to outline cold regions.
Provides passes for computing function attributes based on interprocedural analyses.
OuterAnalysisManagerProxy< ModuleAnalysisManager, Function > ModuleAnalysisManagerFunctionProxy
Provide the ModuleAnalysisManager to Function proxy.
Definition: PassManager.h:1249
bool consume_back(StringRef Suffix)
Returns true if this StringRef has the given suffix and removes that suffix.
Definition: StringRef.h:659
This header provides classes for managing passes over SCCs of the call graph.
This file defines passes to print out IR in various granularities.
void registerCGSCCAnalyses(CGSCCAnalysisManager &CGAM)
Registers all available CGSCC analysis passes.
ModulePassManager buildLTODefaultPipeline(OptimizationLevel Level, bool DebugLogging, ModuleSummaryIndex *ExportSummary)
Build an LTO default optimization pipeline to a pass manager.
static bool startsWithDefaultPipelineAliasPrefix(StringRef Name)
Tests whether a pass name starts with a valid prefix for a default pipeline alias.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file provides the interface for LLVM&#39;s Call Graph Profile pass.
Optimize quickly without destroying debuggability.
Definition: PassBuilder.h:121
The profile size based optimization pass for memory intrinsics.
See the comments on JumpThreadingPass.
An SCC of the call graph.
static const char * name
Performs Loop Inst Simplify Pass.
The LoopVectorize Pass.
Definition: LoopVectorize.h:79
Lightweight error class with error context and mandatory checking.
Definition: Error.h:157
static bool isCGSCCPassName(StringRef Name, CallbacksT &Callbacks)
bool match(StringRef String, SmallVectorImpl< StringRef > *Matches=nullptr)
matches - Match the regex against a given String.
Definition: Regex.cpp:72
An optimization pass providing Scalar Replacement of Aggregates.
Definition: SROA.h:65
This file exposes an interface to building/using memory SSA to walk memory instructions using a use/d...
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:48
This is the interface for LLVM&#39;s primary stateless and local alias analysis.
A container for analyses that lazily runs them and caches their results.
static cl::opt< bool > RunPartialInlining("enable-npm-partial-inlining", cl::init(false), cl::Hidden, cl::ZeroOrMore, cl::desc("Run Partial inlinining pass"))
A set of parameters used to control the transforms in the SimplifyCFG pass.
Definition: Local.h:63
void addPass(PassT Pass)
Definition: PassManager.h:541
This pass exposes codegen information to IR-level passes.
This pass performs function-level constant propagation and merging.
Definition: SCCP.h:36
This header defines various interfaces for pass management in LLVM.
LoopUnrollOptions & setPeeling(bool Peeling)
Enables or disables loop peeling.
static cl::opt< bool > RunNewGVN("enable-npm-newgvn", cl::init(false), cl::Hidden, cl::ZeroOrMore, cl::desc("Run NewGVN instead of GVN"))
A special type used by analysis passes to provide an address that identifies that particular analysis...
Definition: PassManager.h:70
This file provides the interface for the sampled PGO loader pass.
Optional< int > HotCallSiteThreshold
Threshold to use when the callsite is considered hot.
Definition: InlineCost.h:170
int DefaultThreshold
The default threshold to start with for a callee.
Definition: InlineCost.h:155
Optimize globals that never have their address taken.
Definition: GlobalOpt.h:25
bool empty() const
empty - Check if the array is empty.
Definition: ArrayRef.h:143
Performs Loop Idiom Recognize Pass.
std::error_code inconvertibleErrorCode()
The value returned by this function can be returned from convertToErrorCode for Error values where no...
Definition: Error.cpp:77
static bool isLoopPassName(StringRef Name, CallbacksT &Callbacks)