LLVM 20.0.0git
PassBuilder.cpp
Go to the documentation of this file.
1//===- Parsing and selection 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
33#include "llvm/Analysis/DDG.h"
52#include "llvm/Analysis/Lint.h"
145#include "llvm/IR/DebugInfo.h"
146#include "llvm/IR/Dominators.h"
147#include "llvm/IR/PassManager.h"
148#include "llvm/IR/PrintPasses.h"
150#include "llvm/IR/Verifier.h"
154#include "llvm/Support/Debug.h"
157#include "llvm/Support/Regex.h"
346#include <optional>
347
348using namespace llvm;
349
351 "^(default|thinlto-pre-link|thinlto|lto-pre-link|lto)<(O[0123sz])>$");
352
353namespace llvm {
355 "print-pipeline-passes",
356 cl::desc("Print a '-passes' compatible string describing the pipeline "
357 "(best-effort only)."));
358} // namespace llvm
359
360AnalysisKey NoOpModuleAnalysis::Key;
361AnalysisKey NoOpCGSCCAnalysis::Key;
362AnalysisKey NoOpFunctionAnalysis::Key;
363AnalysisKey NoOpLoopAnalysis::Key;
364
365namespace {
366
367// Passes for testing crashes.
368// DO NOT USE THIS EXCEPT FOR TESTING!
369class TriggerCrashModulePass : public PassInfoMixin<TriggerCrashModulePass> {
370public:
372 abort();
373 return PreservedAnalyses::all();
374 }
375 static StringRef name() { return "TriggerCrashModulePass"; }
376};
377
378class TriggerCrashFunctionPass
379 : public PassInfoMixin<TriggerCrashFunctionPass> {
380public:
382 abort();
383 return PreservedAnalyses::all();
384 }
385 static StringRef name() { return "TriggerCrashFunctionPass"; }
386};
387
388// A pass for testing message reporting of -verify-each failures.
389// DO NOT USE THIS EXCEPT FOR TESTING!
390class TriggerVerifierErrorPass
391 : public PassInfoMixin<TriggerVerifierErrorPass> {
392public:
394 // Intentionally break the Module by creating an alias without setting the
395 // aliasee.
396 auto *PtrTy = llvm::PointerType::getUnqual(M.getContext());
397 GlobalAlias::create(PtrTy, PtrTy->getAddressSpace(),
398 GlobalValue::LinkageTypes::InternalLinkage,
399 "__bad_alias", nullptr, &M);
401 }
402
404 // Intentionally break the Function by inserting a terminator
405 // instruction in the middle of a basic block.
406 BasicBlock &BB = F.getEntryBlock();
407 new UnreachableInst(F.getContext(), BB.getTerminator()->getIterator());
409 }
410
412 // Intentionally create a virtual register and set NoVRegs property.
413 auto &MRI = MF.getRegInfo();
414 MRI.createGenericVirtualRegister(LLT::scalar(8));
415 MF.getProperties().set(MachineFunctionProperties::Property::NoVRegs);
416 return PreservedAnalyses::all();
417 }
418
419 static StringRef name() { return "TriggerVerifierErrorPass"; }
420};
421
422// A pass requires all MachineFunctionProperties.
423// DO NOT USE THIS EXCEPT FOR TESTING!
424class RequireAllMachineFunctionPropertiesPass
425 : public PassInfoMixin<RequireAllMachineFunctionPropertiesPass> {
426public:
428 MFPropsModifier _(*this, MF);
430 }
431
432 static MachineFunctionProperties getRequiredProperties() {
434 MFProps.set(MachineFunctionProperties::Property::FailedISel);
435 MFProps.set(MachineFunctionProperties::Property::FailsVerification);
436 MFProps.set(MachineFunctionProperties::Property::IsSSA);
437 MFProps.set(MachineFunctionProperties::Property::Legalized);
438 MFProps.set(MachineFunctionProperties::Property::NoPHIs);
439 MFProps.set(MachineFunctionProperties::Property::NoVRegs);
440 MFProps.set(MachineFunctionProperties::Property::RegBankSelected);
441 MFProps.set(MachineFunctionProperties::Property::Selected);
442 MFProps.set(MachineFunctionProperties::Property::TiedOpsRewritten);
443 MFProps.set(MachineFunctionProperties::Property::TracksDebugUserValues);
444 MFProps.set(MachineFunctionProperties::Property::TracksLiveness);
445 return MFProps;
446 }
447 static StringRef name() { return "RequireAllMachineFunctionPropertiesPass"; }
448};
449
450} // namespace
451
453 std::optional<PGOOptions> PGOOpt,
455 : TM(TM), PTO(PTO), PGOOpt(PGOOpt), PIC(PIC) {
456 if (TM)
457 TM->registerPassBuilderCallbacks(*this);
458 if (PIC) {
460 // MSVC requires this to be captured if it's used inside decltype.
461 // Other compilers consider it an unused lambda capture.
462 (void)this;
463#define MODULE_PASS(NAME, CREATE_PASS) \
464 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
465#define MODULE_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
466 PIC->addClassToPassName(CLASS, NAME);
467#define MODULE_ANALYSIS(NAME, CREATE_PASS) \
468 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
469#define FUNCTION_PASS(NAME, CREATE_PASS) \
470 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
471#define FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
472 PIC->addClassToPassName(CLASS, NAME);
473#define FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
474 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
475#define LOOPNEST_PASS(NAME, CREATE_PASS) \
476 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
477#define LOOP_PASS(NAME, CREATE_PASS) \
478 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
479#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
480 PIC->addClassToPassName(CLASS, NAME);
481#define LOOP_ANALYSIS(NAME, CREATE_PASS) \
482 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
483#define CGSCC_PASS(NAME, CREATE_PASS) \
484 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
485#define CGSCC_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
486 PIC->addClassToPassName(CLASS, NAME);
487#define CGSCC_ANALYSIS(NAME, CREATE_PASS) \
488 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
489#include "PassRegistry.def"
490
491#define MACHINE_FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
492 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
493#define MACHINE_FUNCTION_PASS(NAME, CREATE_PASS) \
494 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
495#include "llvm/Passes/MachinePassRegistry.def"
496 });
497 }
498}
499
501#define MODULE_ANALYSIS(NAME, CREATE_PASS) \
502 MAM.registerPass([&] { return CREATE_PASS; });
503#include "PassRegistry.def"
504
505 for (auto &C : ModuleAnalysisRegistrationCallbacks)
506 C(MAM);
507}
508
510#define CGSCC_ANALYSIS(NAME, CREATE_PASS) \
511 CGAM.registerPass([&] { return CREATE_PASS; });
512#include "PassRegistry.def"
513
514 for (auto &C : CGSCCAnalysisRegistrationCallbacks)
515 C(CGAM);
516}
517
519 // We almost always want the default alias analysis pipeline.
520 // If a user wants a different one, they can register their own before calling
521 // registerFunctionAnalyses().
522 FAM.registerPass([&] { return buildDefaultAAPipeline(); });
523
524#define FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
525 FAM.registerPass([&] { return CREATE_PASS; });
526#include "PassRegistry.def"
527
528 for (auto &C : FunctionAnalysisRegistrationCallbacks)
529 C(FAM);
530}
531
534
535#define MACHINE_FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
536 MFAM.registerPass([&] { return CREATE_PASS; });
537#include "llvm/Passes/MachinePassRegistry.def"
538
539 for (auto &C : MachineFunctionAnalysisRegistrationCallbacks)
540 C(MFAM);
541}
542
544#define LOOP_ANALYSIS(NAME, CREATE_PASS) \
545 LAM.registerPass([&] { return CREATE_PASS; });
546#include "PassRegistry.def"
547
548 for (auto &C : LoopAnalysisRegistrationCallbacks)
549 C(LAM);
550}
551
552static std::optional<std::pair<bool, bool>>
554 std::pair<bool, bool> Params;
555 if (!Name.consume_front("function"))
556 return std::nullopt;
557 if (Name.empty())
558 return Params;
559 if (!Name.consume_front("<") || !Name.consume_back(">"))
560 return std::nullopt;
561 while (!Name.empty()) {
562 auto [Front, Back] = Name.split(';');
563 Name = Back;
564 if (Front == "eager-inv")
565 Params.first = true;
566 else if (Front == "no-rerun")
567 Params.second = true;
568 else
569 return std::nullopt;
570 }
571 return Params;
572}
573
574static std::optional<int> parseDevirtPassName(StringRef Name) {
575 if (!Name.consume_front("devirt<") || !Name.consume_back(">"))
576 return std::nullopt;
577 int Count;
578 if (Name.getAsInteger(0, Count) || Count < 0)
579 return std::nullopt;
580 return Count;
581}
582
583static std::optional<OptimizationLevel> parseOptLevel(StringRef S) {
585 .Case("O0", OptimizationLevel::O0)
591 .Default(std::nullopt);
592}
593
595 StringRef OptionName,
597 bool Result = false;
598 while (!Params.empty()) {
599 StringRef ParamName;
600 std::tie(ParamName, Params) = Params.split(';');
601
602 if (ParamName == OptionName) {
603 Result = true;
604 } else {
605 return make_error<StringError>(
606 formatv("invalid {1} pass parameter '{0}' ", ParamName, PassName)
607 .str(),
609 }
610 }
611 return Result;
612}
613
614namespace {
615
616/// Parser of parameters for HardwareLoops pass.
617Expected<HardwareLoopOptions> parseHardwareLoopOptions(StringRef Params) {
618 HardwareLoopOptions HardwareLoopOpts;
619
620 while (!Params.empty()) {
621 StringRef ParamName;
622 std::tie(ParamName, Params) = Params.split(';');
623 if (ParamName.consume_front("hardware-loop-decrement=")) {
624 int Count;
625 if (ParamName.getAsInteger(0, Count))
626 return make_error<StringError>(
627 formatv("invalid HardwareLoopPass parameter '{0}' ", ParamName).str(),
629 HardwareLoopOpts.setDecrement(Count);
630 continue;
631 }
632 if (ParamName.consume_front("hardware-loop-counter-bitwidth=")) {
633 int Count;
634 if (ParamName.getAsInteger(0, Count))
635 return make_error<StringError>(
636 formatv("invalid HardwareLoopPass parameter '{0}' ", ParamName).str(),
638 HardwareLoopOpts.setCounterBitwidth(Count);
639 continue;
640 }
641 if (ParamName == "force-hardware-loops") {
642 HardwareLoopOpts.setForce(true);
643 } else if (ParamName == "force-hardware-loop-phi") {
644 HardwareLoopOpts.setForcePhi(true);
645 } else if (ParamName == "force-nested-hardware-loop") {
646 HardwareLoopOpts.setForceNested(true);
647 } else if (ParamName == "force-hardware-loop-guard") {
648 HardwareLoopOpts.setForceGuard(true);
649 } else {
650 return make_error<StringError>(
651 formatv("invalid HardwarePass parameter '{0}' ", ParamName).str(),
653 }
654 }
655 return HardwareLoopOpts;
656}
657
658/// Parser of parameters for LoopUnroll pass.
659Expected<LoopUnrollOptions> parseLoopUnrollOptions(StringRef Params) {
660 LoopUnrollOptions UnrollOpts;
661 while (!Params.empty()) {
662 StringRef ParamName;
663 std::tie(ParamName, Params) = Params.split(';');
664 std::optional<OptimizationLevel> OptLevel = parseOptLevel(ParamName);
665 // Don't accept -Os/-Oz.
666 if (OptLevel && !OptLevel->isOptimizingForSize()) {
667 UnrollOpts.setOptLevel(OptLevel->getSpeedupLevel());
668 continue;
669 }
670 if (ParamName.consume_front("full-unroll-max=")) {
671 int Count;
672 if (ParamName.getAsInteger(0, Count))
673 return make_error<StringError>(
674 formatv("invalid LoopUnrollPass parameter '{0}' ", ParamName).str(),
676 UnrollOpts.setFullUnrollMaxCount(Count);
677 continue;
678 }
679
680 bool Enable = !ParamName.consume_front("no-");
681 if (ParamName == "partial") {
682 UnrollOpts.setPartial(Enable);
683 } else if (ParamName == "peeling") {
684 UnrollOpts.setPeeling(Enable);
685 } else if (ParamName == "profile-peeling") {
686 UnrollOpts.setProfileBasedPeeling(Enable);
687 } else if (ParamName == "runtime") {
688 UnrollOpts.setRuntime(Enable);
689 } else if (ParamName == "upperbound") {
690 UnrollOpts.setUpperBound(Enable);
691 } else {
692 return make_error<StringError>(
693 formatv("invalid LoopUnrollPass parameter '{0}' ", ParamName).str(),
695 }
696 }
697 return UnrollOpts;
698}
699
700Expected<bool> parseGlobalDCEPassOptions(StringRef Params) {
702 Params, "vfe-linkage-unit-visibility", "GlobalDCE");
703}
704
705Expected<bool> parseCGProfilePassOptions(StringRef Params) {
706 return PassBuilder::parseSinglePassOption(Params, "in-lto-post-link",
707 "CGProfile");
708}
709
710Expected<bool> parseInlinerPassOptions(StringRef Params) {
711 return PassBuilder::parseSinglePassOption(Params, "only-mandatory",
712 "InlinerPass");
713}
714
715Expected<bool> parseCoroSplitPassOptions(StringRef Params) {
716 return PassBuilder::parseSinglePassOption(Params, "reuse-storage",
717 "CoroSplitPass");
718}
719
720Expected<bool> parsePostOrderFunctionAttrsPassOptions(StringRef Params) {
722 Params, "skip-non-recursive-function-attrs", "PostOrderFunctionAttrs");
723}
724
725Expected<CFGuardPass::Mechanism> parseCFGuardPassOptions(StringRef Params) {
726 if (Params.empty())
728
729 auto [Param, RHS] = Params.split(';');
730 if (!RHS.empty())
731 return make_error<StringError>(
732 formatv("too many CFGuardPass parameters '{0}' ", Params).str(),
734
735 if (Param == "check")
737 if (Param == "dispatch")
739
740 return make_error<StringError>(
741 formatv("invalid CFGuardPass mechanism: '{0}' ", Param).str(),
743}
744
745Expected<bool> parseEarlyCSEPassOptions(StringRef Params) {
746 return PassBuilder::parseSinglePassOption(Params, "memssa", "EarlyCSE");
747}
748
749Expected<bool> parseEntryExitInstrumenterPassOptions(StringRef Params) {
750 return PassBuilder::parseSinglePassOption(Params, "post-inline",
751 "EntryExitInstrumenter");
752}
753
754Expected<bool> parseLoopExtractorPassOptions(StringRef Params) {
755 return PassBuilder::parseSinglePassOption(Params, "single", "LoopExtractor");
756}
757
758Expected<bool> parseLowerMatrixIntrinsicsPassOptions(StringRef Params) {
759 return PassBuilder::parseSinglePassOption(Params, "minimal",
760 "LowerMatrixIntrinsics");
761}
762
763Expected<AddressSanitizerOptions> parseASanPassOptions(StringRef Params) {
765 while (!Params.empty()) {
766 StringRef ParamName;
767 std::tie(ParamName, Params) = Params.split(';');
768
769 if (ParamName == "kernel") {
770 Result.CompileKernel = true;
771 } else {
772 return make_error<StringError>(
773 formatv("invalid AddressSanitizer pass parameter '{0}' ", ParamName)
774 .str(),
776 }
777 }
778 return Result;
779}
780
781Expected<HWAddressSanitizerOptions> parseHWASanPassOptions(StringRef Params) {
783 while (!Params.empty()) {
784 StringRef ParamName;
785 std::tie(ParamName, Params) = Params.split(';');
786
787 if (ParamName == "recover") {
788 Result.Recover = true;
789 } else if (ParamName == "kernel") {
790 Result.CompileKernel = true;
791 } else {
792 return make_error<StringError>(
793 formatv("invalid HWAddressSanitizer pass parameter '{0}' ", ParamName)
794 .str(),
796 }
797 }
798 return Result;
799}
800
801Expected<EmbedBitcodeOptions> parseEmbedBitcodePassOptions(StringRef Params) {
803 while (!Params.empty()) {
804 StringRef ParamName;
805 std::tie(ParamName, Params) = Params.split(';');
806
807 if (ParamName == "thinlto") {
808 Result.IsThinLTO = true;
809 } else if (ParamName == "emit-summary") {
810 Result.EmitLTOSummary = true;
811 } else {
812 return make_error<StringError>(
813 formatv("invalid EmbedBitcode pass parameter '{0}' ", ParamName)
814 .str(),
816 }
817 }
818 return Result;
819}
820
821Expected<MemorySanitizerOptions> parseMSanPassOptions(StringRef Params) {
823 while (!Params.empty()) {
824 StringRef ParamName;
825 std::tie(ParamName, Params) = Params.split(';');
826
827 if (ParamName == "recover") {
828 Result.Recover = true;
829 } else if (ParamName == "kernel") {
830 Result.Kernel = true;
831 } else if (ParamName.consume_front("track-origins=")) {
832 if (ParamName.getAsInteger(0, Result.TrackOrigins))
833 return make_error<StringError>(
834 formatv("invalid argument to MemorySanitizer pass track-origins "
835 "parameter: '{0}' ",
836 ParamName)
837 .str(),
839 } else if (ParamName == "eager-checks") {
840 Result.EagerChecks = true;
841 } else {
842 return make_error<StringError>(
843 formatv("invalid MemorySanitizer pass parameter '{0}' ", ParamName)
844 .str(),
846 }
847 }
848 return Result;
849}
850
851/// Parser of parameters for SimplifyCFG pass.
852Expected<SimplifyCFGOptions> parseSimplifyCFGOptions(StringRef Params) {
854 while (!Params.empty()) {
855 StringRef ParamName;
856 std::tie(ParamName, Params) = Params.split(';');
857
858 bool Enable = !ParamName.consume_front("no-");
859 if (ParamName == "speculate-blocks") {
860 Result.speculateBlocks(Enable);
861 } else if (ParamName == "simplify-cond-branch") {
862 Result.setSimplifyCondBranch(Enable);
863 } else if (ParamName == "forward-switch-cond") {
864 Result.forwardSwitchCondToPhi(Enable);
865 } else if (ParamName == "switch-range-to-icmp") {
866 Result.convertSwitchRangeToICmp(Enable);
867 } else if (ParamName == "switch-to-lookup") {
868 Result.convertSwitchToLookupTable(Enable);
869 } else if (ParamName == "keep-loops") {
870 Result.needCanonicalLoops(Enable);
871 } else if (ParamName == "hoist-common-insts") {
872 Result.hoistCommonInsts(Enable);
873 } else if (ParamName == "hoist-loads-stores-with-cond-faulting") {
874 Result.hoistLoadsStoresWithCondFaulting(Enable);
875 } else if (ParamName == "sink-common-insts") {
876 Result.sinkCommonInsts(Enable);
877 } else if (ParamName == "speculate-unpredictables") {
878 Result.speculateUnpredictables(Enable);
879 } else if (Enable && ParamName.consume_front("bonus-inst-threshold=")) {
880 APInt BonusInstThreshold;
881 if (ParamName.getAsInteger(0, BonusInstThreshold))
882 return make_error<StringError>(
883 formatv("invalid argument to SimplifyCFG pass bonus-threshold "
884 "parameter: '{0}' ",
885 ParamName).str(),
887 Result.bonusInstThreshold(BonusInstThreshold.getSExtValue());
888 } else {
889 return make_error<StringError>(
890 formatv("invalid SimplifyCFG pass parameter '{0}' ", ParamName).str(),
892 }
893 }
894 return Result;
895}
896
897Expected<InstCombineOptions> parseInstCombineOptions(StringRef Params) {
899 // When specifying "instcombine" in -passes enable fix-point verification by
900 // default, as this is what most tests should use.
901 Result.setVerifyFixpoint(true);
902 while (!Params.empty()) {
903 StringRef ParamName;
904 std::tie(ParamName, Params) = Params.split(';');
905
906 bool Enable = !ParamName.consume_front("no-");
907 if (ParamName == "verify-fixpoint") {
908 Result.setVerifyFixpoint(Enable);
909 } else if (Enable && ParamName.consume_front("max-iterations=")) {
910 APInt MaxIterations;
911 if (ParamName.getAsInteger(0, MaxIterations))
912 return make_error<StringError>(
913 formatv("invalid argument to InstCombine pass max-iterations "
914 "parameter: '{0}' ",
915 ParamName).str(),
917 Result.setMaxIterations((unsigned)MaxIterations.getZExtValue());
918 } else {
919 return make_error<StringError>(
920 formatv("invalid InstCombine pass parameter '{0}' ", ParamName).str(),
922 }
923 }
924 return Result;
925}
926
927/// Parser of parameters for LoopVectorize pass.
928Expected<LoopVectorizeOptions> parseLoopVectorizeOptions(StringRef Params) {
930 while (!Params.empty()) {
931 StringRef ParamName;
932 std::tie(ParamName, Params) = Params.split(';');
933
934 bool Enable = !ParamName.consume_front("no-");
935 if (ParamName == "interleave-forced-only") {
937 } else if (ParamName == "vectorize-forced-only") {
939 } else {
940 return make_error<StringError>(
941 formatv("invalid LoopVectorize parameter '{0}' ", ParamName).str(),
943 }
944 }
945 return Opts;
946}
947
948Expected<std::pair<bool, bool>> parseLoopUnswitchOptions(StringRef Params) {
949 std::pair<bool, bool> Result = {false, true};
950 while (!Params.empty()) {
951 StringRef ParamName;
952 std::tie(ParamName, Params) = Params.split(';');
953
954 bool Enable = !ParamName.consume_front("no-");
955 if (ParamName == "nontrivial") {
956 Result.first = Enable;
957 } else if (ParamName == "trivial") {
958 Result.second = Enable;
959 } else {
960 return make_error<StringError>(
961 formatv("invalid LoopUnswitch pass parameter '{0}' ", ParamName)
962 .str(),
964 }
965 }
966 return Result;
967}
968
969Expected<LICMOptions> parseLICMOptions(StringRef Params) {
971 while (!Params.empty()) {
972 StringRef ParamName;
973 std::tie(ParamName, Params) = Params.split(';');
974
975 bool Enable = !ParamName.consume_front("no-");
976 if (ParamName == "allowspeculation") {
977 Result.AllowSpeculation = Enable;
978 } else {
979 return make_error<StringError>(
980 formatv("invalid LICM pass parameter '{0}' ", ParamName).str(),
982 }
983 }
984 return Result;
985}
986
987Expected<std::pair<bool, bool>> parseLoopRotateOptions(StringRef Params) {
988 std::pair<bool, bool> Result = {true, false};
989 while (!Params.empty()) {
990 StringRef ParamName;
991 std::tie(ParamName, Params) = Params.split(';');
992
993 bool Enable = !ParamName.consume_front("no-");
994 if (ParamName == "header-duplication") {
995 Result.first = Enable;
996 } else if (ParamName == "prepare-for-lto") {
997 Result.second = Enable;
998 } else {
999 return make_error<StringError>(
1000 formatv("invalid LoopRotate pass parameter '{0}' ", ParamName).str(),
1002 }
1003 }
1004 return Result;
1005}
1006
1007Expected<bool> parseMergedLoadStoreMotionOptions(StringRef Params) {
1008 bool Result = false;
1009 while (!Params.empty()) {
1010 StringRef ParamName;
1011 std::tie(ParamName, Params) = Params.split(';');
1012
1013 bool Enable = !ParamName.consume_front("no-");
1014 if (ParamName == "split-footer-bb") {
1015 Result = Enable;
1016 } else {
1017 return make_error<StringError>(
1018 formatv("invalid MergedLoadStoreMotion pass parameter '{0}' ",
1019 ParamName)
1020 .str(),
1022 }
1023 }
1024 return Result;
1025}
1026
1027Expected<GVNOptions> parseGVNOptions(StringRef Params) {
1029 while (!Params.empty()) {
1030 StringRef ParamName;
1031 std::tie(ParamName, Params) = Params.split(';');
1032
1033 bool Enable = !ParamName.consume_front("no-");
1034 if (ParamName == "pre") {
1035 Result.setPRE(Enable);
1036 } else if (ParamName == "load-pre") {
1037 Result.setLoadPRE(Enable);
1038 } else if (ParamName == "split-backedge-load-pre") {
1039 Result.setLoadPRESplitBackedge(Enable);
1040 } else if (ParamName == "memdep") {
1041 Result.setMemDep(Enable);
1042 } else {
1043 return make_error<StringError>(
1044 formatv("invalid GVN pass parameter '{0}' ", ParamName).str(),
1046 }
1047 }
1048 return Result;
1049}
1050
1051Expected<IPSCCPOptions> parseIPSCCPOptions(StringRef Params) {
1053 while (!Params.empty()) {
1054 StringRef ParamName;
1055 std::tie(ParamName, Params) = Params.split(';');
1056
1057 bool Enable = !ParamName.consume_front("no-");
1058 if (ParamName == "func-spec")
1059 Result.setFuncSpec(Enable);
1060 else
1061 return make_error<StringError>(
1062 formatv("invalid IPSCCP pass parameter '{0}' ", ParamName).str(),
1064 }
1065 return Result;
1066}
1067
1068Expected<ScalarizerPassOptions> parseScalarizerOptions(StringRef Params) {
1070 while (!Params.empty()) {
1071 StringRef ParamName;
1072 std::tie(ParamName, Params) = Params.split(';');
1073
1074 if (ParamName.consume_front("min-bits=")) {
1075 if (ParamName.getAsInteger(0, Result.ScalarizeMinBits)) {
1076 return make_error<StringError>(
1077 formatv("invalid argument to Scalarizer pass min-bits "
1078 "parameter: '{0}' ",
1079 ParamName)
1080 .str(),
1082 }
1083
1084 continue;
1085 }
1086
1087 bool Enable = !ParamName.consume_front("no-");
1088 if (ParamName == "load-store")
1089 Result.ScalarizeLoadStore = Enable;
1090 else if (ParamName == "variable-insert-extract")
1091 Result.ScalarizeVariableInsertExtract = Enable;
1092 else {
1093 return make_error<StringError>(
1094 formatv("invalid Scalarizer pass parameter '{0}' ", ParamName).str(),
1096 }
1097 }
1098
1099 return Result;
1100}
1101
1102Expected<SROAOptions> parseSROAOptions(StringRef Params) {
1103 if (Params.empty() || Params == "modify-cfg")
1105 if (Params == "preserve-cfg")
1107 return make_error<StringError>(
1108 formatv("invalid SROA pass parameter '{0}' (either preserve-cfg or "
1109 "modify-cfg can be specified)",
1110 Params)
1111 .str(),
1113}
1114
1116parseStackLifetimeOptions(StringRef Params) {
1118 while (!Params.empty()) {
1119 StringRef ParamName;
1120 std::tie(ParamName, Params) = Params.split(';');
1121
1122 if (ParamName == "may") {
1124 } else if (ParamName == "must") {
1126 } else {
1127 return make_error<StringError>(
1128 formatv("invalid StackLifetime parameter '{0}' ", ParamName).str(),
1130 }
1131 }
1132 return Result;
1133}
1134
1135Expected<bool> parseDependenceAnalysisPrinterOptions(StringRef Params) {
1136 return PassBuilder::parseSinglePassOption(Params, "normalized-results",
1137 "DependenceAnalysisPrinter");
1138}
1139
1140Expected<bool> parseSeparateConstOffsetFromGEPPassOptions(StringRef Params) {
1141 return PassBuilder::parseSinglePassOption(Params, "lower-gep",
1142 "SeparateConstOffsetFromGEP");
1143}
1144
1145Expected<bool> parseStructurizeCFGPassOptions(StringRef Params) {
1146 return PassBuilder::parseSinglePassOption(Params, "skip-uniform-regions",
1147 "StructurizeCFG");
1148}
1149
1151parseFunctionSimplificationPipelineOptions(StringRef Params) {
1152 std::optional<OptimizationLevel> L = parseOptLevel(Params);
1153 if (!L || *L == OptimizationLevel::O0) {
1154 return make_error<StringError>(
1155 formatv("invalid function-simplification parameter '{0}' ", Params)
1156 .str(),
1158 };
1159 return *L;
1160}
1161
1162Expected<bool> parseMemorySSAPrinterPassOptions(StringRef Params) {
1163 return PassBuilder::parseSinglePassOption(Params, "no-ensure-optimized-uses",
1164 "MemorySSAPrinterPass");
1165}
1166
1167Expected<bool> parseSpeculativeExecutionPassOptions(StringRef Params) {
1168 return PassBuilder::parseSinglePassOption(Params, "only-if-divergent-target",
1169 "SpeculativeExecutionPass");
1170}
1171
1172Expected<std::string> parseMemProfUsePassOptions(StringRef Params) {
1173 std::string Result;
1174 while (!Params.empty()) {
1175 StringRef ParamName;
1176 std::tie(ParamName, Params) = Params.split(';');
1177
1178 if (ParamName.consume_front("profile-filename=")) {
1179 Result = ParamName.str();
1180 } else {
1181 return make_error<StringError>(
1182 formatv("invalid MemProfUse pass parameter '{0}' ", ParamName).str(),
1184 }
1185 }
1186 return Result;
1187}
1188
1190parseStructuralHashPrinterPassOptions(StringRef Params) {
1191 if (Params.empty())
1193 if (Params == "detailed")
1195 if (Params == "call-target-ignored")
1197 return make_error<StringError>(
1198 formatv("invalid structural hash printer parameter '{0}' ", Params).str(),
1200}
1201
1202Expected<bool> parseWinEHPrepareOptions(StringRef Params) {
1203 return PassBuilder::parseSinglePassOption(Params, "demote-catchswitch-only",
1204 "WinEHPreparePass");
1205}
1206
1207Expected<GlobalMergeOptions> parseGlobalMergeOptions(StringRef Params) {
1209 while (!Params.empty()) {
1210 StringRef ParamName;
1211 std::tie(ParamName, Params) = Params.split(';');
1212
1213 bool Enable = !ParamName.consume_front("no-");
1214 if (ParamName == "group-by-use")
1215 Result.GroupByUse = Enable;
1216 else if (ParamName == "ignore-single-use")
1217 Result.IgnoreSingleUse = Enable;
1218 else if (ParamName == "merge-const")
1219 Result.MergeConst = Enable;
1220 else if (ParamName == "merge-external")
1221 Result.MergeExternal = Enable;
1222 else if (ParamName.consume_front("max-offset=")) {
1223 if (ParamName.getAsInteger(0, Result.MaxOffset))
1224 return make_error<StringError>(
1225 formatv("invalid GlobalMergePass parameter '{0}' ", ParamName)
1226 .str(),
1228 }
1229 }
1230 return Result;
1231}
1232
1233Expected<SmallVector<std::string, 0>> parseInternalizeGVs(StringRef Params) {
1234 SmallVector<std::string, 1> PreservedGVs;
1235 while (!Params.empty()) {
1236 StringRef ParamName;
1237 std::tie(ParamName, Params) = Params.split(';');
1238
1239 if (ParamName.consume_front("preserve-gv=")) {
1240 PreservedGVs.push_back(ParamName.str());
1241 } else {
1242 return make_error<StringError>(
1243 formatv("invalid Internalize pass parameter '{0}' ", ParamName).str(),
1245 }
1246 }
1247
1248 return Expected<SmallVector<std::string, 0>>(std::move(PreservedGVs));
1249}
1250
1252parseRegAllocFastPassOptions(PassBuilder &PB, StringRef Params) {
1254 while (!Params.empty()) {
1255 StringRef ParamName;
1256 std::tie(ParamName, Params) = Params.split(';');
1257
1258 if (ParamName.consume_front("filter=")) {
1259 std::optional<RegAllocFilterFunc> Filter =
1260 PB.parseRegAllocFilter(ParamName);
1261 if (!Filter) {
1262 return make_error<StringError>(
1263 formatv("invalid regallocfast register filter '{0}' ", ParamName)
1264 .str(),
1266 }
1267 Opts.Filter = *Filter;
1268 Opts.FilterName = ParamName;
1269 continue;
1270 }
1271
1272 if (ParamName == "no-clear-vregs") {
1273 Opts.ClearVRegs = false;
1274 continue;
1275 }
1276
1277 return make_error<StringError>(
1278 formatv("invalid regallocfast pass parameter '{0}' ", ParamName).str(),
1280 }
1281 return Opts;
1282}
1283
1285parseBoundsCheckingOptions(StringRef Params) {
1288 while (!Params.empty()) {
1289 StringRef ParamName;
1290 std::tie(ParamName, Params) = Params.split(';');
1291 if (ParamName == "trap") {
1293 } else if (ParamName == "rt") {
1295 } else if (ParamName == "rt-abort") {
1297 } else if (ParamName == "min-rt") {
1299 } else if (ParamName == "min-rt-abort") {
1301 } else if (ParamName == "merge") {
1302 Options.Merge = true;
1303 } else {
1304 return make_error<StringError>(
1305 formatv("invalid BoundsChecking pass parameter '{0}' ", ParamName)
1306 .str(),
1308 }
1309 }
1310 return Options;
1311}
1312
1313} // namespace
1314
1315/// Tests whether a pass name starts with a valid prefix for a default pipeline
1316/// alias.
1318 return Name.starts_with("default") || Name.starts_with("thinlto") ||
1319 Name.starts_with("lto");
1320}
1321
1322/// Tests whether registered callbacks will accept a given pass name.
1323///
1324/// When parsing a pipeline text, the type of the outermost pipeline may be
1325/// omitted, in which case the type is automatically determined from the first
1326/// pass name in the text. This may be a name that is handled through one of the
1327/// callbacks. We check this through the oridinary parsing callbacks by setting
1328/// up a dummy PassManager in order to not force the client to also handle this
1329/// type of query.
1330template <typename PassManagerT, typename CallbacksT>
1331static bool callbacksAcceptPassName(StringRef Name, CallbacksT &Callbacks) {
1332 if (!Callbacks.empty()) {
1333 PassManagerT DummyPM;
1334 for (auto &CB : Callbacks)
1335 if (CB(Name, DummyPM, {}))
1336 return true;
1337 }
1338 return false;
1339}
1340
1341template <typename CallbacksT>
1342static bool isModulePassName(StringRef Name, CallbacksT &Callbacks) {
1343 // Manually handle aliases for pre-configured pipeline fragments.
1346
1347 StringRef NameNoBracket = Name.take_until([](char C) { return C == '<'; });
1348
1349 // Explicitly handle pass manager names.
1350 if (Name == "module")
1351 return true;
1352 if (Name == "cgscc")
1353 return true;
1354 if (NameNoBracket == "function")
1355 return true;
1356 if (Name == "coro-cond")
1357 return true;
1358
1359#define MODULE_PASS(NAME, CREATE_PASS) \
1360 if (Name == NAME) \
1361 return true;
1362#define MODULE_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1363 if (PassBuilder::checkParametrizedPassName(Name, NAME)) \
1364 return true;
1365#define MODULE_ANALYSIS(NAME, CREATE_PASS) \
1366 if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
1367 return true;
1368#include "PassRegistry.def"
1369
1370 return callbacksAcceptPassName<ModulePassManager>(Name, Callbacks);
1371}
1372
1373template <typename CallbacksT>
1374static bool isCGSCCPassName(StringRef Name, CallbacksT &Callbacks) {
1375 // Explicitly handle pass manager names.
1376 StringRef NameNoBracket = Name.take_until([](char C) { return C == '<'; });
1377 if (Name == "cgscc")
1378 return true;
1379 if (NameNoBracket == "function")
1380 return true;
1381
1382 // Explicitly handle custom-parsed pass names.
1384 return true;
1385
1386#define CGSCC_PASS(NAME, CREATE_PASS) \
1387 if (Name == NAME) \
1388 return true;
1389#define CGSCC_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1390 if (PassBuilder::checkParametrizedPassName(Name, NAME)) \
1391 return true;
1392#define CGSCC_ANALYSIS(NAME, CREATE_PASS) \
1393 if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
1394 return true;
1395#include "PassRegistry.def"
1396
1397 return callbacksAcceptPassName<CGSCCPassManager>(Name, Callbacks);
1398}
1399
1400template <typename CallbacksT>
1401static bool isFunctionPassName(StringRef Name, CallbacksT &Callbacks) {
1402 // Explicitly handle pass manager names.
1403 StringRef NameNoBracket = Name.take_until([](char C) { return C == '<'; });
1404 if (NameNoBracket == "function")
1405 return true;
1406 if (Name == "loop" || Name == "loop-mssa" || Name == "machine-function")
1407 return true;
1408
1409#define FUNCTION_PASS(NAME, CREATE_PASS) \
1410 if (Name == NAME) \
1411 return true;
1412#define FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1413 if (PassBuilder::checkParametrizedPassName(Name, NAME)) \
1414 return true;
1415#define FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
1416 if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
1417 return true;
1418#include "PassRegistry.def"
1419
1420 return callbacksAcceptPassName<FunctionPassManager>(Name, Callbacks);
1421}
1422
1423template <typename CallbacksT>
1424static bool isMachineFunctionPassName(StringRef Name, CallbacksT &Callbacks) {
1425 // Explicitly handle pass manager names.
1426 if (Name == "machine-function")
1427 return true;
1428
1429#define MACHINE_FUNCTION_PASS(NAME, CREATE_PASS) \
1430 if (Name == NAME) \
1431 return true;
1432#define MACHINE_FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, \
1433 PARAMS) \
1434 if (PassBuilder::checkParametrizedPassName(Name, NAME)) \
1435 return true;
1436
1437#define MACHINE_FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
1438 if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
1439 return true;
1440
1441#include "llvm/Passes/MachinePassRegistry.def"
1442
1443 return callbacksAcceptPassName<MachineFunctionPassManager>(Name, Callbacks);
1444}
1445
1446template <typename CallbacksT>
1447static bool isLoopNestPassName(StringRef Name, CallbacksT &Callbacks,
1448 bool &UseMemorySSA) {
1449 UseMemorySSA = false;
1450
1452 UseMemorySSA = true;
1453 return true;
1454 }
1455
1456#define LOOPNEST_PASS(NAME, CREATE_PASS) \
1457 if (Name == NAME) \
1458 return true;
1459#include "PassRegistry.def"
1460
1461 return callbacksAcceptPassName<LoopPassManager>(Name, Callbacks);
1462}
1463
1464template <typename CallbacksT>
1465static bool isLoopPassName(StringRef Name, CallbacksT &Callbacks,
1466 bool &UseMemorySSA) {
1467 UseMemorySSA = false;
1468
1470 UseMemorySSA = true;
1471 return true;
1472 }
1473
1474#define LOOP_PASS(NAME, CREATE_PASS) \
1475 if (Name == NAME) \
1476 return true;
1477#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1478 if (PassBuilder::checkParametrizedPassName(Name, NAME)) \
1479 return true;
1480#define LOOP_ANALYSIS(NAME, CREATE_PASS) \
1481 if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
1482 return true;
1483#include "PassRegistry.def"
1484
1485 return callbacksAcceptPassName<LoopPassManager>(Name, Callbacks);
1486}
1487
1488std::optional<std::vector<PassBuilder::PipelineElement>>
1489PassBuilder::parsePipelineText(StringRef Text) {
1490 std::vector<PipelineElement> ResultPipeline;
1491
1492 SmallVector<std::vector<PipelineElement> *, 4> PipelineStack = {
1493 &ResultPipeline};
1494 for (;;) {
1495 std::vector<PipelineElement> &Pipeline = *PipelineStack.back();
1496 size_t Pos = Text.find_first_of(",()");
1497 Pipeline.push_back({Text.substr(0, Pos), {}});
1498
1499 // If we have a single terminating name, we're done.
1500 if (Pos == Text.npos)
1501 break;
1502
1503 char Sep = Text[Pos];
1504 Text = Text.substr(Pos + 1);
1505 if (Sep == ',')
1506 // Just a name ending in a comma, continue.
1507 continue;
1508
1509 if (Sep == '(') {
1510 // Push the inner pipeline onto the stack to continue processing.
1511 PipelineStack.push_back(&Pipeline.back().InnerPipeline);
1512 continue;
1513 }
1514
1515 assert(Sep == ')' && "Bogus separator!");
1516 // When handling the close parenthesis, we greedily consume them to avoid
1517 // empty strings in the pipeline.
1518 do {
1519 // If we try to pop the outer pipeline we have unbalanced parentheses.
1520 if (PipelineStack.size() == 1)
1521 return std::nullopt;
1522
1523 PipelineStack.pop_back();
1524 } while (Text.consume_front(")"));
1525
1526 // Check if we've finished parsing.
1527 if (Text.empty())
1528 break;
1529
1530 // Otherwise, the end of an inner pipeline always has to be followed by
1531 // a comma, and then we can continue.
1532 if (!Text.consume_front(","))
1533 return std::nullopt;
1534 }
1535
1536 if (PipelineStack.size() > 1)
1537 // Unbalanced paretheses.
1538 return std::nullopt;
1539
1540 assert(PipelineStack.back() == &ResultPipeline &&
1541 "Wrong pipeline at the bottom of the stack!");
1542 return {std::move(ResultPipeline)};
1543}
1544
1545Error PassBuilder::parseModulePass(ModulePassManager &MPM,
1546 const PipelineElement &E) {
1547 auto &Name = E.Name;
1548 auto &InnerPipeline = E.InnerPipeline;
1549
1550 // First handle complex passes like the pass managers which carry pipelines.
1551 if (!InnerPipeline.empty()) {
1552 if (Name == "module") {
1553 ModulePassManager NestedMPM;
1554 if (auto Err = parseModulePassPipeline(NestedMPM, InnerPipeline))
1555 return Err;
1556 MPM.addPass(std::move(NestedMPM));
1557 return Error::success();
1558 }
1559 if (Name == "coro-cond") {
1560 ModulePassManager NestedMPM;
1561 if (auto Err = parseModulePassPipeline(NestedMPM, InnerPipeline))
1562 return Err;
1563 MPM.addPass(CoroConditionalWrapper(std::move(NestedMPM)));
1564 return Error::success();
1565 }
1566 if (Name == "cgscc") {
1567 CGSCCPassManager CGPM;
1568 if (auto Err = parseCGSCCPassPipeline(CGPM, InnerPipeline))
1569 return Err;
1571 return Error::success();
1572 }
1573 if (auto Params = parseFunctionPipelineName(Name)) {
1574 if (Params->second)
1575 return make_error<StringError>(
1576 "cannot have a no-rerun module to function adaptor",
1579 if (auto Err = parseFunctionPassPipeline(FPM, InnerPipeline))
1580 return Err;
1581 MPM.addPass(
1582 createModuleToFunctionPassAdaptor(std::move(FPM), Params->first));
1583 return Error::success();
1584 }
1585
1586 for (auto &C : ModulePipelineParsingCallbacks)
1587 if (C(Name, MPM, InnerPipeline))
1588 return Error::success();
1589
1590 // Normal passes can't have pipelines.
1591 return make_error<StringError>(
1592 formatv("invalid use of '{0}' pass as module pipeline", Name).str(),
1594 ;
1595 }
1596
1597 // Manually handle aliases for pre-configured pipeline fragments.
1600 if (!DefaultAliasRegex.match(Name, &Matches))
1601 return make_error<StringError>(
1602 formatv("unknown default pipeline alias '{0}'", Name).str(),
1604
1605 assert(Matches.size() == 3 && "Must capture two matched strings!");
1606
1607 OptimizationLevel L = *parseOptLevel(Matches[2]);
1608
1609 // This is consistent with old pass manager invoked via opt, but
1610 // inconsistent with clang. Clang doesn't enable loop vectorization
1611 // but does enable slp vectorization at Oz.
1612 PTO.LoopVectorization =
1613 L.getSpeedupLevel() > 1 && L != OptimizationLevel::Oz;
1614 PTO.SLPVectorization =
1615 L.getSpeedupLevel() > 1 && L != OptimizationLevel::Oz;
1616
1617 if (Matches[1] == "default") {
1619 } else if (Matches[1] == "thinlto-pre-link") {
1621 } else if (Matches[1] == "thinlto") {
1622 MPM.addPass(buildThinLTODefaultPipeline(L, nullptr));
1623 } else if (Matches[1] == "lto-pre-link") {
1624 if (PTO.UnifiedLTO)
1625 // When UnifiedLTO is enabled, use the ThinLTO pre-link pipeline. This
1626 // avoids compile-time performance regressions and keeps the pre-link
1627 // LTO pipeline "unified" for both LTO modes.
1629 else
1631 } else {
1632 assert(Matches[1] == "lto" && "Not one of the matched options!");
1633 MPM.addPass(buildLTODefaultPipeline(L, nullptr));
1634 }
1635 return Error::success();
1636 }
1637
1638 // Finally expand the basic registered passes from the .inc file.
1639#define MODULE_PASS(NAME, CREATE_PASS) \
1640 if (Name == NAME) { \
1641 MPM.addPass(CREATE_PASS); \
1642 return Error::success(); \
1643 }
1644#define MODULE_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1645 if (checkParametrizedPassName(Name, NAME)) { \
1646 auto Params = parsePassParameters(PARSER, Name, NAME); \
1647 if (!Params) \
1648 return Params.takeError(); \
1649 MPM.addPass(CREATE_PASS(Params.get())); \
1650 return Error::success(); \
1651 }
1652#define MODULE_ANALYSIS(NAME, CREATE_PASS) \
1653 if (Name == "require<" NAME ">") { \
1654 MPM.addPass( \
1655 RequireAnalysisPass< \
1656 std::remove_reference_t<decltype(CREATE_PASS)>, Module>()); \
1657 return Error::success(); \
1658 } \
1659 if (Name == "invalidate<" NAME ">") { \
1660 MPM.addPass(InvalidateAnalysisPass< \
1661 std::remove_reference_t<decltype(CREATE_PASS)>>()); \
1662 return Error::success(); \
1663 }
1664#define CGSCC_PASS(NAME, CREATE_PASS) \
1665 if (Name == NAME) { \
1666 MPM.addPass(createModuleToPostOrderCGSCCPassAdaptor(CREATE_PASS)); \
1667 return Error::success(); \
1668 }
1669#define CGSCC_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1670 if (checkParametrizedPassName(Name, NAME)) { \
1671 auto Params = parsePassParameters(PARSER, Name, NAME); \
1672 if (!Params) \
1673 return Params.takeError(); \
1674 MPM.addPass( \
1675 createModuleToPostOrderCGSCCPassAdaptor(CREATE_PASS(Params.get()))); \
1676 return Error::success(); \
1677 }
1678#define FUNCTION_PASS(NAME, CREATE_PASS) \
1679 if (Name == NAME) { \
1680 MPM.addPass(createModuleToFunctionPassAdaptor(CREATE_PASS)); \
1681 return Error::success(); \
1682 }
1683#define FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1684 if (checkParametrizedPassName(Name, NAME)) { \
1685 auto Params = parsePassParameters(PARSER, Name, NAME); \
1686 if (!Params) \
1687 return Params.takeError(); \
1688 MPM.addPass(createModuleToFunctionPassAdaptor(CREATE_PASS(Params.get()))); \
1689 return Error::success(); \
1690 }
1691#define LOOPNEST_PASS(NAME, CREATE_PASS) \
1692 if (Name == NAME) { \
1693 MPM.addPass(createModuleToFunctionPassAdaptor( \
1694 createFunctionToLoopPassAdaptor(CREATE_PASS, false, false))); \
1695 return Error::success(); \
1696 }
1697#define LOOP_PASS(NAME, CREATE_PASS) \
1698 if (Name == NAME) { \
1699 MPM.addPass(createModuleToFunctionPassAdaptor( \
1700 createFunctionToLoopPassAdaptor(CREATE_PASS, false, false))); \
1701 return Error::success(); \
1702 }
1703#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1704 if (checkParametrizedPassName(Name, NAME)) { \
1705 auto Params = parsePassParameters(PARSER, Name, NAME); \
1706 if (!Params) \
1707 return Params.takeError(); \
1708 MPM.addPass( \
1709 createModuleToFunctionPassAdaptor(createFunctionToLoopPassAdaptor( \
1710 CREATE_PASS(Params.get()), false, false))); \
1711 return Error::success(); \
1712 }
1713#include "PassRegistry.def"
1714
1715 for (auto &C : ModulePipelineParsingCallbacks)
1716 if (C(Name, MPM, InnerPipeline))
1717 return Error::success();
1718 return make_error<StringError>(
1719 formatv("unknown module pass '{0}'", Name).str(),
1721}
1722
1723Error PassBuilder::parseCGSCCPass(CGSCCPassManager &CGPM,
1724 const PipelineElement &E) {
1725 auto &Name = E.Name;
1726 auto &InnerPipeline = E.InnerPipeline;
1727
1728 // First handle complex passes like the pass managers which carry pipelines.
1729 if (!InnerPipeline.empty()) {
1730 if (Name == "cgscc") {
1731 CGSCCPassManager NestedCGPM;
1732 if (auto Err = parseCGSCCPassPipeline(NestedCGPM, InnerPipeline))
1733 return Err;
1734 // Add the nested pass manager with the appropriate adaptor.
1735 CGPM.addPass(std::move(NestedCGPM));
1736 return Error::success();
1737 }
1738 if (auto Params = parseFunctionPipelineName(Name)) {
1740 if (auto Err = parseFunctionPassPipeline(FPM, InnerPipeline))
1741 return Err;
1742 // Add the nested pass manager with the appropriate adaptor.
1744 std::move(FPM), Params->first, Params->second));
1745 return Error::success();
1746 }
1747 if (auto MaxRepetitions = parseDevirtPassName(Name)) {
1748 CGSCCPassManager NestedCGPM;
1749 if (auto Err = parseCGSCCPassPipeline(NestedCGPM, InnerPipeline))
1750 return Err;
1751 CGPM.addPass(
1752 createDevirtSCCRepeatedPass(std::move(NestedCGPM), *MaxRepetitions));
1753 return Error::success();
1754 }
1755
1756 for (auto &C : CGSCCPipelineParsingCallbacks)
1757 if (C(Name, CGPM, InnerPipeline))
1758 return Error::success();
1759
1760 // Normal passes can't have pipelines.
1761 return make_error<StringError>(
1762 formatv("invalid use of '{0}' pass as cgscc pipeline", Name).str(),
1764 }
1765
1766// Now expand the basic registered passes from the .inc file.
1767#define CGSCC_PASS(NAME, CREATE_PASS) \
1768 if (Name == NAME) { \
1769 CGPM.addPass(CREATE_PASS); \
1770 return Error::success(); \
1771 }
1772#define CGSCC_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1773 if (checkParametrizedPassName(Name, NAME)) { \
1774 auto Params = parsePassParameters(PARSER, Name, NAME); \
1775 if (!Params) \
1776 return Params.takeError(); \
1777 CGPM.addPass(CREATE_PASS(Params.get())); \
1778 return Error::success(); \
1779 }
1780#define CGSCC_ANALYSIS(NAME, CREATE_PASS) \
1781 if (Name == "require<" NAME ">") { \
1782 CGPM.addPass(RequireAnalysisPass< \
1783 std::remove_reference_t<decltype(CREATE_PASS)>, \
1784 LazyCallGraph::SCC, CGSCCAnalysisManager, LazyCallGraph &, \
1785 CGSCCUpdateResult &>()); \
1786 return Error::success(); \
1787 } \
1788 if (Name == "invalidate<" NAME ">") { \
1789 CGPM.addPass(InvalidateAnalysisPass< \
1790 std::remove_reference_t<decltype(CREATE_PASS)>>()); \
1791 return Error::success(); \
1792 }
1793#define FUNCTION_PASS(NAME, CREATE_PASS) \
1794 if (Name == NAME) { \
1795 CGPM.addPass(createCGSCCToFunctionPassAdaptor(CREATE_PASS)); \
1796 return Error::success(); \
1797 }
1798#define FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1799 if (checkParametrizedPassName(Name, NAME)) { \
1800 auto Params = parsePassParameters(PARSER, Name, NAME); \
1801 if (!Params) \
1802 return Params.takeError(); \
1803 CGPM.addPass(createCGSCCToFunctionPassAdaptor(CREATE_PASS(Params.get()))); \
1804 return Error::success(); \
1805 }
1806#define LOOPNEST_PASS(NAME, CREATE_PASS) \
1807 if (Name == NAME) { \
1808 CGPM.addPass(createCGSCCToFunctionPassAdaptor( \
1809 createFunctionToLoopPassAdaptor(CREATE_PASS, false, false))); \
1810 return Error::success(); \
1811 }
1812#define LOOP_PASS(NAME, CREATE_PASS) \
1813 if (Name == NAME) { \
1814 CGPM.addPass(createCGSCCToFunctionPassAdaptor( \
1815 createFunctionToLoopPassAdaptor(CREATE_PASS, false, false))); \
1816 return Error::success(); \
1817 }
1818#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1819 if (checkParametrizedPassName(Name, NAME)) { \
1820 auto Params = parsePassParameters(PARSER, Name, NAME); \
1821 if (!Params) \
1822 return Params.takeError(); \
1823 CGPM.addPass( \
1824 createCGSCCToFunctionPassAdaptor(createFunctionToLoopPassAdaptor( \
1825 CREATE_PASS(Params.get()), false, false))); \
1826 return Error::success(); \
1827 }
1828#include "PassRegistry.def"
1829
1830 for (auto &C : CGSCCPipelineParsingCallbacks)
1831 if (C(Name, CGPM, InnerPipeline))
1832 return Error::success();
1833 return make_error<StringError>(
1834 formatv("unknown cgscc pass '{0}'", Name).str(),
1836}
1837
1838Error PassBuilder::parseFunctionPass(FunctionPassManager &FPM,
1839 const PipelineElement &E) {
1840 auto &Name = E.Name;
1841 auto &InnerPipeline = E.InnerPipeline;
1842
1843 // First handle complex passes like the pass managers which carry pipelines.
1844 if (!InnerPipeline.empty()) {
1845 if (Name == "function") {
1846 FunctionPassManager NestedFPM;
1847 if (auto Err = parseFunctionPassPipeline(NestedFPM, InnerPipeline))
1848 return Err;
1849 // Add the nested pass manager with the appropriate adaptor.
1850 FPM.addPass(std::move(NestedFPM));
1851 return Error::success();
1852 }
1853 if (Name == "loop" || Name == "loop-mssa") {
1854 LoopPassManager LPM;
1855 if (auto Err = parseLoopPassPipeline(LPM, InnerPipeline))
1856 return Err;
1857 // Add the nested pass manager with the appropriate adaptor.
1858 bool UseMemorySSA = (Name == "loop-mssa");
1859 bool UseBFI = llvm::any_of(InnerPipeline, [](auto Pipeline) {
1860 return Pipeline.Name.contains("simple-loop-unswitch");
1861 });
1862 bool UseBPI = llvm::any_of(InnerPipeline, [](auto Pipeline) {
1863 return Pipeline.Name == "loop-predication";
1864 });
1865 FPM.addPass(createFunctionToLoopPassAdaptor(std::move(LPM), UseMemorySSA,
1866 UseBFI, UseBPI));
1867 return Error::success();
1868 }
1869 if (Name == "machine-function") {
1871 if (auto Err = parseMachinePassPipeline(MFPM, InnerPipeline))
1872 return Err;
1874 return Error::success();
1875 }
1876
1877 for (auto &C : FunctionPipelineParsingCallbacks)
1878 if (C(Name, FPM, InnerPipeline))
1879 return Error::success();
1880
1881 // Normal passes can't have pipelines.
1882 return make_error<StringError>(
1883 formatv("invalid use of '{0}' pass as function pipeline", Name).str(),
1885 }
1886
1887// Now expand the basic registered passes from the .inc file.
1888#define FUNCTION_PASS(NAME, CREATE_PASS) \
1889 if (Name == NAME) { \
1890 FPM.addPass(CREATE_PASS); \
1891 return Error::success(); \
1892 }
1893#define FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1894 if (checkParametrizedPassName(Name, NAME)) { \
1895 auto Params = parsePassParameters(PARSER, Name, NAME); \
1896 if (!Params) \
1897 return Params.takeError(); \
1898 FPM.addPass(CREATE_PASS(Params.get())); \
1899 return Error::success(); \
1900 }
1901#define FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
1902 if (Name == "require<" NAME ">") { \
1903 FPM.addPass( \
1904 RequireAnalysisPass< \
1905 std::remove_reference_t<decltype(CREATE_PASS)>, Function>()); \
1906 return Error::success(); \
1907 } \
1908 if (Name == "invalidate<" NAME ">") { \
1909 FPM.addPass(InvalidateAnalysisPass< \
1910 std::remove_reference_t<decltype(CREATE_PASS)>>()); \
1911 return Error::success(); \
1912 }
1913// FIXME: UseMemorySSA is set to false. Maybe we could do things like:
1914// bool UseMemorySSA = !("canon-freeze" || "loop-predication" ||
1915// "guard-widening");
1916// The risk is that it may become obsolete if we're not careful.
1917#define LOOPNEST_PASS(NAME, CREATE_PASS) \
1918 if (Name == NAME) { \
1919 FPM.addPass(createFunctionToLoopPassAdaptor(CREATE_PASS, false, false)); \
1920 return Error::success(); \
1921 }
1922#define LOOP_PASS(NAME, CREATE_PASS) \
1923 if (Name == NAME) { \
1924 FPM.addPass(createFunctionToLoopPassAdaptor(CREATE_PASS, false, false)); \
1925 return Error::success(); \
1926 }
1927#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1928 if (checkParametrizedPassName(Name, NAME)) { \
1929 auto Params = parsePassParameters(PARSER, Name, NAME); \
1930 if (!Params) \
1931 return Params.takeError(); \
1932 FPM.addPass(createFunctionToLoopPassAdaptor(CREATE_PASS(Params.get()), \
1933 false, false)); \
1934 return Error::success(); \
1935 }
1936#include "PassRegistry.def"
1937
1938 for (auto &C : FunctionPipelineParsingCallbacks)
1939 if (C(Name, FPM, InnerPipeline))
1940 return Error::success();
1941 return make_error<StringError>(
1942 formatv("unknown function pass '{0}'", Name).str(),
1944}
1945
1946Error PassBuilder::parseLoopPass(LoopPassManager &LPM,
1947 const PipelineElement &E) {
1948 StringRef Name = E.Name;
1949 auto &InnerPipeline = E.InnerPipeline;
1950
1951 // First handle complex passes like the pass managers which carry pipelines.
1952 if (!InnerPipeline.empty()) {
1953 if (Name == "loop") {
1954 LoopPassManager NestedLPM;
1955 if (auto Err = parseLoopPassPipeline(NestedLPM, InnerPipeline))
1956 return Err;
1957 // Add the nested pass manager with the appropriate adaptor.
1958 LPM.addPass(std::move(NestedLPM));
1959 return Error::success();
1960 }
1961
1962 for (auto &C : LoopPipelineParsingCallbacks)
1963 if (C(Name, LPM, InnerPipeline))
1964 return Error::success();
1965
1966 // Normal passes can't have pipelines.
1967 return make_error<StringError>(
1968 formatv("invalid use of '{0}' pass as loop pipeline", Name).str(),
1970 }
1971
1972// Now expand the basic registered passes from the .inc file.
1973#define LOOPNEST_PASS(NAME, CREATE_PASS) \
1974 if (Name == NAME) { \
1975 LPM.addPass(CREATE_PASS); \
1976 return Error::success(); \
1977 }
1978#define LOOP_PASS(NAME, CREATE_PASS) \
1979 if (Name == NAME) { \
1980 LPM.addPass(CREATE_PASS); \
1981 return Error::success(); \
1982 }
1983#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1984 if (checkParametrizedPassName(Name, NAME)) { \
1985 auto Params = parsePassParameters(PARSER, Name, NAME); \
1986 if (!Params) \
1987 return Params.takeError(); \
1988 LPM.addPass(CREATE_PASS(Params.get())); \
1989 return Error::success(); \
1990 }
1991#define LOOP_ANALYSIS(NAME, CREATE_PASS) \
1992 if (Name == "require<" NAME ">") { \
1993 LPM.addPass(RequireAnalysisPass< \
1994 std::remove_reference_t<decltype(CREATE_PASS)>, Loop, \
1995 LoopAnalysisManager, LoopStandardAnalysisResults &, \
1996 LPMUpdater &>()); \
1997 return Error::success(); \
1998 } \
1999 if (Name == "invalidate<" NAME ">") { \
2000 LPM.addPass(InvalidateAnalysisPass< \
2001 std::remove_reference_t<decltype(CREATE_PASS)>>()); \
2002 return Error::success(); \
2003 }
2004#include "PassRegistry.def"
2005
2006 for (auto &C : LoopPipelineParsingCallbacks)
2007 if (C(Name, LPM, InnerPipeline))
2008 return Error::success();
2009 return make_error<StringError>(formatv("unknown loop pass '{0}'", Name).str(),
2011}
2012
2013Error PassBuilder::parseMachinePass(MachineFunctionPassManager &MFPM,
2014 const PipelineElement &E) {
2015 StringRef Name = E.Name;
2016 if (!E.InnerPipeline.empty())
2017 return make_error<StringError>("invalid pipeline",
2019
2020#define MACHINE_MODULE_PASS(NAME, CREATE_PASS) \
2021 if (Name == NAME) { \
2022 MFPM.addPass(CREATE_PASS); \
2023 return Error::success(); \
2024 }
2025#define MACHINE_FUNCTION_PASS(NAME, CREATE_PASS) \
2026 if (Name == NAME) { \
2027 MFPM.addPass(CREATE_PASS); \
2028 return Error::success(); \
2029 }
2030#define MACHINE_FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, \
2031 PARAMS) \
2032 if (checkParametrizedPassName(Name, NAME)) { \
2033 auto Params = parsePassParameters(PARSER, Name, NAME); \
2034 if (!Params) \
2035 return Params.takeError(); \
2036 MFPM.addPass(CREATE_PASS(Params.get())); \
2037 return Error::success(); \
2038 }
2039#define MACHINE_FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
2040 if (Name == "require<" NAME ">") { \
2041 MFPM.addPass( \
2042 RequireAnalysisPass<std::remove_reference_t<decltype(CREATE_PASS)>, \
2043 MachineFunction>()); \
2044 return Error::success(); \
2045 } \
2046 if (Name == "invalidate<" NAME ">") { \
2047 MFPM.addPass(InvalidateAnalysisPass< \
2048 std::remove_reference_t<decltype(CREATE_PASS)>>()); \
2049 return Error::success(); \
2050 }
2051#include "llvm/Passes/MachinePassRegistry.def"
2052
2053 for (auto &C : MachineFunctionPipelineParsingCallbacks)
2054 if (C(Name, MFPM, E.InnerPipeline))
2055 return Error::success();
2056 return make_error<StringError>(
2057 formatv("unknown machine pass '{0}'", Name).str(),
2059}
2060
2061bool PassBuilder::parseAAPassName(AAManager &AA, StringRef Name) {
2062#define MODULE_ALIAS_ANALYSIS(NAME, CREATE_PASS) \
2063 if (Name == NAME) { \
2064 AA.registerModuleAnalysis< \
2065 std::remove_reference_t<decltype(CREATE_PASS)>>(); \
2066 return true; \
2067 }
2068#define FUNCTION_ALIAS_ANALYSIS(NAME, CREATE_PASS) \
2069 if (Name == NAME) { \
2070 AA.registerFunctionAnalysis< \
2071 std::remove_reference_t<decltype(CREATE_PASS)>>(); \
2072 return true; \
2073 }
2074#include "PassRegistry.def"
2075
2076 for (auto &C : AAParsingCallbacks)
2077 if (C(Name, AA))
2078 return true;
2079 return false;
2080}
2081
2082Error PassBuilder::parseMachinePassPipeline(
2084 for (const auto &Element : Pipeline) {
2085 if (auto Err = parseMachinePass(MFPM, Element))
2086 return Err;
2087 }
2088 return Error::success();
2089}
2090
2091Error PassBuilder::parseLoopPassPipeline(LoopPassManager &LPM,
2092 ArrayRef<PipelineElement> Pipeline) {
2093 for (const auto &Element : Pipeline) {
2094 if (auto Err = parseLoopPass(LPM, Element))
2095 return Err;
2096 }
2097 return Error::success();
2098}
2099
2100Error PassBuilder::parseFunctionPassPipeline(
2102 for (const auto &Element : Pipeline) {
2103 if (auto Err = parseFunctionPass(FPM, Element))
2104 return Err;
2105 }
2106 return Error::success();
2107}
2108
2109Error PassBuilder::parseCGSCCPassPipeline(CGSCCPassManager &CGPM,
2110 ArrayRef<PipelineElement> Pipeline) {
2111 for (const auto &Element : Pipeline) {
2112 if (auto Err = parseCGSCCPass(CGPM, Element))
2113 return Err;
2114 }
2115 return Error::success();
2116}
2117
2130 if (MFAM) {
2132 [&] { return MachineFunctionAnalysisManagerModuleProxy(*MFAM); });
2134 [&] { return MachineFunctionAnalysisManagerFunctionProxy(*MFAM); });
2135 MFAM->registerPass(
2137 MFAM->registerPass(
2139 }
2140}
2141
2142Error PassBuilder::parseModulePassPipeline(ModulePassManager &MPM,
2143 ArrayRef<PipelineElement> Pipeline) {
2144 for (const auto &Element : Pipeline) {
2145 if (auto Err = parseModulePass(MPM, Element))
2146 return Err;
2147 }
2148 return Error::success();
2149}
2150
2151// Primary pass pipeline description parsing routine for a \c ModulePassManager
2152// FIXME: Should this routine accept a TargetMachine or require the caller to
2153// pre-populate the analysis managers with target-specific stuff?
2155 StringRef PipelineText) {
2156 auto Pipeline = parsePipelineText(PipelineText);
2157 if (!Pipeline || Pipeline->empty())
2158 return make_error<StringError>(
2159 formatv("invalid pipeline '{0}'", PipelineText).str(),
2161
2162 // If the first name isn't at the module layer, wrap the pipeline up
2163 // automatically.
2164 StringRef FirstName = Pipeline->front().Name;
2165
2166 if (!isModulePassName(FirstName, ModulePipelineParsingCallbacks)) {
2167 bool UseMemorySSA;
2168 if (isCGSCCPassName(FirstName, CGSCCPipelineParsingCallbacks)) {
2169 Pipeline = {{"cgscc", std::move(*Pipeline)}};
2170 } else if (isFunctionPassName(FirstName,
2171 FunctionPipelineParsingCallbacks)) {
2172 Pipeline = {{"function", std::move(*Pipeline)}};
2173 } else if (isLoopNestPassName(FirstName, LoopPipelineParsingCallbacks,
2174 UseMemorySSA)) {
2175 Pipeline = {{"function", {{UseMemorySSA ? "loop-mssa" : "loop",
2176 std::move(*Pipeline)}}}};
2177 } else if (isLoopPassName(FirstName, LoopPipelineParsingCallbacks,
2178 UseMemorySSA)) {
2179 Pipeline = {{"function", {{UseMemorySSA ? "loop-mssa" : "loop",
2180 std::move(*Pipeline)}}}};
2181 } else if (isMachineFunctionPassName(
2182 FirstName, MachineFunctionPipelineParsingCallbacks)) {
2183 Pipeline = {{"function", {{"machine-function", std::move(*Pipeline)}}}};
2184 } else {
2185 for (auto &C : TopLevelPipelineParsingCallbacks)
2186 if (C(MPM, *Pipeline))
2187 return Error::success();
2188
2189 // Unknown pass or pipeline name!
2190 auto &InnerPipeline = Pipeline->front().InnerPipeline;
2191 return make_error<StringError>(
2192 formatv("unknown {0} name '{1}'",
2193 (InnerPipeline.empty() ? "pass" : "pipeline"), FirstName)
2194 .str(),
2196 }
2197 }
2198
2199 if (auto Err = parseModulePassPipeline(MPM, *Pipeline))
2200 return Err;
2201 return Error::success();
2202}
2203
2204// Primary pass pipeline description parsing routine for a \c CGSCCPassManager
2206 StringRef PipelineText) {
2207 auto Pipeline = parsePipelineText(PipelineText);
2208 if (!Pipeline || Pipeline->empty())
2209 return make_error<StringError>(
2210 formatv("invalid pipeline '{0}'", PipelineText).str(),
2212
2213 StringRef FirstName = Pipeline->front().Name;
2214 if (!isCGSCCPassName(FirstName, CGSCCPipelineParsingCallbacks))
2215 return make_error<StringError>(
2216 formatv("unknown cgscc pass '{0}' in pipeline '{1}'", FirstName,
2217 PipelineText)
2218 .str(),
2220
2221 if (auto Err = parseCGSCCPassPipeline(CGPM, *Pipeline))
2222 return Err;
2223 return Error::success();
2224}
2225
2226// Primary pass pipeline description parsing routine for a \c
2227// FunctionPassManager
2229 StringRef PipelineText) {
2230 auto Pipeline = parsePipelineText(PipelineText);
2231 if (!Pipeline || Pipeline->empty())
2232 return make_error<StringError>(
2233 formatv("invalid pipeline '{0}'", PipelineText).str(),
2235
2236 StringRef FirstName = Pipeline->front().Name;
2237 if (!isFunctionPassName(FirstName, FunctionPipelineParsingCallbacks))
2238 return make_error<StringError>(
2239 formatv("unknown function pass '{0}' in pipeline '{1}'", FirstName,
2240 PipelineText)
2241 .str(),
2243
2244 if (auto Err = parseFunctionPassPipeline(FPM, *Pipeline))
2245 return Err;
2246 return Error::success();
2247}
2248
2249// Primary pass pipeline description parsing routine for a \c LoopPassManager
2251 StringRef PipelineText) {
2252 auto Pipeline = parsePipelineText(PipelineText);
2253 if (!Pipeline || Pipeline->empty())
2254 return make_error<StringError>(
2255 formatv("invalid pipeline '{0}'", PipelineText).str(),
2257
2258 if (auto Err = parseLoopPassPipeline(CGPM, *Pipeline))
2259 return Err;
2260
2261 return Error::success();
2262}
2263
2265 StringRef PipelineText) {
2266 auto Pipeline = parsePipelineText(PipelineText);
2267 if (!Pipeline || Pipeline->empty())
2268 return make_error<StringError>(
2269 formatv("invalid machine pass pipeline '{0}'", PipelineText).str(),
2271
2272 if (auto Err = parseMachinePassPipeline(MFPM, *Pipeline))
2273 return Err;
2274
2275 return Error::success();
2276}
2277
2279 // If the pipeline just consists of the word 'default' just replace the AA
2280 // manager with our default one.
2281 if (PipelineText == "default") {
2283 return Error::success();
2284 }
2285
2286 while (!PipelineText.empty()) {
2288 std::tie(Name, PipelineText) = PipelineText.split(',');
2289 if (!parseAAPassName(AA, Name))
2290 return make_error<StringError>(
2291 formatv("unknown alias analysis name '{0}'", Name).str(),
2293 }
2294
2295 return Error::success();
2296}
2297
2298std::optional<RegAllocFilterFunc>
2300 if (FilterName == "all")
2301 return nullptr;
2302 for (auto &C : RegClassFilterParsingCallbacks)
2303 if (auto F = C(FilterName))
2304 return F;
2305 return std::nullopt;
2306}
2307
2309 OS << " " << PassName << "\n";
2310}
2312 raw_ostream &OS) {
2313 OS << " " << PassName << "<" << Params << ">\n";
2314}
2315
2317 // TODO: print pass descriptions when they are available
2318
2319 OS << "Module passes:\n";
2320#define MODULE_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2321#include "PassRegistry.def"
2322
2323 OS << "Module passes with params:\n";
2324#define MODULE_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
2325 printPassName(NAME, PARAMS, OS);
2326#include "PassRegistry.def"
2327
2328 OS << "Module analyses:\n";
2329#define MODULE_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2330#include "PassRegistry.def"
2331
2332 OS << "Module alias analyses:\n";
2333#define MODULE_ALIAS_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2334#include "PassRegistry.def"
2335
2336 OS << "CGSCC passes:\n";
2337#define CGSCC_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2338#include "PassRegistry.def"
2339
2340 OS << "CGSCC passes with params:\n";
2341#define CGSCC_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
2342 printPassName(NAME, PARAMS, OS);
2343#include "PassRegistry.def"
2344
2345 OS << "CGSCC analyses:\n";
2346#define CGSCC_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2347#include "PassRegistry.def"
2348
2349 OS << "Function passes:\n";
2350#define FUNCTION_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2351#include "PassRegistry.def"
2352
2353 OS << "Function passes with params:\n";
2354#define FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
2355 printPassName(NAME, PARAMS, OS);
2356#include "PassRegistry.def"
2357
2358 OS << "Function analyses:\n";
2359#define FUNCTION_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2360#include "PassRegistry.def"
2361
2362 OS << "Function alias analyses:\n";
2363#define FUNCTION_ALIAS_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2364#include "PassRegistry.def"
2365
2366 OS << "LoopNest passes:\n";
2367#define LOOPNEST_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2368#include "PassRegistry.def"
2369
2370 OS << "Loop passes:\n";
2371#define LOOP_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2372#include "PassRegistry.def"
2373
2374 OS << "Loop passes with params:\n";
2375#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
2376 printPassName(NAME, PARAMS, OS);
2377#include "PassRegistry.def"
2378
2379 OS << "Loop analyses:\n";
2380#define LOOP_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2381#include "PassRegistry.def"
2382
2383 OS << "Machine module passes (WIP):\n";
2384#define MACHINE_MODULE_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2385#include "llvm/Passes/MachinePassRegistry.def"
2386
2387 OS << "Machine function passes (WIP):\n";
2388#define MACHINE_FUNCTION_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2389#include "llvm/Passes/MachinePassRegistry.def"
2390
2391 OS << "Machine function analyses (WIP):\n";
2392#define MACHINE_FUNCTION_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2393#include "llvm/Passes/MachinePassRegistry.def"
2394}
2395
2397 const std::function<bool(ModulePassManager &, ArrayRef<PipelineElement>)>
2398 &C) {
2399 TopLevelPipelineParsingCallbacks.push_back(C);
2400}
unsigned const MachineRegisterInfo * MRI
AggressiveInstCombiner - Combine expression patterns to form expressions with fewer,...
This file implements a simple N^2 alias analysis accuracy evaluator.
Provides passes to inlining "always_inline" functions.
This is the interface for LLVM's primary stateless and local alias analysis.
This file provides the interface for LLVM's Call Graph Profile pass.
This header provides classes for managing passes over SCCs of the call graph.
This file provides interfaces used to build and manipulate a call graph, which is a very useful tool ...
Defines an IR pass for CodeGen Prepare.
This file declares an analysis pass that computes CycleInfo for LLVM IR, specialized from GenericCycl...
std::string Name
This file provides the interface for a simple, fast CSE pass.
This file provides a pass which clones the current module and runs the provided pass pipeline on the ...
This file provides a pass manager that only runs its passes if the provided marker analysis has been ...
Super simple passes to force specific function attrs from the commandline into the IR for debugging p...
Provides passes for computing function attributes based on interprocedural analyses.
This file provides the interface for the GCOV style profiler pass.
This file provides the interface for LLVM's Global Value Numbering pass which eliminates fully redund...
This is the interface for a simple mod/ref and alias analysis over globals.
Defines an IR pass for the creation of hardware loops.
#define _
AcceleratorCodeSelection - Identify all functions reachable from a kernel, removing those that are un...
This file defines passes to print out IR in various granularities.
This header defines various interfaces for pass management in LLVM.
Interfaces for passes which infer implicit function attributes from the name and signature of functio...
This file provides the primary interface to the instcombine pass.
Defines passes for running instruction simplification across chunks of IR.
This file provides the interface for LLVM's PGO Instrumentation lowering pass.
This file contains the declaration of the InterleavedAccessPass class, its corresponding pass name is...
See the comments on JumpThreadingPass.
static LVOptions Options
Definition: LVOptions.cpp:25
Implements a lazy call graph analysis and related passes for the new pass manager.
This file defines the interface for the loop cache analysis.
This file provides the interface for LLVM's Loop Data Prefetching Pass.
This file implements the Loop Fusion pass.
This header defines the LoopLoadEliminationPass object.
This file defines the interface for the loop nest analysis.
This header provides classes for managing a pipeline of passes over loops in LLVM IR.
This file provides the interface for the pass responsible for removing expensive ubsan checks.
The header file for the LowerConstantIntrinsics pass as used by the new pass manager.
The header file for the LowerExpectIntrinsic pass as used by the new pass manager.
#define F(x, y, z)
Definition: MD5.cpp:55
UseBFI
Definition: MachineLICM.cpp:89
===- MachineOptimizationRemarkEmitter.h - Opt Diagnostics -*- C++ -*-—===//
This file exposes an interface to building/using memory SSA to walk memory instructions using a use/d...
This pass performs merges of loads and stores on both sides of a.
This is the interface to build a ModuleSummaryIndex for a module.
Contains a collection of routines for determining if a given instruction is guaranteed to execute if ...
This file provides the interface for LLVM's Global Value Numbering pass.
This file declares a simple ARC-aware AliasAnalysis using special knowledge of Objective C to enhance...
This header enumerates the LLVM-provided high-level optimization levels.
This file provides the interface for IR based instrumentation passes ( (profile-gen,...
CGSCCAnalysisManager CGAM
LoopAnalysisManager LAM
FunctionAnalysisManager FAM
ModuleAnalysisManager MAM
PassInstrumentationCallbacks PIC
PassBuilder PB(Machine, PassOpts->PTO, std::nullopt, &PIC)
static bool isModulePassName(StringRef Name, CallbacksT &Callbacks)
static bool callbacksAcceptPassName(StringRef Name, CallbacksT &Callbacks)
Tests whether registered callbacks will accept a given pass name.
static std::optional< int > parseDevirtPassName(StringRef Name)
static bool startsWithDefaultPipelineAliasPrefix(StringRef Name)
Tests whether a pass name starts with a valid prefix for a default pipeline alias.
static bool isLoopNestPassName(StringRef Name, CallbacksT &Callbacks, bool &UseMemorySSA)
static bool isMachineFunctionPassName(StringRef Name, CallbacksT &Callbacks)
static std::optional< OptimizationLevel > parseOptLevel(StringRef S)
static bool isLoopPassName(StringRef Name, CallbacksT &Callbacks, bool &UseMemorySSA)
static std::optional< std::pair< bool, bool > > parseFunctionPipelineName(StringRef Name)
static bool isCGSCCPassName(StringRef Name, CallbacksT &Callbacks)
static void printPassName(StringRef PassName, raw_ostream &OS)
static bool isFunctionPassName(StringRef Name, CallbacksT &Callbacks)
static const Regex DefaultAliasRegex("^(default|thinlto-pre-link|thinlto|lto-pre-link|lto)<(O[0123sz])>$")
This file implements the PredicateInfo analysis, which creates an Extended SSA form for operations us...
This pass is required to take advantage of the interprocedural register allocation infrastructure.
This file implements relative lookup table converter that converts lookup tables to relative lookup t...
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file provides the interface for LLVM's Scalar Replacement of Aggregates pass.
raw_pwrite_stream & OS
This file provides the interface for the pseudo probe implementation for AutoFDO.
This file provides the interface for the sampled PGO loader pass.
This is the interface for a SCEV-based alias analysis.
This pass converts vector operations into scalar operations (or, optionally, operations on smaller ve...
This is the interface for a metadata-based scoped no-alias analysis.
This file contains the declaration of the SelectOptimizePass class, its corresponding pass name is se...
This file provides the interface for the pass responsible for both simplifying and canonicalizing the...
This file implements the StringSwitch template, which mimics a switch() statement whose cases are str...
Target-Independent Code Generator Pass Configuration Options pass.
This pass exposes codegen information to IR-level passes.
This is the interface for a metadata-based TBAA.
Defines an IR pass for type promotion.
LLVM IR instance of the generic uniformity analysis.
static const char PassName[]
Value * RHS
A manager for alias analyses.
Class for arbitrary precision integers.
Definition: APInt.h:78
uint64_t getZExtValue() const
Get zero extended value.
Definition: APInt.h:1520
int64_t getSExtValue() const
Get sign extended value.
Definition: APInt.h:1542
A container for analyses that lazily runs them and caches their results.
Definition: PassManager.h:253
bool registerPass(PassBuilderT &&PassBuilder)
Register an analysis pass with the manager.
Definition: PassManager.h:471
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: ArrayRef.h:41
LLVM Basic Block Representation.
Definition: BasicBlock.h:61
const Instruction * getTerminator() const LLVM_READONLY
Returns the terminator instruction if the block is well formed or null if the block is not well forme...
Definition: BasicBlock.h:239
Lightweight error class with error context and mandatory checking.
Definition: Error.h:160
static ErrorSuccess success()
Create a success value.
Definition: Error.h:337
Tagged union holding either a T or a Error.
Definition: Error.h:481
static GlobalAlias * create(Type *Ty, unsigned AddressSpace, LinkageTypes Linkage, const Twine &Name, Constant *Aliasee, Module *Parent)
If a parent module is specified, the alias is automatically inserted into the end of the specified mo...
Definition: Globals.cpp:557
An analysis over an "outer" IR unit that provides access to an analysis manager over an "inner" IR un...
Definition: PassManager.h:567
static constexpr LLT scalar(unsigned SizeInBits)
Get a low-level scalar or aggregate "bag of bits".
Definition: LowLevelType.h:42
An RAII based helper class to modify MachineFunctionProperties when running pass.
Properties which a MachineFunction may have at a given point in time.
MachineFunctionProperties & set(Property P)
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
const MachineFunctionProperties & getProperties() const
Get the function properties.
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:65
static const OptimizationLevel O3
Optimize for fast execution as much as possible.
static const OptimizationLevel Oz
A very specialized mode that will optimize for code size at any and all costs.
static const OptimizationLevel O0
Disable as many optimizations as possible.
static const OptimizationLevel Os
Similar to O2 but tries to optimize for small code size instead of fast execution without triggering ...
static const OptimizationLevel O2
Optimize for fast execution as much as possible without triggering significant incremental compile ti...
static const OptimizationLevel O1
Optimize quickly without destroying debuggability.
This class provides access to building LLVM's passes.
Definition: PassBuilder.h:105
void printPassNames(raw_ostream &OS)
Print pass names.
static bool checkParametrizedPassName(StringRef Name, StringRef PassName)
Definition: PassBuilder.h:650
AAManager buildDefaultAAPipeline()
Build the default AAManager with the default alias analysis pipeline registered.
Error parseAAPipeline(AAManager &AA, StringRef PipelineText)
Parse a textual alias analysis pipeline into the provided AA manager.
ModulePassManager buildThinLTOPreLinkDefaultPipeline(OptimizationLevel Level)
Build a pre-link, ThinLTO-targeting default optimization pipeline to a pass manager.
PassBuilder(TargetMachine *TM=nullptr, PipelineTuningOptions PTO=PipelineTuningOptions(), std::optional< PGOOptions > PGOOpt=std::nullopt, PassInstrumentationCallbacks *PIC=nullptr)
void registerLoopAnalyses(LoopAnalysisManager &LAM)
Registers all available loop analysis passes.
std::optional< RegAllocFilterFunc > parseRegAllocFilter(StringRef RegAllocFilterName)
Parse RegAllocFilterName to get RegAllocFilterFunc.
void crossRegisterProxies(LoopAnalysisManager &LAM, FunctionAnalysisManager &FAM, CGSCCAnalysisManager &CGAM, ModuleAnalysisManager &MAM, MachineFunctionAnalysisManager *MFAM=nullptr)
Cross register the analysis managers through their proxies.
ModulePassManager buildPerModuleDefaultPipeline(OptimizationLevel Level, ThinOrFullLTOPhase Phase=ThinOrFullLTOPhase::None)
Build a per-module default optimization pipeline.
Error parsePassPipeline(ModulePassManager &MPM, StringRef PipelineText)
Parse a textual pass pipeline description into a ModulePassManager.
ModulePassManager buildLTODefaultPipeline(OptimizationLevel Level, ModuleSummaryIndex *ExportSummary)
Build an LTO default optimization pipeline to a pass manager.
ModulePassManager buildThinLTODefaultPipeline(OptimizationLevel Level, const ModuleSummaryIndex *ImportSummary)
Build a ThinLTO default optimization pipeline to a pass manager.
void registerModuleAnalyses(ModuleAnalysisManager &MAM)
Registers all available module analysis passes.
void registerCGSCCAnalyses(CGSCCAnalysisManager &CGAM)
Registers all available CGSCC analysis passes.
static Expected< bool > parseSinglePassOption(StringRef Params, StringRef OptionName, StringRef PassName)
Handle passes only accept one bool-valued parameter.
void registerMachineFunctionAnalyses(MachineFunctionAnalysisManager &MFAM)
Registers all available machine function analysis passes.
void registerParseTopLevelPipelineCallback(const std::function< bool(ModulePassManager &, ArrayRef< PipelineElement >)> &C)
Register a callback for a top-level pipeline entry.
ModulePassManager buildLTOPreLinkDefaultPipeline(OptimizationLevel Level)
Build a pre-link, LTO-targeting default optimization pipeline to a pass manager.
void registerFunctionAnalyses(FunctionAnalysisManager &FAM)
Registers all available function analysis passes.
LLVM_ATTRIBUTE_MINSIZE std::enable_if_t< is_detected< HasRunOnLoopT, PassT >::value > addPass(PassT &&Pass)
LLVM_ATTRIBUTE_MINSIZE std::enable_if_t<!std::is_same_v< PassT, PassManager > > addPass(PassT &&Pass)
Definition: PassManager.h:195
Tunable parameters for passes in the default pipelines.
Definition: PassBuilder.h:43
bool SLPVectorization
Tuning option to enable/disable slp loop vectorization, set based on opt level.
Definition: PassBuilder.h:58
bool LoopVectorization
Tuning option to enable/disable loop vectorization, set based on opt level.
Definition: PassBuilder.h:54
static PointerType * getUnqual(Type *ElementType)
This constructs a pointer to an object of the specified type in the default address space (address sp...
Definition: DerivedTypes.h:686
A set of analyses that are preserved following a run of a transformation pass.
Definition: Analysis.h:111
static PreservedAnalyses none()
Convenience factory function for the empty preserved set.
Definition: Analysis.h:114
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
Definition: Analysis.h:117
bool match(StringRef String, SmallVectorImpl< StringRef > *Matches=nullptr, std::string *Error=nullptr) const
matches - Match the regex against a given String.
Definition: Regex.cpp:83
size_t size() const
Definition: SmallVector.h:78
void push_back(const T &Elt)
Definition: SmallVector.h:413
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1196
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:51
std::pair< StringRef, StringRef > split(char Separator) const
Split into two substrings around the first occurrence of a separator character.
Definition: StringRef.h:700
bool getAsInteger(unsigned Radix, T &Result) const
Parse the current string as an integer of the specified radix.
Definition: StringRef.h:470
std::string str() const
str - Get the contents as an std::string.
Definition: StringRef.h:229
constexpr bool empty() const
empty - Check if the string is empty.
Definition: StringRef.h:147
char front() const
front - Get the first character in the string.
Definition: StringRef.h:153
bool consume_front(StringRef Prefix)
Returns true if this StringRef has the given prefix and removes that prefix.
Definition: StringRef.h:635
A switch()-like statement whose cases are string literals.
Definition: StringSwitch.h:44
StringSwitch & Case(StringLiteral S, T Value)
Definition: StringSwitch.h:69
R Default(T Value)
Definition: StringSwitch.h:182
Primary interface to the complete machine description for the target machine.
Definition: TargetMachine.h:77
This function has undefined behavior.
self_iterator getIterator()
Definition: ilist_node.h:132
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:52
Interfaces for registering analysis passes, producing common pass manager configurations,...
@ C
The default llvm calling convention, compatible with C.
Definition: CallingConv.h:34
PointerTypeMap run(const Module &M)
Compute the PointerTypeMap for the module M.
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
ModuleToFunctionPassAdaptor createModuleToFunctionPassAdaptor(FunctionPassT &&Pass, bool EagerlyInvalidate=false)
A function to deduce a function pass type and wrap it in the templated adaptor.
Definition: PassManager.h:852
DevirtSCCRepeatedPass createDevirtSCCRepeatedPass(CGSCCPassT &&Pass, int MaxIterations)
A function to deduce a function pass type and wrap it in the templated adaptor.
std::error_code inconvertibleErrorCode()
The value returned by this function can be returned from convertToErrorCode for Error values where no...
Definition: Error.cpp:98
OuterAnalysisManagerProxy< ModuleAnalysisManager, MachineFunction > ModuleAnalysisManagerMachineFunctionProxy
Provide the ModuleAnalysisManager to Function proxy.
OuterAnalysisManagerProxy< ModuleAnalysisManager, Function > ModuleAnalysisManagerFunctionProxy
Provide the ModuleAnalysisManager to Function proxy.
Definition: PassManager.h:802
InnerAnalysisManagerProxy< MachineFunctionAnalysisManager, Module > MachineFunctionAnalysisManagerModuleProxy
OuterAnalysisManagerProxy< ModuleAnalysisManager, LazyCallGraph::SCC, LazyCallGraph & > ModuleAnalysisManagerCGSCCProxy
A proxy from a ModuleAnalysisManager to an SCC.
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly.
Definition: STLExtras.h:1746
ModuleToPostOrderCGSCCPassAdaptor createModuleToPostOrderCGSCCPassAdaptor(CGSCCPassT &&Pass)
A function to deduce a function pass type and wrap it in the templated adaptor.
auto formatv(bool Validate, const char *Fmt, Ts &&...Vals)
CGSCCToFunctionPassAdaptor createCGSCCToFunctionPassAdaptor(FunctionPassT &&Pass, bool EagerlyInvalidate=false, bool NoRerun=false)
A function to deduce a function pass type and wrap it in the templated adaptor.
InnerAnalysisManagerProxy< FunctionAnalysisManager, Module > FunctionAnalysisManagerModuleProxy
Provide the FunctionAnalysisManager to Module proxy.
Definition: PassManager.h:648
FunctionToMachineFunctionPassAdaptor createFunctionToMachineFunctionPassAdaptor(MachineFunctionPassT &&Pass)
InnerAnalysisManagerProxy< MachineFunctionAnalysisManager, Function > MachineFunctionAnalysisManagerFunctionProxy
OuterAnalysisManagerProxy< FunctionAnalysisManager, Loop, LoopStandardAnalysisResults & > FunctionAnalysisManagerLoopProxy
A proxy from a FunctionAnalysisManager to a Loop.
cl::opt< bool > PrintPipelinePasses
Common option used by multiple tools to print pipeline passes.
OuterAnalysisManagerProxy< CGSCCAnalysisManager, Function > CGSCCAnalysisManagerFunctionProxy
A proxy from a CGSCCAnalysisManager to a Function.
std::enable_if_t< is_detected< HasRunOnLoopT, LoopPassT >::value, FunctionToLoopPassAdaptor > createFunctionToLoopPassAdaptor(LoopPassT &&Pass, bool UseMemorySSA=false, bool UseBlockFrequencyInfo=false, bool UseBranchProbabilityInfo=false)
A function to deduce a loop pass type and wrap it in the templated adaptor.
@ Detailed
Hash with opcode only.
@ CallTargetIgnored
Hash with opcode and operands.
@ Enable
Enable colors.
A special type used by analysis passes to provide an address that identifies that particular analysis...
Definition: Analysis.h:28
A set of parameters to control various transforms performed by GVN pass.
Definition: GVN.h:74
HardwareLoopOptions & setForceNested(bool Force)
Definition: HardwareLoops.h:45
HardwareLoopOptions & setDecrement(unsigned Count)
Definition: HardwareLoops.h:29
HardwareLoopOptions & setForceGuard(bool Force)
Definition: HardwareLoops.h:49
HardwareLoopOptions & setForce(bool Force)
Definition: HardwareLoops.h:37
HardwareLoopOptions & setCounterBitwidth(unsigned Width)
Definition: HardwareLoops.h:33
HardwareLoopOptions & setForcePhi(bool Force)
Definition: HardwareLoops.h:41
A set of parameters to control various transforms performed by IPSCCP pass.
Definition: SCCP.h:35
A set of parameters used to control various transforms performed by the LoopUnroll pass.
LoopUnrollOptions & setPeeling(bool Peeling)
Enables or disables loop peeling.
LoopUnrollOptions & setOptLevel(int O)
LoopUnrollOptions & setPartial(bool Partial)
Enables or disables partial unrolling.
LoopUnrollOptions & setFullUnrollMaxCount(unsigned O)
LoopUnrollOptions & setUpperBound(bool UpperBound)
Enables or disables the use of trip count upper bound in loop unrolling.
LoopUnrollOptions & setRuntime(bool Runtime)
Enables or disables unrolling of loops with runtime trip count.
LoopUnrollOptions & setProfileBasedPeeling(int O)
LoopVectorizeOptions & setVectorizeOnlyWhenForced(bool Value)
LoopVectorizeOptions & setInterleaveOnlyWhenForced(bool Value)
A CRTP mix-in to automatically provide informational APIs needed for passes.
Definition: PassManager.h:69
static StringRef name()
Gets the name of the pass we are mixed into.
Definition: PassManager.h:71
This class manages callbacks registration, as well as provides a way for PassInstrumentation to pass ...
RegAllocFilterFunc Filter
Definition: RegAllocFast.h:18