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 {
1302 return make_error<StringError>(
1303 formatv("invalid BoundsChecking pass parameter '{0}' ", ParamName)
1304 .str(),
1306 }
1307 }
1308 return Mode;
1309}
1310
1311} // namespace
1312
1313/// Tests whether a pass name starts with a valid prefix for a default pipeline
1314/// alias.
1316 return Name.starts_with("default") || Name.starts_with("thinlto") ||
1317 Name.starts_with("lto");
1318}
1319
1320/// Tests whether registered callbacks will accept a given pass name.
1321///
1322/// When parsing a pipeline text, the type of the outermost pipeline may be
1323/// omitted, in which case the type is automatically determined from the first
1324/// pass name in the text. This may be a name that is handled through one of the
1325/// callbacks. We check this through the oridinary parsing callbacks by setting
1326/// up a dummy PassManager in order to not force the client to also handle this
1327/// type of query.
1328template <typename PassManagerT, typename CallbacksT>
1329static bool callbacksAcceptPassName(StringRef Name, CallbacksT &Callbacks) {
1330 if (!Callbacks.empty()) {
1331 PassManagerT DummyPM;
1332 for (auto &CB : Callbacks)
1333 if (CB(Name, DummyPM, {}))
1334 return true;
1335 }
1336 return false;
1337}
1338
1339template <typename CallbacksT>
1340static bool isModulePassName(StringRef Name, CallbacksT &Callbacks) {
1341 // Manually handle aliases for pre-configured pipeline fragments.
1344
1345 StringRef NameNoBracket = Name.take_until([](char C) { return C == '<'; });
1346
1347 // Explicitly handle pass manager names.
1348 if (Name == "module")
1349 return true;
1350 if (Name == "cgscc")
1351 return true;
1352 if (NameNoBracket == "function")
1353 return true;
1354 if (Name == "coro-cond")
1355 return true;
1356
1357#define MODULE_PASS(NAME, CREATE_PASS) \
1358 if (Name == NAME) \
1359 return true;
1360#define MODULE_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1361 if (PassBuilder::checkParametrizedPassName(Name, NAME)) \
1362 return true;
1363#define MODULE_ANALYSIS(NAME, CREATE_PASS) \
1364 if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
1365 return true;
1366#include "PassRegistry.def"
1367
1368 return callbacksAcceptPassName<ModulePassManager>(Name, Callbacks);
1369}
1370
1371template <typename CallbacksT>
1372static bool isCGSCCPassName(StringRef Name, CallbacksT &Callbacks) {
1373 // Explicitly handle pass manager names.
1374 StringRef NameNoBracket = Name.take_until([](char C) { return C == '<'; });
1375 if (Name == "cgscc")
1376 return true;
1377 if (NameNoBracket == "function")
1378 return true;
1379
1380 // Explicitly handle custom-parsed pass names.
1382 return true;
1383
1384#define CGSCC_PASS(NAME, CREATE_PASS) \
1385 if (Name == NAME) \
1386 return true;
1387#define CGSCC_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1388 if (PassBuilder::checkParametrizedPassName(Name, NAME)) \
1389 return true;
1390#define CGSCC_ANALYSIS(NAME, CREATE_PASS) \
1391 if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
1392 return true;
1393#include "PassRegistry.def"
1394
1395 return callbacksAcceptPassName<CGSCCPassManager>(Name, Callbacks);
1396}
1397
1398template <typename CallbacksT>
1399static bool isFunctionPassName(StringRef Name, CallbacksT &Callbacks) {
1400 // Explicitly handle pass manager names.
1401 StringRef NameNoBracket = Name.take_until([](char C) { return C == '<'; });
1402 if (NameNoBracket == "function")
1403 return true;
1404 if (Name == "loop" || Name == "loop-mssa" || Name == "machine-function")
1405 return true;
1406
1407#define FUNCTION_PASS(NAME, CREATE_PASS) \
1408 if (Name == NAME) \
1409 return true;
1410#define FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1411 if (PassBuilder::checkParametrizedPassName(Name, NAME)) \
1412 return true;
1413#define FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
1414 if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
1415 return true;
1416#include "PassRegistry.def"
1417
1418 return callbacksAcceptPassName<FunctionPassManager>(Name, Callbacks);
1419}
1420
1421template <typename CallbacksT>
1422static bool isMachineFunctionPassName(StringRef Name, CallbacksT &Callbacks) {
1423 // Explicitly handle pass manager names.
1424 if (Name == "machine-function")
1425 return true;
1426
1427#define MACHINE_FUNCTION_PASS(NAME, CREATE_PASS) \
1428 if (Name == NAME) \
1429 return true;
1430#define MACHINE_FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, \
1431 PARAMS) \
1432 if (PassBuilder::checkParametrizedPassName(Name, NAME)) \
1433 return true;
1434
1435#define MACHINE_FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
1436 if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
1437 return true;
1438
1439#include "llvm/Passes/MachinePassRegistry.def"
1440
1441 return callbacksAcceptPassName<MachineFunctionPassManager>(Name, Callbacks);
1442}
1443
1444template <typename CallbacksT>
1445static bool isLoopNestPassName(StringRef Name, CallbacksT &Callbacks,
1446 bool &UseMemorySSA) {
1447 UseMemorySSA = false;
1448
1450 UseMemorySSA = true;
1451 return true;
1452 }
1453
1454#define LOOPNEST_PASS(NAME, CREATE_PASS) \
1455 if (Name == NAME) \
1456 return true;
1457#include "PassRegistry.def"
1458
1459 return callbacksAcceptPassName<LoopPassManager>(Name, Callbacks);
1460}
1461
1462template <typename CallbacksT>
1463static bool isLoopPassName(StringRef Name, CallbacksT &Callbacks,
1464 bool &UseMemorySSA) {
1465 UseMemorySSA = false;
1466
1468 UseMemorySSA = true;
1469 return true;
1470 }
1471
1472#define LOOP_PASS(NAME, CREATE_PASS) \
1473 if (Name == NAME) \
1474 return true;
1475#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1476 if (PassBuilder::checkParametrizedPassName(Name, NAME)) \
1477 return true;
1478#define LOOP_ANALYSIS(NAME, CREATE_PASS) \
1479 if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
1480 return true;
1481#include "PassRegistry.def"
1482
1483 return callbacksAcceptPassName<LoopPassManager>(Name, Callbacks);
1484}
1485
1486std::optional<std::vector<PassBuilder::PipelineElement>>
1487PassBuilder::parsePipelineText(StringRef Text) {
1488 std::vector<PipelineElement> ResultPipeline;
1489
1490 SmallVector<std::vector<PipelineElement> *, 4> PipelineStack = {
1491 &ResultPipeline};
1492 for (;;) {
1493 std::vector<PipelineElement> &Pipeline = *PipelineStack.back();
1494 size_t Pos = Text.find_first_of(",()");
1495 Pipeline.push_back({Text.substr(0, Pos), {}});
1496
1497 // If we have a single terminating name, we're done.
1498 if (Pos == Text.npos)
1499 break;
1500
1501 char Sep = Text[Pos];
1502 Text = Text.substr(Pos + 1);
1503 if (Sep == ',')
1504 // Just a name ending in a comma, continue.
1505 continue;
1506
1507 if (Sep == '(') {
1508 // Push the inner pipeline onto the stack to continue processing.
1509 PipelineStack.push_back(&Pipeline.back().InnerPipeline);
1510 continue;
1511 }
1512
1513 assert(Sep == ')' && "Bogus separator!");
1514 // When handling the close parenthesis, we greedily consume them to avoid
1515 // empty strings in the pipeline.
1516 do {
1517 // If we try to pop the outer pipeline we have unbalanced parentheses.
1518 if (PipelineStack.size() == 1)
1519 return std::nullopt;
1520
1521 PipelineStack.pop_back();
1522 } while (Text.consume_front(")"));
1523
1524 // Check if we've finished parsing.
1525 if (Text.empty())
1526 break;
1527
1528 // Otherwise, the end of an inner pipeline always has to be followed by
1529 // a comma, and then we can continue.
1530 if (!Text.consume_front(","))
1531 return std::nullopt;
1532 }
1533
1534 if (PipelineStack.size() > 1)
1535 // Unbalanced paretheses.
1536 return std::nullopt;
1537
1538 assert(PipelineStack.back() == &ResultPipeline &&
1539 "Wrong pipeline at the bottom of the stack!");
1540 return {std::move(ResultPipeline)};
1541}
1542
1543Error PassBuilder::parseModulePass(ModulePassManager &MPM,
1544 const PipelineElement &E) {
1545 auto &Name = E.Name;
1546 auto &InnerPipeline = E.InnerPipeline;
1547
1548 // First handle complex passes like the pass managers which carry pipelines.
1549 if (!InnerPipeline.empty()) {
1550 if (Name == "module") {
1551 ModulePassManager NestedMPM;
1552 if (auto Err = parseModulePassPipeline(NestedMPM, InnerPipeline))
1553 return Err;
1554 MPM.addPass(std::move(NestedMPM));
1555 return Error::success();
1556 }
1557 if (Name == "coro-cond") {
1558 ModulePassManager NestedMPM;
1559 if (auto Err = parseModulePassPipeline(NestedMPM, InnerPipeline))
1560 return Err;
1561 MPM.addPass(CoroConditionalWrapper(std::move(NestedMPM)));
1562 return Error::success();
1563 }
1564 if (Name == "cgscc") {
1565 CGSCCPassManager CGPM;
1566 if (auto Err = parseCGSCCPassPipeline(CGPM, InnerPipeline))
1567 return Err;
1569 return Error::success();
1570 }
1571 if (auto Params = parseFunctionPipelineName(Name)) {
1572 if (Params->second)
1573 return make_error<StringError>(
1574 "cannot have a no-rerun module to function adaptor",
1577 if (auto Err = parseFunctionPassPipeline(FPM, InnerPipeline))
1578 return Err;
1579 MPM.addPass(
1580 createModuleToFunctionPassAdaptor(std::move(FPM), Params->first));
1581 return Error::success();
1582 }
1583
1584 for (auto &C : ModulePipelineParsingCallbacks)
1585 if (C(Name, MPM, InnerPipeline))
1586 return Error::success();
1587
1588 // Normal passes can't have pipelines.
1589 return make_error<StringError>(
1590 formatv("invalid use of '{0}' pass as module pipeline", Name).str(),
1592 ;
1593 }
1594
1595 // Manually handle aliases for pre-configured pipeline fragments.
1598 if (!DefaultAliasRegex.match(Name, &Matches))
1599 return make_error<StringError>(
1600 formatv("unknown default pipeline alias '{0}'", Name).str(),
1602
1603 assert(Matches.size() == 3 && "Must capture two matched strings!");
1604
1605 OptimizationLevel L = *parseOptLevel(Matches[2]);
1606
1607 // This is consistent with old pass manager invoked via opt, but
1608 // inconsistent with clang. Clang doesn't enable loop vectorization
1609 // but does enable slp vectorization at Oz.
1610 PTO.LoopVectorization =
1611 L.getSpeedupLevel() > 1 && L != OptimizationLevel::Oz;
1612 PTO.SLPVectorization =
1613 L.getSpeedupLevel() > 1 && L != OptimizationLevel::Oz;
1614
1615 if (Matches[1] == "default") {
1617 } else if (Matches[1] == "thinlto-pre-link") {
1619 } else if (Matches[1] == "thinlto") {
1620 MPM.addPass(buildThinLTODefaultPipeline(L, nullptr));
1621 } else if (Matches[1] == "lto-pre-link") {
1622 if (PTO.UnifiedLTO)
1623 // When UnifiedLTO is enabled, use the ThinLTO pre-link pipeline. This
1624 // avoids compile-time performance regressions and keeps the pre-link
1625 // LTO pipeline "unified" for both LTO modes.
1627 else
1629 } else {
1630 assert(Matches[1] == "lto" && "Not one of the matched options!");
1631 MPM.addPass(buildLTODefaultPipeline(L, nullptr));
1632 }
1633 return Error::success();
1634 }
1635
1636 // Finally expand the basic registered passes from the .inc file.
1637#define MODULE_PASS(NAME, CREATE_PASS) \
1638 if (Name == NAME) { \
1639 MPM.addPass(CREATE_PASS); \
1640 return Error::success(); \
1641 }
1642#define MODULE_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1643 if (checkParametrizedPassName(Name, NAME)) { \
1644 auto Params = parsePassParameters(PARSER, Name, NAME); \
1645 if (!Params) \
1646 return Params.takeError(); \
1647 MPM.addPass(CREATE_PASS(Params.get())); \
1648 return Error::success(); \
1649 }
1650#define MODULE_ANALYSIS(NAME, CREATE_PASS) \
1651 if (Name == "require<" NAME ">") { \
1652 MPM.addPass( \
1653 RequireAnalysisPass< \
1654 std::remove_reference_t<decltype(CREATE_PASS)>, Module>()); \
1655 return Error::success(); \
1656 } \
1657 if (Name == "invalidate<" NAME ">") { \
1658 MPM.addPass(InvalidateAnalysisPass< \
1659 std::remove_reference_t<decltype(CREATE_PASS)>>()); \
1660 return Error::success(); \
1661 }
1662#define CGSCC_PASS(NAME, CREATE_PASS) \
1663 if (Name == NAME) { \
1664 MPM.addPass(createModuleToPostOrderCGSCCPassAdaptor(CREATE_PASS)); \
1665 return Error::success(); \
1666 }
1667#define CGSCC_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1668 if (checkParametrizedPassName(Name, NAME)) { \
1669 auto Params = parsePassParameters(PARSER, Name, NAME); \
1670 if (!Params) \
1671 return Params.takeError(); \
1672 MPM.addPass( \
1673 createModuleToPostOrderCGSCCPassAdaptor(CREATE_PASS(Params.get()))); \
1674 return Error::success(); \
1675 }
1676#define FUNCTION_PASS(NAME, CREATE_PASS) \
1677 if (Name == NAME) { \
1678 MPM.addPass(createModuleToFunctionPassAdaptor(CREATE_PASS)); \
1679 return Error::success(); \
1680 }
1681#define FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1682 if (checkParametrizedPassName(Name, NAME)) { \
1683 auto Params = parsePassParameters(PARSER, Name, NAME); \
1684 if (!Params) \
1685 return Params.takeError(); \
1686 MPM.addPass(createModuleToFunctionPassAdaptor(CREATE_PASS(Params.get()))); \
1687 return Error::success(); \
1688 }
1689#define LOOPNEST_PASS(NAME, CREATE_PASS) \
1690 if (Name == NAME) { \
1691 MPM.addPass(createModuleToFunctionPassAdaptor( \
1692 createFunctionToLoopPassAdaptor(CREATE_PASS, false, false))); \
1693 return Error::success(); \
1694 }
1695#define LOOP_PASS(NAME, CREATE_PASS) \
1696 if (Name == NAME) { \
1697 MPM.addPass(createModuleToFunctionPassAdaptor( \
1698 createFunctionToLoopPassAdaptor(CREATE_PASS, false, false))); \
1699 return Error::success(); \
1700 }
1701#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1702 if (checkParametrizedPassName(Name, NAME)) { \
1703 auto Params = parsePassParameters(PARSER, Name, NAME); \
1704 if (!Params) \
1705 return Params.takeError(); \
1706 MPM.addPass( \
1707 createModuleToFunctionPassAdaptor(createFunctionToLoopPassAdaptor( \
1708 CREATE_PASS(Params.get()), false, false))); \
1709 return Error::success(); \
1710 }
1711#include "PassRegistry.def"
1712
1713 for (auto &C : ModulePipelineParsingCallbacks)
1714 if (C(Name, MPM, InnerPipeline))
1715 return Error::success();
1716 return make_error<StringError>(
1717 formatv("unknown module pass '{0}'", Name).str(),
1719}
1720
1721Error PassBuilder::parseCGSCCPass(CGSCCPassManager &CGPM,
1722 const PipelineElement &E) {
1723 auto &Name = E.Name;
1724 auto &InnerPipeline = E.InnerPipeline;
1725
1726 // First handle complex passes like the pass managers which carry pipelines.
1727 if (!InnerPipeline.empty()) {
1728 if (Name == "cgscc") {
1729 CGSCCPassManager NestedCGPM;
1730 if (auto Err = parseCGSCCPassPipeline(NestedCGPM, InnerPipeline))
1731 return Err;
1732 // Add the nested pass manager with the appropriate adaptor.
1733 CGPM.addPass(std::move(NestedCGPM));
1734 return Error::success();
1735 }
1736 if (auto Params = parseFunctionPipelineName(Name)) {
1738 if (auto Err = parseFunctionPassPipeline(FPM, InnerPipeline))
1739 return Err;
1740 // Add the nested pass manager with the appropriate adaptor.
1742 std::move(FPM), Params->first, Params->second));
1743 return Error::success();
1744 }
1745 if (auto MaxRepetitions = parseDevirtPassName(Name)) {
1746 CGSCCPassManager NestedCGPM;
1747 if (auto Err = parseCGSCCPassPipeline(NestedCGPM, InnerPipeline))
1748 return Err;
1749 CGPM.addPass(
1750 createDevirtSCCRepeatedPass(std::move(NestedCGPM), *MaxRepetitions));
1751 return Error::success();
1752 }
1753
1754 for (auto &C : CGSCCPipelineParsingCallbacks)
1755 if (C(Name, CGPM, InnerPipeline))
1756 return Error::success();
1757
1758 // Normal passes can't have pipelines.
1759 return make_error<StringError>(
1760 formatv("invalid use of '{0}' pass as cgscc pipeline", Name).str(),
1762 }
1763
1764// Now expand the basic registered passes from the .inc file.
1765#define CGSCC_PASS(NAME, CREATE_PASS) \
1766 if (Name == NAME) { \
1767 CGPM.addPass(CREATE_PASS); \
1768 return Error::success(); \
1769 }
1770#define CGSCC_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1771 if (checkParametrizedPassName(Name, NAME)) { \
1772 auto Params = parsePassParameters(PARSER, Name, NAME); \
1773 if (!Params) \
1774 return Params.takeError(); \
1775 CGPM.addPass(CREATE_PASS(Params.get())); \
1776 return Error::success(); \
1777 }
1778#define CGSCC_ANALYSIS(NAME, CREATE_PASS) \
1779 if (Name == "require<" NAME ">") { \
1780 CGPM.addPass(RequireAnalysisPass< \
1781 std::remove_reference_t<decltype(CREATE_PASS)>, \
1782 LazyCallGraph::SCC, CGSCCAnalysisManager, LazyCallGraph &, \
1783 CGSCCUpdateResult &>()); \
1784 return Error::success(); \
1785 } \
1786 if (Name == "invalidate<" NAME ">") { \
1787 CGPM.addPass(InvalidateAnalysisPass< \
1788 std::remove_reference_t<decltype(CREATE_PASS)>>()); \
1789 return Error::success(); \
1790 }
1791#define FUNCTION_PASS(NAME, CREATE_PASS) \
1792 if (Name == NAME) { \
1793 CGPM.addPass(createCGSCCToFunctionPassAdaptor(CREATE_PASS)); \
1794 return Error::success(); \
1795 }
1796#define FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1797 if (checkParametrizedPassName(Name, NAME)) { \
1798 auto Params = parsePassParameters(PARSER, Name, NAME); \
1799 if (!Params) \
1800 return Params.takeError(); \
1801 CGPM.addPass(createCGSCCToFunctionPassAdaptor(CREATE_PASS(Params.get()))); \
1802 return Error::success(); \
1803 }
1804#define LOOPNEST_PASS(NAME, CREATE_PASS) \
1805 if (Name == NAME) { \
1806 CGPM.addPass(createCGSCCToFunctionPassAdaptor( \
1807 createFunctionToLoopPassAdaptor(CREATE_PASS, false, false))); \
1808 return Error::success(); \
1809 }
1810#define LOOP_PASS(NAME, CREATE_PASS) \
1811 if (Name == NAME) { \
1812 CGPM.addPass(createCGSCCToFunctionPassAdaptor( \
1813 createFunctionToLoopPassAdaptor(CREATE_PASS, false, false))); \
1814 return Error::success(); \
1815 }
1816#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1817 if (checkParametrizedPassName(Name, NAME)) { \
1818 auto Params = parsePassParameters(PARSER, Name, NAME); \
1819 if (!Params) \
1820 return Params.takeError(); \
1821 CGPM.addPass( \
1822 createCGSCCToFunctionPassAdaptor(createFunctionToLoopPassAdaptor( \
1823 CREATE_PASS(Params.get()), false, false))); \
1824 return Error::success(); \
1825 }
1826#include "PassRegistry.def"
1827
1828 for (auto &C : CGSCCPipelineParsingCallbacks)
1829 if (C(Name, CGPM, InnerPipeline))
1830 return Error::success();
1831 return make_error<StringError>(
1832 formatv("unknown cgscc pass '{0}'", Name).str(),
1834}
1835
1836Error PassBuilder::parseFunctionPass(FunctionPassManager &FPM,
1837 const PipelineElement &E) {
1838 auto &Name = E.Name;
1839 auto &InnerPipeline = E.InnerPipeline;
1840
1841 // First handle complex passes like the pass managers which carry pipelines.
1842 if (!InnerPipeline.empty()) {
1843 if (Name == "function") {
1844 FunctionPassManager NestedFPM;
1845 if (auto Err = parseFunctionPassPipeline(NestedFPM, InnerPipeline))
1846 return Err;
1847 // Add the nested pass manager with the appropriate adaptor.
1848 FPM.addPass(std::move(NestedFPM));
1849 return Error::success();
1850 }
1851 if (Name == "loop" || Name == "loop-mssa") {
1852 LoopPassManager LPM;
1853 if (auto Err = parseLoopPassPipeline(LPM, InnerPipeline))
1854 return Err;
1855 // Add the nested pass manager with the appropriate adaptor.
1856 bool UseMemorySSA = (Name == "loop-mssa");
1857 bool UseBFI = llvm::any_of(InnerPipeline, [](auto Pipeline) {
1858 return Pipeline.Name.contains("simple-loop-unswitch");
1859 });
1860 bool UseBPI = llvm::any_of(InnerPipeline, [](auto Pipeline) {
1861 return Pipeline.Name == "loop-predication";
1862 });
1863 FPM.addPass(createFunctionToLoopPassAdaptor(std::move(LPM), UseMemorySSA,
1864 UseBFI, UseBPI));
1865 return Error::success();
1866 }
1867 if (Name == "machine-function") {
1869 if (auto Err = parseMachinePassPipeline(MFPM, InnerPipeline))
1870 return Err;
1872 return Error::success();
1873 }
1874
1875 for (auto &C : FunctionPipelineParsingCallbacks)
1876 if (C(Name, FPM, InnerPipeline))
1877 return Error::success();
1878
1879 // Normal passes can't have pipelines.
1880 return make_error<StringError>(
1881 formatv("invalid use of '{0}' pass as function pipeline", Name).str(),
1883 }
1884
1885// Now expand the basic registered passes from the .inc file.
1886#define FUNCTION_PASS(NAME, CREATE_PASS) \
1887 if (Name == NAME) { \
1888 FPM.addPass(CREATE_PASS); \
1889 return Error::success(); \
1890 }
1891#define FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1892 if (checkParametrizedPassName(Name, NAME)) { \
1893 auto Params = parsePassParameters(PARSER, Name, NAME); \
1894 if (!Params) \
1895 return Params.takeError(); \
1896 FPM.addPass(CREATE_PASS(Params.get())); \
1897 return Error::success(); \
1898 }
1899#define FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
1900 if (Name == "require<" NAME ">") { \
1901 FPM.addPass( \
1902 RequireAnalysisPass< \
1903 std::remove_reference_t<decltype(CREATE_PASS)>, Function>()); \
1904 return Error::success(); \
1905 } \
1906 if (Name == "invalidate<" NAME ">") { \
1907 FPM.addPass(InvalidateAnalysisPass< \
1908 std::remove_reference_t<decltype(CREATE_PASS)>>()); \
1909 return Error::success(); \
1910 }
1911// FIXME: UseMemorySSA is set to false. Maybe we could do things like:
1912// bool UseMemorySSA = !("canon-freeze" || "loop-predication" ||
1913// "guard-widening");
1914// The risk is that it may become obsolete if we're not careful.
1915#define LOOPNEST_PASS(NAME, CREATE_PASS) \
1916 if (Name == NAME) { \
1917 FPM.addPass(createFunctionToLoopPassAdaptor(CREATE_PASS, false, false)); \
1918 return Error::success(); \
1919 }
1920#define LOOP_PASS(NAME, CREATE_PASS) \
1921 if (Name == NAME) { \
1922 FPM.addPass(createFunctionToLoopPassAdaptor(CREATE_PASS, false, false)); \
1923 return Error::success(); \
1924 }
1925#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1926 if (checkParametrizedPassName(Name, NAME)) { \
1927 auto Params = parsePassParameters(PARSER, Name, NAME); \
1928 if (!Params) \
1929 return Params.takeError(); \
1930 FPM.addPass(createFunctionToLoopPassAdaptor(CREATE_PASS(Params.get()), \
1931 false, false)); \
1932 return Error::success(); \
1933 }
1934#include "PassRegistry.def"
1935
1936 for (auto &C : FunctionPipelineParsingCallbacks)
1937 if (C(Name, FPM, InnerPipeline))
1938 return Error::success();
1939 return make_error<StringError>(
1940 formatv("unknown function pass '{0}'", Name).str(),
1942}
1943
1944Error PassBuilder::parseLoopPass(LoopPassManager &LPM,
1945 const PipelineElement &E) {
1946 StringRef Name = E.Name;
1947 auto &InnerPipeline = E.InnerPipeline;
1948
1949 // First handle complex passes like the pass managers which carry pipelines.
1950 if (!InnerPipeline.empty()) {
1951 if (Name == "loop") {
1952 LoopPassManager NestedLPM;
1953 if (auto Err = parseLoopPassPipeline(NestedLPM, InnerPipeline))
1954 return Err;
1955 // Add the nested pass manager with the appropriate adaptor.
1956 LPM.addPass(std::move(NestedLPM));
1957 return Error::success();
1958 }
1959
1960 for (auto &C : LoopPipelineParsingCallbacks)
1961 if (C(Name, LPM, InnerPipeline))
1962 return Error::success();
1963
1964 // Normal passes can't have pipelines.
1965 return make_error<StringError>(
1966 formatv("invalid use of '{0}' pass as loop pipeline", Name).str(),
1968 }
1969
1970// Now expand the basic registered passes from the .inc file.
1971#define LOOPNEST_PASS(NAME, CREATE_PASS) \
1972 if (Name == NAME) { \
1973 LPM.addPass(CREATE_PASS); \
1974 return Error::success(); \
1975 }
1976#define LOOP_PASS(NAME, CREATE_PASS) \
1977 if (Name == NAME) { \
1978 LPM.addPass(CREATE_PASS); \
1979 return Error::success(); \
1980 }
1981#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1982 if (checkParametrizedPassName(Name, NAME)) { \
1983 auto Params = parsePassParameters(PARSER, Name, NAME); \
1984 if (!Params) \
1985 return Params.takeError(); \
1986 LPM.addPass(CREATE_PASS(Params.get())); \
1987 return Error::success(); \
1988 }
1989#define LOOP_ANALYSIS(NAME, CREATE_PASS) \
1990 if (Name == "require<" NAME ">") { \
1991 LPM.addPass(RequireAnalysisPass< \
1992 std::remove_reference_t<decltype(CREATE_PASS)>, Loop, \
1993 LoopAnalysisManager, LoopStandardAnalysisResults &, \
1994 LPMUpdater &>()); \
1995 return Error::success(); \
1996 } \
1997 if (Name == "invalidate<" NAME ">") { \
1998 LPM.addPass(InvalidateAnalysisPass< \
1999 std::remove_reference_t<decltype(CREATE_PASS)>>()); \
2000 return Error::success(); \
2001 }
2002#include "PassRegistry.def"
2003
2004 for (auto &C : LoopPipelineParsingCallbacks)
2005 if (C(Name, LPM, InnerPipeline))
2006 return Error::success();
2007 return make_error<StringError>(formatv("unknown loop pass '{0}'", Name).str(),
2009}
2010
2011Error PassBuilder::parseMachinePass(MachineFunctionPassManager &MFPM,
2012 const PipelineElement &E) {
2013 StringRef Name = E.Name;
2014 if (!E.InnerPipeline.empty())
2015 return make_error<StringError>("invalid pipeline",
2017
2018#define MACHINE_MODULE_PASS(NAME, CREATE_PASS) \
2019 if (Name == NAME) { \
2020 MFPM.addPass(CREATE_PASS); \
2021 return Error::success(); \
2022 }
2023#define MACHINE_FUNCTION_PASS(NAME, CREATE_PASS) \
2024 if (Name == NAME) { \
2025 MFPM.addPass(CREATE_PASS); \
2026 return Error::success(); \
2027 }
2028#define MACHINE_FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, \
2029 PARAMS) \
2030 if (checkParametrizedPassName(Name, NAME)) { \
2031 auto Params = parsePassParameters(PARSER, Name, NAME); \
2032 if (!Params) \
2033 return Params.takeError(); \
2034 MFPM.addPass(CREATE_PASS(Params.get())); \
2035 return Error::success(); \
2036 }
2037#define MACHINE_FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
2038 if (Name == "require<" NAME ">") { \
2039 MFPM.addPass( \
2040 RequireAnalysisPass<std::remove_reference_t<decltype(CREATE_PASS)>, \
2041 MachineFunction>()); \
2042 return Error::success(); \
2043 } \
2044 if (Name == "invalidate<" NAME ">") { \
2045 MFPM.addPass(InvalidateAnalysisPass< \
2046 std::remove_reference_t<decltype(CREATE_PASS)>>()); \
2047 return Error::success(); \
2048 }
2049#include "llvm/Passes/MachinePassRegistry.def"
2050
2051 for (auto &C : MachineFunctionPipelineParsingCallbacks)
2052 if (C(Name, MFPM, E.InnerPipeline))
2053 return Error::success();
2054 return make_error<StringError>(
2055 formatv("unknown machine pass '{0}'", Name).str(),
2057}
2058
2059bool PassBuilder::parseAAPassName(AAManager &AA, StringRef Name) {
2060#define MODULE_ALIAS_ANALYSIS(NAME, CREATE_PASS) \
2061 if (Name == NAME) { \
2062 AA.registerModuleAnalysis< \
2063 std::remove_reference_t<decltype(CREATE_PASS)>>(); \
2064 return true; \
2065 }
2066#define FUNCTION_ALIAS_ANALYSIS(NAME, CREATE_PASS) \
2067 if (Name == NAME) { \
2068 AA.registerFunctionAnalysis< \
2069 std::remove_reference_t<decltype(CREATE_PASS)>>(); \
2070 return true; \
2071 }
2072#include "PassRegistry.def"
2073
2074 for (auto &C : AAParsingCallbacks)
2075 if (C(Name, AA))
2076 return true;
2077 return false;
2078}
2079
2080Error PassBuilder::parseMachinePassPipeline(
2082 for (const auto &Element : Pipeline) {
2083 if (auto Err = parseMachinePass(MFPM, Element))
2084 return Err;
2085 }
2086 return Error::success();
2087}
2088
2089Error PassBuilder::parseLoopPassPipeline(LoopPassManager &LPM,
2090 ArrayRef<PipelineElement> Pipeline) {
2091 for (const auto &Element : Pipeline) {
2092 if (auto Err = parseLoopPass(LPM, Element))
2093 return Err;
2094 }
2095 return Error::success();
2096}
2097
2098Error PassBuilder::parseFunctionPassPipeline(
2100 for (const auto &Element : Pipeline) {
2101 if (auto Err = parseFunctionPass(FPM, Element))
2102 return Err;
2103 }
2104 return Error::success();
2105}
2106
2107Error PassBuilder::parseCGSCCPassPipeline(CGSCCPassManager &CGPM,
2108 ArrayRef<PipelineElement> Pipeline) {
2109 for (const auto &Element : Pipeline) {
2110 if (auto Err = parseCGSCCPass(CGPM, Element))
2111 return Err;
2112 }
2113 return Error::success();
2114}
2115
2128 if (MFAM) {
2130 [&] { return MachineFunctionAnalysisManagerModuleProxy(*MFAM); });
2132 [&] { return MachineFunctionAnalysisManagerFunctionProxy(*MFAM); });
2133 MFAM->registerPass(
2135 MFAM->registerPass(
2137 }
2138}
2139
2140Error PassBuilder::parseModulePassPipeline(ModulePassManager &MPM,
2141 ArrayRef<PipelineElement> Pipeline) {
2142 for (const auto &Element : Pipeline) {
2143 if (auto Err = parseModulePass(MPM, Element))
2144 return Err;
2145 }
2146 return Error::success();
2147}
2148
2149// Primary pass pipeline description parsing routine for a \c ModulePassManager
2150// FIXME: Should this routine accept a TargetMachine or require the caller to
2151// pre-populate the analysis managers with target-specific stuff?
2153 StringRef PipelineText) {
2154 auto Pipeline = parsePipelineText(PipelineText);
2155 if (!Pipeline || Pipeline->empty())
2156 return make_error<StringError>(
2157 formatv("invalid pipeline '{0}'", PipelineText).str(),
2159
2160 // If the first name isn't at the module layer, wrap the pipeline up
2161 // automatically.
2162 StringRef FirstName = Pipeline->front().Name;
2163
2164 if (!isModulePassName(FirstName, ModulePipelineParsingCallbacks)) {
2165 bool UseMemorySSA;
2166 if (isCGSCCPassName(FirstName, CGSCCPipelineParsingCallbacks)) {
2167 Pipeline = {{"cgscc", std::move(*Pipeline)}};
2168 } else if (isFunctionPassName(FirstName,
2169 FunctionPipelineParsingCallbacks)) {
2170 Pipeline = {{"function", std::move(*Pipeline)}};
2171 } else if (isLoopNestPassName(FirstName, LoopPipelineParsingCallbacks,
2172 UseMemorySSA)) {
2173 Pipeline = {{"function", {{UseMemorySSA ? "loop-mssa" : "loop",
2174 std::move(*Pipeline)}}}};
2175 } else if (isLoopPassName(FirstName, LoopPipelineParsingCallbacks,
2176 UseMemorySSA)) {
2177 Pipeline = {{"function", {{UseMemorySSA ? "loop-mssa" : "loop",
2178 std::move(*Pipeline)}}}};
2179 } else if (isMachineFunctionPassName(
2180 FirstName, MachineFunctionPipelineParsingCallbacks)) {
2181 Pipeline = {{"function", {{"machine-function", std::move(*Pipeline)}}}};
2182 } else {
2183 for (auto &C : TopLevelPipelineParsingCallbacks)
2184 if (C(MPM, *Pipeline))
2185 return Error::success();
2186
2187 // Unknown pass or pipeline name!
2188 auto &InnerPipeline = Pipeline->front().InnerPipeline;
2189 return make_error<StringError>(
2190 formatv("unknown {0} name '{1}'",
2191 (InnerPipeline.empty() ? "pass" : "pipeline"), FirstName)
2192 .str(),
2194 }
2195 }
2196
2197 if (auto Err = parseModulePassPipeline(MPM, *Pipeline))
2198 return Err;
2199 return Error::success();
2200}
2201
2202// Primary pass pipeline description parsing routine for a \c CGSCCPassManager
2204 StringRef PipelineText) {
2205 auto Pipeline = parsePipelineText(PipelineText);
2206 if (!Pipeline || Pipeline->empty())
2207 return make_error<StringError>(
2208 formatv("invalid pipeline '{0}'", PipelineText).str(),
2210
2211 StringRef FirstName = Pipeline->front().Name;
2212 if (!isCGSCCPassName(FirstName, CGSCCPipelineParsingCallbacks))
2213 return make_error<StringError>(
2214 formatv("unknown cgscc pass '{0}' in pipeline '{1}'", FirstName,
2215 PipelineText)
2216 .str(),
2218
2219 if (auto Err = parseCGSCCPassPipeline(CGPM, *Pipeline))
2220 return Err;
2221 return Error::success();
2222}
2223
2224// Primary pass pipeline description parsing routine for a \c
2225// FunctionPassManager
2227 StringRef PipelineText) {
2228 auto Pipeline = parsePipelineText(PipelineText);
2229 if (!Pipeline || Pipeline->empty())
2230 return make_error<StringError>(
2231 formatv("invalid pipeline '{0}'", PipelineText).str(),
2233
2234 StringRef FirstName = Pipeline->front().Name;
2235 if (!isFunctionPassName(FirstName, FunctionPipelineParsingCallbacks))
2236 return make_error<StringError>(
2237 formatv("unknown function pass '{0}' in pipeline '{1}'", FirstName,
2238 PipelineText)
2239 .str(),
2241
2242 if (auto Err = parseFunctionPassPipeline(FPM, *Pipeline))
2243 return Err;
2244 return Error::success();
2245}
2246
2247// Primary pass pipeline description parsing routine for a \c LoopPassManager
2249 StringRef PipelineText) {
2250 auto Pipeline = parsePipelineText(PipelineText);
2251 if (!Pipeline || Pipeline->empty())
2252 return make_error<StringError>(
2253 formatv("invalid pipeline '{0}'", PipelineText).str(),
2255
2256 if (auto Err = parseLoopPassPipeline(CGPM, *Pipeline))
2257 return Err;
2258
2259 return Error::success();
2260}
2261
2263 StringRef PipelineText) {
2264 auto Pipeline = parsePipelineText(PipelineText);
2265 if (!Pipeline || Pipeline->empty())
2266 return make_error<StringError>(
2267 formatv("invalid machine pass pipeline '{0}'", PipelineText).str(),
2269
2270 if (auto Err = parseMachinePassPipeline(MFPM, *Pipeline))
2271 return Err;
2272
2273 return Error::success();
2274}
2275
2277 // If the pipeline just consists of the word 'default' just replace the AA
2278 // manager with our default one.
2279 if (PipelineText == "default") {
2281 return Error::success();
2282 }
2283
2284 while (!PipelineText.empty()) {
2286 std::tie(Name, PipelineText) = PipelineText.split(',');
2287 if (!parseAAPassName(AA, Name))
2288 return make_error<StringError>(
2289 formatv("unknown alias analysis name '{0}'", Name).str(),
2291 }
2292
2293 return Error::success();
2294}
2295
2296std::optional<RegAllocFilterFunc>
2298 if (FilterName == "all")
2299 return nullptr;
2300 for (auto &C : RegClassFilterParsingCallbacks)
2301 if (auto F = C(FilterName))
2302 return F;
2303 return std::nullopt;
2304}
2305
2307 OS << " " << PassName << "\n";
2308}
2310 raw_ostream &OS) {
2311 OS << " " << PassName << "<" << Params << ">\n";
2312}
2313
2315 // TODO: print pass descriptions when they are available
2316
2317 OS << "Module passes:\n";
2318#define MODULE_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2319#include "PassRegistry.def"
2320
2321 OS << "Module passes with params:\n";
2322#define MODULE_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
2323 printPassName(NAME, PARAMS, OS);
2324#include "PassRegistry.def"
2325
2326 OS << "Module analyses:\n";
2327#define MODULE_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2328#include "PassRegistry.def"
2329
2330 OS << "Module alias analyses:\n";
2331#define MODULE_ALIAS_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2332#include "PassRegistry.def"
2333
2334 OS << "CGSCC passes:\n";
2335#define CGSCC_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2336#include "PassRegistry.def"
2337
2338 OS << "CGSCC passes with params:\n";
2339#define CGSCC_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
2340 printPassName(NAME, PARAMS, OS);
2341#include "PassRegistry.def"
2342
2343 OS << "CGSCC analyses:\n";
2344#define CGSCC_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2345#include "PassRegistry.def"
2346
2347 OS << "Function passes:\n";
2348#define FUNCTION_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2349#include "PassRegistry.def"
2350
2351 OS << "Function passes with params:\n";
2352#define FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
2353 printPassName(NAME, PARAMS, OS);
2354#include "PassRegistry.def"
2355
2356 OS << "Function analyses:\n";
2357#define FUNCTION_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2358#include "PassRegistry.def"
2359
2360 OS << "Function alias analyses:\n";
2361#define FUNCTION_ALIAS_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2362#include "PassRegistry.def"
2363
2364 OS << "LoopNest passes:\n";
2365#define LOOPNEST_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2366#include "PassRegistry.def"
2367
2368 OS << "Loop passes:\n";
2369#define LOOP_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2370#include "PassRegistry.def"
2371
2372 OS << "Loop passes with params:\n";
2373#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
2374 printPassName(NAME, PARAMS, OS);
2375#include "PassRegistry.def"
2376
2377 OS << "Loop analyses:\n";
2378#define LOOP_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2379#include "PassRegistry.def"
2380
2381 OS << "Machine module passes (WIP):\n";
2382#define MACHINE_MODULE_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2383#include "llvm/Passes/MachinePassRegistry.def"
2384
2385 OS << "Machine function passes (WIP):\n";
2386#define MACHINE_FUNCTION_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2387#include "llvm/Passes/MachinePassRegistry.def"
2388
2389 OS << "Machine function analyses (WIP):\n";
2390#define MACHINE_FUNCTION_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2391#include "llvm/Passes/MachinePassRegistry.def"
2392}
2393
2395 const std::function<bool(ModulePassManager &, ArrayRef<PipelineElement>)>
2396 &C) {
2397 TopLevelPipelineParsingCallbacks.push_back(C);
2398}
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.
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