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#define MACHINE_FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, \
496 PARAMS) \
497 PIC->addClassToPassName(CLASS, NAME);
498#include "llvm/Passes/MachinePassRegistry.def"
499 });
500 }
501}
502
504#define MODULE_ANALYSIS(NAME, CREATE_PASS) \
505 MAM.registerPass([&] { return CREATE_PASS; });
506#include "PassRegistry.def"
507
508 for (auto &C : ModuleAnalysisRegistrationCallbacks)
509 C(MAM);
510}
511
513#define CGSCC_ANALYSIS(NAME, CREATE_PASS) \
514 CGAM.registerPass([&] { return CREATE_PASS; });
515#include "PassRegistry.def"
516
517 for (auto &C : CGSCCAnalysisRegistrationCallbacks)
518 C(CGAM);
519}
520
522 // We almost always want the default alias analysis pipeline.
523 // If a user wants a different one, they can register their own before calling
524 // registerFunctionAnalyses().
525 FAM.registerPass([&] { return buildDefaultAAPipeline(); });
526
527#define FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
528 FAM.registerPass([&] { return CREATE_PASS; });
529#include "PassRegistry.def"
530
531 for (auto &C : FunctionAnalysisRegistrationCallbacks)
532 C(FAM);
533}
534
537
538#define MACHINE_FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
539 MFAM.registerPass([&] { return CREATE_PASS; });
540#include "llvm/Passes/MachinePassRegistry.def"
541
542 for (auto &C : MachineFunctionAnalysisRegistrationCallbacks)
543 C(MFAM);
544}
545
547#define LOOP_ANALYSIS(NAME, CREATE_PASS) \
548 LAM.registerPass([&] { return CREATE_PASS; });
549#include "PassRegistry.def"
550
551 for (auto &C : LoopAnalysisRegistrationCallbacks)
552 C(LAM);
553}
554
555static std::optional<std::pair<bool, bool>>
557 std::pair<bool, bool> Params;
558 if (!Name.consume_front("function"))
559 return std::nullopt;
560 if (Name.empty())
561 return Params;
562 if (!Name.consume_front("<") || !Name.consume_back(">"))
563 return std::nullopt;
564 while (!Name.empty()) {
565 auto [Front, Back] = Name.split(';');
566 Name = Back;
567 if (Front == "eager-inv")
568 Params.first = true;
569 else if (Front == "no-rerun")
570 Params.second = true;
571 else
572 return std::nullopt;
573 }
574 return Params;
575}
576
577static std::optional<int> parseDevirtPassName(StringRef Name) {
578 if (!Name.consume_front("devirt<") || !Name.consume_back(">"))
579 return std::nullopt;
580 int Count;
581 if (Name.getAsInteger(0, Count) || Count < 0)
582 return std::nullopt;
583 return Count;
584}
585
586static std::optional<OptimizationLevel> parseOptLevel(StringRef S) {
588 .Case("O0", OptimizationLevel::O0)
594 .Default(std::nullopt);
595}
596
598 StringRef OptionName,
600 bool Result = false;
601 while (!Params.empty()) {
602 StringRef ParamName;
603 std::tie(ParamName, Params) = Params.split(';');
604
605 if (ParamName == OptionName) {
606 Result = true;
607 } else {
608 return make_error<StringError>(
609 formatv("invalid {1} pass parameter '{0}' ", ParamName, PassName)
610 .str(),
612 }
613 }
614 return Result;
615}
616
617namespace {
618
619/// Parser of parameters for HardwareLoops pass.
620Expected<HardwareLoopOptions> parseHardwareLoopOptions(StringRef Params) {
621 HardwareLoopOptions HardwareLoopOpts;
622
623 while (!Params.empty()) {
624 StringRef ParamName;
625 std::tie(ParamName, Params) = Params.split(';');
626 if (ParamName.consume_front("hardware-loop-decrement=")) {
627 int Count;
628 if (ParamName.getAsInteger(0, Count))
629 return make_error<StringError>(
630 formatv("invalid HardwareLoopPass parameter '{0}' ", ParamName).str(),
632 HardwareLoopOpts.setDecrement(Count);
633 continue;
634 }
635 if (ParamName.consume_front("hardware-loop-counter-bitwidth=")) {
636 int Count;
637 if (ParamName.getAsInteger(0, Count))
638 return make_error<StringError>(
639 formatv("invalid HardwareLoopPass parameter '{0}' ", ParamName).str(),
641 HardwareLoopOpts.setCounterBitwidth(Count);
642 continue;
643 }
644 if (ParamName == "force-hardware-loops") {
645 HardwareLoopOpts.setForce(true);
646 } else if (ParamName == "force-hardware-loop-phi") {
647 HardwareLoopOpts.setForcePhi(true);
648 } else if (ParamName == "force-nested-hardware-loop") {
649 HardwareLoopOpts.setForceNested(true);
650 } else if (ParamName == "force-hardware-loop-guard") {
651 HardwareLoopOpts.setForceGuard(true);
652 } else {
653 return make_error<StringError>(
654 formatv("invalid HardwarePass parameter '{0}' ", ParamName).str(),
656 }
657 }
658 return HardwareLoopOpts;
659}
660
661/// Parser of parameters for LoopUnroll pass.
662Expected<LoopUnrollOptions> parseLoopUnrollOptions(StringRef Params) {
663 LoopUnrollOptions UnrollOpts;
664 while (!Params.empty()) {
665 StringRef ParamName;
666 std::tie(ParamName, Params) = Params.split(';');
667 std::optional<OptimizationLevel> OptLevel = parseOptLevel(ParamName);
668 // Don't accept -Os/-Oz.
669 if (OptLevel && !OptLevel->isOptimizingForSize()) {
670 UnrollOpts.setOptLevel(OptLevel->getSpeedupLevel());
671 continue;
672 }
673 if (ParamName.consume_front("full-unroll-max=")) {
674 int Count;
675 if (ParamName.getAsInteger(0, Count))
676 return make_error<StringError>(
677 formatv("invalid LoopUnrollPass parameter '{0}' ", ParamName).str(),
679 UnrollOpts.setFullUnrollMaxCount(Count);
680 continue;
681 }
682
683 bool Enable = !ParamName.consume_front("no-");
684 if (ParamName == "partial") {
685 UnrollOpts.setPartial(Enable);
686 } else if (ParamName == "peeling") {
687 UnrollOpts.setPeeling(Enable);
688 } else if (ParamName == "profile-peeling") {
689 UnrollOpts.setProfileBasedPeeling(Enable);
690 } else if (ParamName == "runtime") {
691 UnrollOpts.setRuntime(Enable);
692 } else if (ParamName == "upperbound") {
693 UnrollOpts.setUpperBound(Enable);
694 } else {
695 return make_error<StringError>(
696 formatv("invalid LoopUnrollPass parameter '{0}' ", ParamName).str(),
698 }
699 }
700 return UnrollOpts;
701}
702
703Expected<bool> parseGlobalDCEPassOptions(StringRef Params) {
705 Params, "vfe-linkage-unit-visibility", "GlobalDCE");
706}
707
708Expected<bool> parseCGProfilePassOptions(StringRef Params) {
709 return PassBuilder::parseSinglePassOption(Params, "in-lto-post-link",
710 "CGProfile");
711}
712
713Expected<bool> parseInlinerPassOptions(StringRef Params) {
714 return PassBuilder::parseSinglePassOption(Params, "only-mandatory",
715 "InlinerPass");
716}
717
718Expected<bool> parseCoroSplitPassOptions(StringRef Params) {
719 return PassBuilder::parseSinglePassOption(Params, "reuse-storage",
720 "CoroSplitPass");
721}
722
723Expected<bool> parsePostOrderFunctionAttrsPassOptions(StringRef Params) {
725 Params, "skip-non-recursive-function-attrs", "PostOrderFunctionAttrs");
726}
727
728Expected<CFGuardPass::Mechanism> parseCFGuardPassOptions(StringRef Params) {
729 if (Params.empty())
731
732 auto [Param, RHS] = Params.split(';');
733 if (!RHS.empty())
734 return make_error<StringError>(
735 formatv("too many CFGuardPass parameters '{0}' ", Params).str(),
737
738 if (Param == "check")
740 if (Param == "dispatch")
742
743 return make_error<StringError>(
744 formatv("invalid CFGuardPass mechanism: '{0}' ", Param).str(),
746}
747
748Expected<bool> parseEarlyCSEPassOptions(StringRef Params) {
749 return PassBuilder::parseSinglePassOption(Params, "memssa", "EarlyCSE");
750}
751
752Expected<bool> parseEntryExitInstrumenterPassOptions(StringRef Params) {
753 return PassBuilder::parseSinglePassOption(Params, "post-inline",
754 "EntryExitInstrumenter");
755}
756
757Expected<bool> parseLoopExtractorPassOptions(StringRef Params) {
758 return PassBuilder::parseSinglePassOption(Params, "single", "LoopExtractor");
759}
760
761Expected<bool> parseLowerMatrixIntrinsicsPassOptions(StringRef Params) {
762 return PassBuilder::parseSinglePassOption(Params, "minimal",
763 "LowerMatrixIntrinsics");
764}
765
766Expected<AddressSanitizerOptions> parseASanPassOptions(StringRef Params) {
768 while (!Params.empty()) {
769 StringRef ParamName;
770 std::tie(ParamName, Params) = Params.split(';');
771
772 if (ParamName == "kernel") {
773 Result.CompileKernel = true;
774 } else {
775 return make_error<StringError>(
776 formatv("invalid AddressSanitizer pass parameter '{0}' ", ParamName)
777 .str(),
779 }
780 }
781 return Result;
782}
783
784Expected<HWAddressSanitizerOptions> parseHWASanPassOptions(StringRef Params) {
786 while (!Params.empty()) {
787 StringRef ParamName;
788 std::tie(ParamName, Params) = Params.split(';');
789
790 if (ParamName == "recover") {
791 Result.Recover = true;
792 } else if (ParamName == "kernel") {
793 Result.CompileKernel = true;
794 } else {
795 return make_error<StringError>(
796 formatv("invalid HWAddressSanitizer pass parameter '{0}' ", ParamName)
797 .str(),
799 }
800 }
801 return Result;
802}
803
804Expected<EmbedBitcodeOptions> parseEmbedBitcodePassOptions(StringRef Params) {
806 while (!Params.empty()) {
807 StringRef ParamName;
808 std::tie(ParamName, Params) = Params.split(';');
809
810 if (ParamName == "thinlto") {
811 Result.IsThinLTO = true;
812 } else if (ParamName == "emit-summary") {
813 Result.EmitLTOSummary = true;
814 } else {
815 return make_error<StringError>(
816 formatv("invalid EmbedBitcode pass parameter '{0}' ", ParamName)
817 .str(),
819 }
820 }
821 return Result;
822}
823
824Expected<MemorySanitizerOptions> parseMSanPassOptions(StringRef Params) {
826 while (!Params.empty()) {
827 StringRef ParamName;
828 std::tie(ParamName, Params) = Params.split(';');
829
830 if (ParamName == "recover") {
831 Result.Recover = true;
832 } else if (ParamName == "kernel") {
833 Result.Kernel = true;
834 } else if (ParamName.consume_front("track-origins=")) {
835 if (ParamName.getAsInteger(0, Result.TrackOrigins))
836 return make_error<StringError>(
837 formatv("invalid argument to MemorySanitizer pass track-origins "
838 "parameter: '{0}' ",
839 ParamName)
840 .str(),
842 } else if (ParamName == "eager-checks") {
843 Result.EagerChecks = true;
844 } else {
845 return make_error<StringError>(
846 formatv("invalid MemorySanitizer pass parameter '{0}' ", ParamName)
847 .str(),
849 }
850 }
851 return Result;
852}
853
854/// Parser of parameters for SimplifyCFG pass.
855Expected<SimplifyCFGOptions> parseSimplifyCFGOptions(StringRef Params) {
857 while (!Params.empty()) {
858 StringRef ParamName;
859 std::tie(ParamName, Params) = Params.split(';');
860
861 bool Enable = !ParamName.consume_front("no-");
862 if (ParamName == "speculate-blocks") {
863 Result.speculateBlocks(Enable);
864 } else if (ParamName == "simplify-cond-branch") {
865 Result.setSimplifyCondBranch(Enable);
866 } else if (ParamName == "forward-switch-cond") {
867 Result.forwardSwitchCondToPhi(Enable);
868 } else if (ParamName == "switch-range-to-icmp") {
869 Result.convertSwitchRangeToICmp(Enable);
870 } else if (ParamName == "switch-to-lookup") {
871 Result.convertSwitchToLookupTable(Enable);
872 } else if (ParamName == "keep-loops") {
873 Result.needCanonicalLoops(Enable);
874 } else if (ParamName == "hoist-common-insts") {
875 Result.hoistCommonInsts(Enable);
876 } else if (ParamName == "hoist-loads-stores-with-cond-faulting") {
877 Result.hoistLoadsStoresWithCondFaulting(Enable);
878 } else if (ParamName == "sink-common-insts") {
879 Result.sinkCommonInsts(Enable);
880 } else if (ParamName == "speculate-unpredictables") {
881 Result.speculateUnpredictables(Enable);
882 } else if (Enable && ParamName.consume_front("bonus-inst-threshold=")) {
883 APInt BonusInstThreshold;
884 if (ParamName.getAsInteger(0, BonusInstThreshold))
885 return make_error<StringError>(
886 formatv("invalid argument to SimplifyCFG pass bonus-threshold "
887 "parameter: '{0}' ",
888 ParamName).str(),
890 Result.bonusInstThreshold(BonusInstThreshold.getSExtValue());
891 } else {
892 return make_error<StringError>(
893 formatv("invalid SimplifyCFG pass parameter '{0}' ", ParamName).str(),
895 }
896 }
897 return Result;
898}
899
900Expected<InstCombineOptions> parseInstCombineOptions(StringRef Params) {
902 // When specifying "instcombine" in -passes enable fix-point verification by
903 // default, as this is what most tests should use.
904 Result.setVerifyFixpoint(true);
905 while (!Params.empty()) {
906 StringRef ParamName;
907 std::tie(ParamName, Params) = Params.split(';');
908
909 bool Enable = !ParamName.consume_front("no-");
910 if (ParamName == "verify-fixpoint") {
911 Result.setVerifyFixpoint(Enable);
912 } else if (Enable && ParamName.consume_front("max-iterations=")) {
913 APInt MaxIterations;
914 if (ParamName.getAsInteger(0, MaxIterations))
915 return make_error<StringError>(
916 formatv("invalid argument to InstCombine pass max-iterations "
917 "parameter: '{0}' ",
918 ParamName).str(),
920 Result.setMaxIterations((unsigned)MaxIterations.getZExtValue());
921 } else {
922 return make_error<StringError>(
923 formatv("invalid InstCombine pass parameter '{0}' ", ParamName).str(),
925 }
926 }
927 return Result;
928}
929
930/// Parser of parameters for LoopVectorize pass.
931Expected<LoopVectorizeOptions> parseLoopVectorizeOptions(StringRef Params) {
933 while (!Params.empty()) {
934 StringRef ParamName;
935 std::tie(ParamName, Params) = Params.split(';');
936
937 bool Enable = !ParamName.consume_front("no-");
938 if (ParamName == "interleave-forced-only") {
940 } else if (ParamName == "vectorize-forced-only") {
942 } else {
943 return make_error<StringError>(
944 formatv("invalid LoopVectorize parameter '{0}' ", ParamName).str(),
946 }
947 }
948 return Opts;
949}
950
951Expected<std::pair<bool, bool>> parseLoopUnswitchOptions(StringRef Params) {
952 std::pair<bool, bool> Result = {false, true};
953 while (!Params.empty()) {
954 StringRef ParamName;
955 std::tie(ParamName, Params) = Params.split(';');
956
957 bool Enable = !ParamName.consume_front("no-");
958 if (ParamName == "nontrivial") {
959 Result.first = Enable;
960 } else if (ParamName == "trivial") {
961 Result.second = Enable;
962 } else {
963 return make_error<StringError>(
964 formatv("invalid LoopUnswitch pass parameter '{0}' ", ParamName)
965 .str(),
967 }
968 }
969 return Result;
970}
971
972Expected<LICMOptions> parseLICMOptions(StringRef Params) {
974 while (!Params.empty()) {
975 StringRef ParamName;
976 std::tie(ParamName, Params) = Params.split(';');
977
978 bool Enable = !ParamName.consume_front("no-");
979 if (ParamName == "allowspeculation") {
980 Result.AllowSpeculation = Enable;
981 } else {
982 return make_error<StringError>(
983 formatv("invalid LICM pass parameter '{0}' ", ParamName).str(),
985 }
986 }
987 return Result;
988}
989
990Expected<std::pair<bool, bool>> parseLoopRotateOptions(StringRef Params) {
991 std::pair<bool, bool> Result = {true, false};
992 while (!Params.empty()) {
993 StringRef ParamName;
994 std::tie(ParamName, Params) = Params.split(';');
995
996 bool Enable = !ParamName.consume_front("no-");
997 if (ParamName == "header-duplication") {
998 Result.first = Enable;
999 } else if (ParamName == "prepare-for-lto") {
1000 Result.second = Enable;
1001 } else {
1002 return make_error<StringError>(
1003 formatv("invalid LoopRotate pass parameter '{0}' ", ParamName).str(),
1005 }
1006 }
1007 return Result;
1008}
1009
1010Expected<bool> parseMergedLoadStoreMotionOptions(StringRef Params) {
1011 bool Result = false;
1012 while (!Params.empty()) {
1013 StringRef ParamName;
1014 std::tie(ParamName, Params) = Params.split(';');
1015
1016 bool Enable = !ParamName.consume_front("no-");
1017 if (ParamName == "split-footer-bb") {
1018 Result = Enable;
1019 } else {
1020 return make_error<StringError>(
1021 formatv("invalid MergedLoadStoreMotion pass parameter '{0}' ",
1022 ParamName)
1023 .str(),
1025 }
1026 }
1027 return Result;
1028}
1029
1030Expected<GVNOptions> parseGVNOptions(StringRef Params) {
1032 while (!Params.empty()) {
1033 StringRef ParamName;
1034 std::tie(ParamName, Params) = Params.split(';');
1035
1036 bool Enable = !ParamName.consume_front("no-");
1037 if (ParamName == "pre") {
1038 Result.setPRE(Enable);
1039 } else if (ParamName == "load-pre") {
1040 Result.setLoadPRE(Enable);
1041 } else if (ParamName == "split-backedge-load-pre") {
1042 Result.setLoadPRESplitBackedge(Enable);
1043 } else if (ParamName == "memdep") {
1044 Result.setMemDep(Enable);
1045 } else if (ParamName == "memoryssa") {
1046 Result.setMemorySSA(Enable);
1047 } else {
1048 return make_error<StringError>(
1049 formatv("invalid GVN pass parameter '{0}' ", ParamName).str(),
1051 }
1052 }
1053 return Result;
1054}
1055
1056Expected<IPSCCPOptions> parseIPSCCPOptions(StringRef Params) {
1058 while (!Params.empty()) {
1059 StringRef ParamName;
1060 std::tie(ParamName, Params) = Params.split(';');
1061
1062 bool Enable = !ParamName.consume_front("no-");
1063 if (ParamName == "func-spec")
1064 Result.setFuncSpec(Enable);
1065 else
1066 return make_error<StringError>(
1067 formatv("invalid IPSCCP pass parameter '{0}' ", ParamName).str(),
1069 }
1070 return Result;
1071}
1072
1073Expected<ScalarizerPassOptions> parseScalarizerOptions(StringRef Params) {
1075 while (!Params.empty()) {
1076 StringRef ParamName;
1077 std::tie(ParamName, Params) = Params.split(';');
1078
1079 if (ParamName.consume_front("min-bits=")) {
1080 if (ParamName.getAsInteger(0, Result.ScalarizeMinBits)) {
1081 return make_error<StringError>(
1082 formatv("invalid argument to Scalarizer pass min-bits "
1083 "parameter: '{0}' ",
1084 ParamName)
1085 .str(),
1087 }
1088
1089 continue;
1090 }
1091
1092 bool Enable = !ParamName.consume_front("no-");
1093 if (ParamName == "load-store")
1094 Result.ScalarizeLoadStore = Enable;
1095 else if (ParamName == "variable-insert-extract")
1096 Result.ScalarizeVariableInsertExtract = Enable;
1097 else {
1098 return make_error<StringError>(
1099 formatv("invalid Scalarizer pass parameter '{0}' ", ParamName).str(),
1101 }
1102 }
1103
1104 return Result;
1105}
1106
1107Expected<SROAOptions> parseSROAOptions(StringRef Params) {
1108 if (Params.empty() || Params == "modify-cfg")
1110 if (Params == "preserve-cfg")
1112 return make_error<StringError>(
1113 formatv("invalid SROA pass parameter '{0}' (either preserve-cfg or "
1114 "modify-cfg can be specified)",
1115 Params)
1116 .str(),
1118}
1119
1121parseStackLifetimeOptions(StringRef Params) {
1123 while (!Params.empty()) {
1124 StringRef ParamName;
1125 std::tie(ParamName, Params) = Params.split(';');
1126
1127 if (ParamName == "may") {
1129 } else if (ParamName == "must") {
1131 } else {
1132 return make_error<StringError>(
1133 formatv("invalid StackLifetime parameter '{0}' ", ParamName).str(),
1135 }
1136 }
1137 return Result;
1138}
1139
1140Expected<bool> parseDependenceAnalysisPrinterOptions(StringRef Params) {
1141 return PassBuilder::parseSinglePassOption(Params, "normalized-results",
1142 "DependenceAnalysisPrinter");
1143}
1144
1145Expected<bool> parseSeparateConstOffsetFromGEPPassOptions(StringRef Params) {
1146 return PassBuilder::parseSinglePassOption(Params, "lower-gep",
1147 "SeparateConstOffsetFromGEP");
1148}
1149
1150Expected<bool> parseStructurizeCFGPassOptions(StringRef Params) {
1151 return PassBuilder::parseSinglePassOption(Params, "skip-uniform-regions",
1152 "StructurizeCFG");
1153}
1154
1156parseFunctionSimplificationPipelineOptions(StringRef Params) {
1157 std::optional<OptimizationLevel> L = parseOptLevel(Params);
1158 if (!L || *L == OptimizationLevel::O0) {
1159 return make_error<StringError>(
1160 formatv("invalid function-simplification parameter '{0}' ", Params)
1161 .str(),
1163 };
1164 return *L;
1165}
1166
1167Expected<bool> parseMemorySSAPrinterPassOptions(StringRef Params) {
1168 return PassBuilder::parseSinglePassOption(Params, "no-ensure-optimized-uses",
1169 "MemorySSAPrinterPass");
1170}
1171
1172Expected<bool> parseSpeculativeExecutionPassOptions(StringRef Params) {
1173 return PassBuilder::parseSinglePassOption(Params, "only-if-divergent-target",
1174 "SpeculativeExecutionPass");
1175}
1176
1177Expected<std::string> parseMemProfUsePassOptions(StringRef Params) {
1178 std::string Result;
1179 while (!Params.empty()) {
1180 StringRef ParamName;
1181 std::tie(ParamName, Params) = Params.split(';');
1182
1183 if (ParamName.consume_front("profile-filename=")) {
1184 Result = ParamName.str();
1185 } else {
1186 return make_error<StringError>(
1187 formatv("invalid MemProfUse pass parameter '{0}' ", ParamName).str(),
1189 }
1190 }
1191 return Result;
1192}
1193
1195parseStructuralHashPrinterPassOptions(StringRef Params) {
1196 if (Params.empty())
1198 if (Params == "detailed")
1200 if (Params == "call-target-ignored")
1202 return make_error<StringError>(
1203 formatv("invalid structural hash printer parameter '{0}' ", Params).str(),
1205}
1206
1207Expected<bool> parseWinEHPrepareOptions(StringRef Params) {
1208 return PassBuilder::parseSinglePassOption(Params, "demote-catchswitch-only",
1209 "WinEHPreparePass");
1210}
1211
1212Expected<GlobalMergeOptions> parseGlobalMergeOptions(StringRef Params) {
1214 while (!Params.empty()) {
1215 StringRef ParamName;
1216 std::tie(ParamName, Params) = Params.split(';');
1217
1218 bool Enable = !ParamName.consume_front("no-");
1219 if (ParamName == "group-by-use")
1220 Result.GroupByUse = Enable;
1221 else if (ParamName == "ignore-single-use")
1222 Result.IgnoreSingleUse = Enable;
1223 else if (ParamName == "merge-const")
1224 Result.MergeConst = Enable;
1225 else if (ParamName == "merge-external")
1226 Result.MergeExternal = Enable;
1227 else if (ParamName.consume_front("max-offset=")) {
1228 if (ParamName.getAsInteger(0, Result.MaxOffset))
1229 return make_error<StringError>(
1230 formatv("invalid GlobalMergePass parameter '{0}' ", ParamName)
1231 .str(),
1233 }
1234 }
1235 return Result;
1236}
1237
1238Expected<SmallVector<std::string, 0>> parseInternalizeGVs(StringRef Params) {
1239 SmallVector<std::string, 1> PreservedGVs;
1240 while (!Params.empty()) {
1241 StringRef ParamName;
1242 std::tie(ParamName, Params) = Params.split(';');
1243
1244 if (ParamName.consume_front("preserve-gv=")) {
1245 PreservedGVs.push_back(ParamName.str());
1246 } else {
1247 return make_error<StringError>(
1248 formatv("invalid Internalize pass parameter '{0}' ", ParamName).str(),
1250 }
1251 }
1252
1253 return Expected<SmallVector<std::string, 0>>(std::move(PreservedGVs));
1254}
1255
1257parseRegAllocFastPassOptions(PassBuilder &PB, StringRef Params) {
1259 while (!Params.empty()) {
1260 StringRef ParamName;
1261 std::tie(ParamName, Params) = Params.split(';');
1262
1263 if (ParamName.consume_front("filter=")) {
1264 std::optional<RegAllocFilterFunc> Filter =
1265 PB.parseRegAllocFilter(ParamName);
1266 if (!Filter) {
1267 return make_error<StringError>(
1268 formatv("invalid regallocfast register filter '{0}' ", ParamName)
1269 .str(),
1271 }
1272 Opts.Filter = *Filter;
1273 Opts.FilterName = ParamName;
1274 continue;
1275 }
1276
1277 if (ParamName == "no-clear-vregs") {
1278 Opts.ClearVRegs = false;
1279 continue;
1280 }
1281
1282 return make_error<StringError>(
1283 formatv("invalid regallocfast pass parameter '{0}' ", ParamName).str(),
1285 }
1286 return Opts;
1287}
1288
1290parseBoundsCheckingOptions(StringRef Params) {
1292 while (!Params.empty()) {
1293 StringRef ParamName;
1294 std::tie(ParamName, Params) = Params.split(';');
1295 if (ParamName == "trap") {
1296 Options.Rt = std::nullopt;
1297 } else if (ParamName == "rt") {
1298 Options.Rt = {
1299 /*MinRuntime=*/false,
1300 /*MayReturn=*/true,
1301 };
1302 } else if (ParamName == "rt-abort") {
1303 Options.Rt = {
1304 /*MinRuntime=*/false,
1305 /*MayReturn=*/false,
1306 };
1307 } else if (ParamName == "min-rt") {
1308 Options.Rt = {
1309 /*MinRuntime=*/true,
1310 /*MayReturn=*/true,
1311 };
1312 } else if (ParamName == "min-rt-abort") {
1313 Options.Rt = {
1314 /*MinRuntime=*/true,
1315 /*MayReturn=*/false,
1316 };
1317 } else if (ParamName == "merge") {
1318 Options.Merge = true;
1319 } else {
1320 StringRef ParamEQ;
1321 StringRef Val;
1322 std::tie(ParamEQ, Val) = ParamName.split('=');
1323 int8_t Id = 0;
1324 if (ParamEQ == "guard" && !Val.getAsInteger(0, Id)) {
1325 Options.GuardKind = Id;
1326 } else {
1327 return make_error<StringError>(
1328 formatv("invalid BoundsChecking pass parameter '{0}' ", ParamName)
1329 .str(),
1331 }
1332 }
1333 }
1334 return Options;
1335}
1336
1337} // namespace
1338
1339/// Tests whether a pass name starts with a valid prefix for a default pipeline
1340/// alias.
1342 return Name.starts_with("default") || Name.starts_with("thinlto") ||
1343 Name.starts_with("lto");
1344}
1345
1346/// Tests whether registered callbacks will accept a given pass name.
1347///
1348/// When parsing a pipeline text, the type of the outermost pipeline may be
1349/// omitted, in which case the type is automatically determined from the first
1350/// pass name in the text. This may be a name that is handled through one of the
1351/// callbacks. We check this through the oridinary parsing callbacks by setting
1352/// up a dummy PassManager in order to not force the client to also handle this
1353/// type of query.
1354template <typename PassManagerT, typename CallbacksT>
1355static bool callbacksAcceptPassName(StringRef Name, CallbacksT &Callbacks) {
1356 if (!Callbacks.empty()) {
1357 PassManagerT DummyPM;
1358 for (auto &CB : Callbacks)
1359 if (CB(Name, DummyPM, {}))
1360 return true;
1361 }
1362 return false;
1363}
1364
1365template <typename CallbacksT>
1366static bool isModulePassName(StringRef Name, CallbacksT &Callbacks) {
1367 // Manually handle aliases for pre-configured pipeline fragments.
1370
1371 StringRef NameNoBracket = Name.take_until([](char C) { return C == '<'; });
1372
1373 // Explicitly handle pass manager names.
1374 if (Name == "module")
1375 return true;
1376 if (Name == "cgscc")
1377 return true;
1378 if (NameNoBracket == "function")
1379 return true;
1380 if (Name == "coro-cond")
1381 return true;
1382
1383#define MODULE_PASS(NAME, CREATE_PASS) \
1384 if (Name == NAME) \
1385 return true;
1386#define MODULE_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1387 if (PassBuilder::checkParametrizedPassName(Name, NAME)) \
1388 return true;
1389#define MODULE_ANALYSIS(NAME, CREATE_PASS) \
1390 if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
1391 return true;
1392#include "PassRegistry.def"
1393
1394 return callbacksAcceptPassName<ModulePassManager>(Name, Callbacks);
1395}
1396
1397template <typename CallbacksT>
1398static bool isCGSCCPassName(StringRef Name, CallbacksT &Callbacks) {
1399 // Explicitly handle pass manager names.
1400 StringRef NameNoBracket = Name.take_until([](char C) { return C == '<'; });
1401 if (Name == "cgscc")
1402 return true;
1403 if (NameNoBracket == "function")
1404 return true;
1405
1406 // Explicitly handle custom-parsed pass names.
1408 return true;
1409
1410#define CGSCC_PASS(NAME, CREATE_PASS) \
1411 if (Name == NAME) \
1412 return true;
1413#define CGSCC_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1414 if (PassBuilder::checkParametrizedPassName(Name, NAME)) \
1415 return true;
1416#define CGSCC_ANALYSIS(NAME, CREATE_PASS) \
1417 if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
1418 return true;
1419#include "PassRegistry.def"
1420
1421 return callbacksAcceptPassName<CGSCCPassManager>(Name, Callbacks);
1422}
1423
1424template <typename CallbacksT>
1425static bool isFunctionPassName(StringRef Name, CallbacksT &Callbacks) {
1426 // Explicitly handle pass manager names.
1427 StringRef NameNoBracket = Name.take_until([](char C) { return C == '<'; });
1428 if (NameNoBracket == "function")
1429 return true;
1430 if (Name == "loop" || Name == "loop-mssa" || Name == "machine-function")
1431 return true;
1432
1433#define FUNCTION_PASS(NAME, CREATE_PASS) \
1434 if (Name == NAME) \
1435 return true;
1436#define FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1437 if (PassBuilder::checkParametrizedPassName(Name, NAME)) \
1438 return true;
1439#define FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
1440 if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
1441 return true;
1442#include "PassRegistry.def"
1443
1444 return callbacksAcceptPassName<FunctionPassManager>(Name, Callbacks);
1445}
1446
1447template <typename CallbacksT>
1448static bool isMachineFunctionPassName(StringRef Name, CallbacksT &Callbacks) {
1449 // Explicitly handle pass manager names.
1450 if (Name == "machine-function")
1451 return true;
1452
1453#define MACHINE_FUNCTION_PASS(NAME, CREATE_PASS) \
1454 if (Name == NAME) \
1455 return true;
1456#define MACHINE_FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, \
1457 PARAMS) \
1458 if (PassBuilder::checkParametrizedPassName(Name, NAME)) \
1459 return true;
1460
1461#define MACHINE_FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
1462 if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
1463 return true;
1464
1465#include "llvm/Passes/MachinePassRegistry.def"
1466
1467 return callbacksAcceptPassName<MachineFunctionPassManager>(Name, Callbacks);
1468}
1469
1470template <typename CallbacksT>
1471static bool isLoopNestPassName(StringRef Name, CallbacksT &Callbacks,
1472 bool &UseMemorySSA) {
1473 UseMemorySSA = false;
1474
1476 UseMemorySSA = true;
1477 return true;
1478 }
1479
1480#define LOOPNEST_PASS(NAME, CREATE_PASS) \
1481 if (Name == NAME) \
1482 return true;
1483#include "PassRegistry.def"
1484
1485 return callbacksAcceptPassName<LoopPassManager>(Name, Callbacks);
1486}
1487
1488template <typename CallbacksT>
1489static bool isLoopPassName(StringRef Name, CallbacksT &Callbacks,
1490 bool &UseMemorySSA) {
1491 UseMemorySSA = false;
1492
1494 UseMemorySSA = true;
1495 return true;
1496 }
1497
1498#define LOOP_PASS(NAME, CREATE_PASS) \
1499 if (Name == NAME) \
1500 return true;
1501#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1502 if (PassBuilder::checkParametrizedPassName(Name, NAME)) \
1503 return true;
1504#define LOOP_ANALYSIS(NAME, CREATE_PASS) \
1505 if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
1506 return true;
1507#include "PassRegistry.def"
1508
1509 return callbacksAcceptPassName<LoopPassManager>(Name, Callbacks);
1510}
1511
1512std::optional<std::vector<PassBuilder::PipelineElement>>
1513PassBuilder::parsePipelineText(StringRef Text) {
1514 std::vector<PipelineElement> ResultPipeline;
1515
1516 SmallVector<std::vector<PipelineElement> *, 4> PipelineStack = {
1517 &ResultPipeline};
1518 for (;;) {
1519 std::vector<PipelineElement> &Pipeline = *PipelineStack.back();
1520 size_t Pos = Text.find_first_of(",()");
1521 Pipeline.push_back({Text.substr(0, Pos), {}});
1522
1523 // If we have a single terminating name, we're done.
1524 if (Pos == Text.npos)
1525 break;
1526
1527 char Sep = Text[Pos];
1528 Text = Text.substr(Pos + 1);
1529 if (Sep == ',')
1530 // Just a name ending in a comma, continue.
1531 continue;
1532
1533 if (Sep == '(') {
1534 // Push the inner pipeline onto the stack to continue processing.
1535 PipelineStack.push_back(&Pipeline.back().InnerPipeline);
1536 continue;
1537 }
1538
1539 assert(Sep == ')' && "Bogus separator!");
1540 // When handling the close parenthesis, we greedily consume them to avoid
1541 // empty strings in the pipeline.
1542 do {
1543 // If we try to pop the outer pipeline we have unbalanced parentheses.
1544 if (PipelineStack.size() == 1)
1545 return std::nullopt;
1546
1547 PipelineStack.pop_back();
1548 } while (Text.consume_front(")"));
1549
1550 // Check if we've finished parsing.
1551 if (Text.empty())
1552 break;
1553
1554 // Otherwise, the end of an inner pipeline always has to be followed by
1555 // a comma, and then we can continue.
1556 if (!Text.consume_front(","))
1557 return std::nullopt;
1558 }
1559
1560 if (PipelineStack.size() > 1)
1561 // Unbalanced paretheses.
1562 return std::nullopt;
1563
1564 assert(PipelineStack.back() == &ResultPipeline &&
1565 "Wrong pipeline at the bottom of the stack!");
1566 return {std::move(ResultPipeline)};
1567}
1568
1569Error PassBuilder::parseModulePass(ModulePassManager &MPM,
1570 const PipelineElement &E) {
1571 auto &Name = E.Name;
1572 auto &InnerPipeline = E.InnerPipeline;
1573
1574 // First handle complex passes like the pass managers which carry pipelines.
1575 if (!InnerPipeline.empty()) {
1576 if (Name == "module") {
1577 ModulePassManager NestedMPM;
1578 if (auto Err = parseModulePassPipeline(NestedMPM, InnerPipeline))
1579 return Err;
1580 MPM.addPass(std::move(NestedMPM));
1581 return Error::success();
1582 }
1583 if (Name == "coro-cond") {
1584 ModulePassManager NestedMPM;
1585 if (auto Err = parseModulePassPipeline(NestedMPM, InnerPipeline))
1586 return Err;
1587 MPM.addPass(CoroConditionalWrapper(std::move(NestedMPM)));
1588 return Error::success();
1589 }
1590 if (Name == "cgscc") {
1591 CGSCCPassManager CGPM;
1592 if (auto Err = parseCGSCCPassPipeline(CGPM, InnerPipeline))
1593 return Err;
1595 return Error::success();
1596 }
1597 if (auto Params = parseFunctionPipelineName(Name)) {
1598 if (Params->second)
1599 return make_error<StringError>(
1600 "cannot have a no-rerun module to function adaptor",
1603 if (auto Err = parseFunctionPassPipeline(FPM, InnerPipeline))
1604 return Err;
1605 MPM.addPass(
1606 createModuleToFunctionPassAdaptor(std::move(FPM), Params->first));
1607 return Error::success();
1608 }
1609
1610 for (auto &C : ModulePipelineParsingCallbacks)
1611 if (C(Name, MPM, InnerPipeline))
1612 return Error::success();
1613
1614 // Normal passes can't have pipelines.
1615 return make_error<StringError>(
1616 formatv("invalid use of '{0}' pass as module pipeline", Name).str(),
1618 ;
1619 }
1620
1621 // Manually handle aliases for pre-configured pipeline fragments.
1624 if (!DefaultAliasRegex.match(Name, &Matches))
1625 return make_error<StringError>(
1626 formatv("unknown default pipeline alias '{0}'", Name).str(),
1628
1629 assert(Matches.size() == 3 && "Must capture two matched strings!");
1630
1631 OptimizationLevel L = *parseOptLevel(Matches[2]);
1632
1633 // This is consistent with old pass manager invoked via opt, but
1634 // inconsistent with clang. Clang doesn't enable loop vectorization
1635 // but does enable slp vectorization at Oz.
1636 PTO.LoopVectorization =
1637 L.getSpeedupLevel() > 1 && L != OptimizationLevel::Oz;
1638 PTO.SLPVectorization =
1639 L.getSpeedupLevel() > 1 && L != OptimizationLevel::Oz;
1640
1641 if (Matches[1] == "default") {
1643 } else if (Matches[1] == "thinlto-pre-link") {
1645 } else if (Matches[1] == "thinlto") {
1646 MPM.addPass(buildThinLTODefaultPipeline(L, nullptr));
1647 } else if (Matches[1] == "lto-pre-link") {
1648 if (PTO.UnifiedLTO)
1649 // When UnifiedLTO is enabled, use the ThinLTO pre-link pipeline. This
1650 // avoids compile-time performance regressions and keeps the pre-link
1651 // LTO pipeline "unified" for both LTO modes.
1653 else
1655 } else {
1656 assert(Matches[1] == "lto" && "Not one of the matched options!");
1657 MPM.addPass(buildLTODefaultPipeline(L, nullptr));
1658 }
1659 return Error::success();
1660 }
1661
1662 // Finally expand the basic registered passes from the .inc file.
1663#define MODULE_PASS(NAME, CREATE_PASS) \
1664 if (Name == NAME) { \
1665 MPM.addPass(CREATE_PASS); \
1666 return Error::success(); \
1667 }
1668#define MODULE_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1669 if (checkParametrizedPassName(Name, NAME)) { \
1670 auto Params = parsePassParameters(PARSER, Name, NAME); \
1671 if (!Params) \
1672 return Params.takeError(); \
1673 MPM.addPass(CREATE_PASS(Params.get())); \
1674 return Error::success(); \
1675 }
1676#define MODULE_ANALYSIS(NAME, CREATE_PASS) \
1677 if (Name == "require<" NAME ">") { \
1678 MPM.addPass( \
1679 RequireAnalysisPass< \
1680 std::remove_reference_t<decltype(CREATE_PASS)>, Module>()); \
1681 return Error::success(); \
1682 } \
1683 if (Name == "invalidate<" NAME ">") { \
1684 MPM.addPass(InvalidateAnalysisPass< \
1685 std::remove_reference_t<decltype(CREATE_PASS)>>()); \
1686 return Error::success(); \
1687 }
1688#define CGSCC_PASS(NAME, CREATE_PASS) \
1689 if (Name == NAME) { \
1690 MPM.addPass(createModuleToPostOrderCGSCCPassAdaptor(CREATE_PASS)); \
1691 return Error::success(); \
1692 }
1693#define CGSCC_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1694 if (checkParametrizedPassName(Name, NAME)) { \
1695 auto Params = parsePassParameters(PARSER, Name, NAME); \
1696 if (!Params) \
1697 return Params.takeError(); \
1698 MPM.addPass( \
1699 createModuleToPostOrderCGSCCPassAdaptor(CREATE_PASS(Params.get()))); \
1700 return Error::success(); \
1701 }
1702#define FUNCTION_PASS(NAME, CREATE_PASS) \
1703 if (Name == NAME) { \
1704 MPM.addPass(createModuleToFunctionPassAdaptor(CREATE_PASS)); \
1705 return Error::success(); \
1706 }
1707#define FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1708 if (checkParametrizedPassName(Name, NAME)) { \
1709 auto Params = parsePassParameters(PARSER, Name, NAME); \
1710 if (!Params) \
1711 return Params.takeError(); \
1712 MPM.addPass(createModuleToFunctionPassAdaptor(CREATE_PASS(Params.get()))); \
1713 return Error::success(); \
1714 }
1715#define LOOPNEST_PASS(NAME, CREATE_PASS) \
1716 if (Name == NAME) { \
1717 MPM.addPass(createModuleToFunctionPassAdaptor( \
1718 createFunctionToLoopPassAdaptor(CREATE_PASS, false, false))); \
1719 return Error::success(); \
1720 }
1721#define LOOP_PASS(NAME, CREATE_PASS) \
1722 if (Name == NAME) { \
1723 MPM.addPass(createModuleToFunctionPassAdaptor( \
1724 createFunctionToLoopPassAdaptor(CREATE_PASS, false, false))); \
1725 return Error::success(); \
1726 }
1727#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1728 if (checkParametrizedPassName(Name, NAME)) { \
1729 auto Params = parsePassParameters(PARSER, Name, NAME); \
1730 if (!Params) \
1731 return Params.takeError(); \
1732 MPM.addPass( \
1733 createModuleToFunctionPassAdaptor(createFunctionToLoopPassAdaptor( \
1734 CREATE_PASS(Params.get()), false, false))); \
1735 return Error::success(); \
1736 }
1737#include "PassRegistry.def"
1738
1739 for (auto &C : ModulePipelineParsingCallbacks)
1740 if (C(Name, MPM, InnerPipeline))
1741 return Error::success();
1742 return make_error<StringError>(
1743 formatv("unknown module pass '{0}'", Name).str(),
1745}
1746
1747Error PassBuilder::parseCGSCCPass(CGSCCPassManager &CGPM,
1748 const PipelineElement &E) {
1749 auto &Name = E.Name;
1750 auto &InnerPipeline = E.InnerPipeline;
1751
1752 // First handle complex passes like the pass managers which carry pipelines.
1753 if (!InnerPipeline.empty()) {
1754 if (Name == "cgscc") {
1755 CGSCCPassManager NestedCGPM;
1756 if (auto Err = parseCGSCCPassPipeline(NestedCGPM, InnerPipeline))
1757 return Err;
1758 // Add the nested pass manager with the appropriate adaptor.
1759 CGPM.addPass(std::move(NestedCGPM));
1760 return Error::success();
1761 }
1762 if (auto Params = parseFunctionPipelineName(Name)) {
1764 if (auto Err = parseFunctionPassPipeline(FPM, InnerPipeline))
1765 return Err;
1766 // Add the nested pass manager with the appropriate adaptor.
1768 std::move(FPM), Params->first, Params->second));
1769 return Error::success();
1770 }
1771 if (auto MaxRepetitions = parseDevirtPassName(Name)) {
1772 CGSCCPassManager NestedCGPM;
1773 if (auto Err = parseCGSCCPassPipeline(NestedCGPM, InnerPipeline))
1774 return Err;
1775 CGPM.addPass(
1776 createDevirtSCCRepeatedPass(std::move(NestedCGPM), *MaxRepetitions));
1777 return Error::success();
1778 }
1779
1780 for (auto &C : CGSCCPipelineParsingCallbacks)
1781 if (C(Name, CGPM, InnerPipeline))
1782 return Error::success();
1783
1784 // Normal passes can't have pipelines.
1785 return make_error<StringError>(
1786 formatv("invalid use of '{0}' pass as cgscc pipeline", Name).str(),
1788 }
1789
1790// Now expand the basic registered passes from the .inc file.
1791#define CGSCC_PASS(NAME, CREATE_PASS) \
1792 if (Name == NAME) { \
1793 CGPM.addPass(CREATE_PASS); \
1794 return Error::success(); \
1795 }
1796#define CGSCC_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(CREATE_PASS(Params.get())); \
1802 return Error::success(); \
1803 }
1804#define CGSCC_ANALYSIS(NAME, CREATE_PASS) \
1805 if (Name == "require<" NAME ">") { \
1806 CGPM.addPass(RequireAnalysisPass< \
1807 std::remove_reference_t<decltype(CREATE_PASS)>, \
1808 LazyCallGraph::SCC, CGSCCAnalysisManager, LazyCallGraph &, \
1809 CGSCCUpdateResult &>()); \
1810 return Error::success(); \
1811 } \
1812 if (Name == "invalidate<" NAME ">") { \
1813 CGPM.addPass(InvalidateAnalysisPass< \
1814 std::remove_reference_t<decltype(CREATE_PASS)>>()); \
1815 return Error::success(); \
1816 }
1817#define FUNCTION_PASS(NAME, CREATE_PASS) \
1818 if (Name == NAME) { \
1819 CGPM.addPass(createCGSCCToFunctionPassAdaptor(CREATE_PASS)); \
1820 return Error::success(); \
1821 }
1822#define FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1823 if (checkParametrizedPassName(Name, NAME)) { \
1824 auto Params = parsePassParameters(PARSER, Name, NAME); \
1825 if (!Params) \
1826 return Params.takeError(); \
1827 CGPM.addPass(createCGSCCToFunctionPassAdaptor(CREATE_PASS(Params.get()))); \
1828 return Error::success(); \
1829 }
1830#define LOOPNEST_PASS(NAME, CREATE_PASS) \
1831 if (Name == NAME) { \
1832 CGPM.addPass(createCGSCCToFunctionPassAdaptor( \
1833 createFunctionToLoopPassAdaptor(CREATE_PASS, false, false))); \
1834 return Error::success(); \
1835 }
1836#define LOOP_PASS(NAME, CREATE_PASS) \
1837 if (Name == NAME) { \
1838 CGPM.addPass(createCGSCCToFunctionPassAdaptor( \
1839 createFunctionToLoopPassAdaptor(CREATE_PASS, false, false))); \
1840 return Error::success(); \
1841 }
1842#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1843 if (checkParametrizedPassName(Name, NAME)) { \
1844 auto Params = parsePassParameters(PARSER, Name, NAME); \
1845 if (!Params) \
1846 return Params.takeError(); \
1847 CGPM.addPass( \
1848 createCGSCCToFunctionPassAdaptor(createFunctionToLoopPassAdaptor( \
1849 CREATE_PASS(Params.get()), false, false))); \
1850 return Error::success(); \
1851 }
1852#include "PassRegistry.def"
1853
1854 for (auto &C : CGSCCPipelineParsingCallbacks)
1855 if (C(Name, CGPM, InnerPipeline))
1856 return Error::success();
1857 return make_error<StringError>(
1858 formatv("unknown cgscc pass '{0}'", Name).str(),
1860}
1861
1862Error PassBuilder::parseFunctionPass(FunctionPassManager &FPM,
1863 const PipelineElement &E) {
1864 auto &Name = E.Name;
1865 auto &InnerPipeline = E.InnerPipeline;
1866
1867 // First handle complex passes like the pass managers which carry pipelines.
1868 if (!InnerPipeline.empty()) {
1869 if (Name == "function") {
1870 FunctionPassManager NestedFPM;
1871 if (auto Err = parseFunctionPassPipeline(NestedFPM, InnerPipeline))
1872 return Err;
1873 // Add the nested pass manager with the appropriate adaptor.
1874 FPM.addPass(std::move(NestedFPM));
1875 return Error::success();
1876 }
1877 if (Name == "loop" || Name == "loop-mssa") {
1878 LoopPassManager LPM;
1879 if (auto Err = parseLoopPassPipeline(LPM, InnerPipeline))
1880 return Err;
1881 // Add the nested pass manager with the appropriate adaptor.
1882 bool UseMemorySSA = (Name == "loop-mssa");
1883 bool UseBFI = llvm::any_of(InnerPipeline, [](auto Pipeline) {
1884 return Pipeline.Name.contains("simple-loop-unswitch");
1885 });
1886 bool UseBPI = llvm::any_of(InnerPipeline, [](auto Pipeline) {
1887 return Pipeline.Name == "loop-predication";
1888 });
1889 FPM.addPass(createFunctionToLoopPassAdaptor(std::move(LPM), UseMemorySSA,
1890 UseBFI, UseBPI));
1891 return Error::success();
1892 }
1893 if (Name == "machine-function") {
1895 if (auto Err = parseMachinePassPipeline(MFPM, InnerPipeline))
1896 return Err;
1898 return Error::success();
1899 }
1900
1901 for (auto &C : FunctionPipelineParsingCallbacks)
1902 if (C(Name, FPM, InnerPipeline))
1903 return Error::success();
1904
1905 // Normal passes can't have pipelines.
1906 return make_error<StringError>(
1907 formatv("invalid use of '{0}' pass as function pipeline", Name).str(),
1909 }
1910
1911// Now expand the basic registered passes from the .inc file.
1912#define FUNCTION_PASS(NAME, CREATE_PASS) \
1913 if (Name == NAME) { \
1914 FPM.addPass(CREATE_PASS); \
1915 return Error::success(); \
1916 }
1917#define FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1918 if (checkParametrizedPassName(Name, NAME)) { \
1919 auto Params = parsePassParameters(PARSER, Name, NAME); \
1920 if (!Params) \
1921 return Params.takeError(); \
1922 FPM.addPass(CREATE_PASS(Params.get())); \
1923 return Error::success(); \
1924 }
1925#define FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
1926 if (Name == "require<" NAME ">") { \
1927 FPM.addPass( \
1928 RequireAnalysisPass< \
1929 std::remove_reference_t<decltype(CREATE_PASS)>, Function>()); \
1930 return Error::success(); \
1931 } \
1932 if (Name == "invalidate<" NAME ">") { \
1933 FPM.addPass(InvalidateAnalysisPass< \
1934 std::remove_reference_t<decltype(CREATE_PASS)>>()); \
1935 return Error::success(); \
1936 }
1937// FIXME: UseMemorySSA is set to false. Maybe we could do things like:
1938// bool UseMemorySSA = !("canon-freeze" || "loop-predication" ||
1939// "guard-widening");
1940// The risk is that it may become obsolete if we're not careful.
1941#define LOOPNEST_PASS(NAME, CREATE_PASS) \
1942 if (Name == NAME) { \
1943 FPM.addPass(createFunctionToLoopPassAdaptor(CREATE_PASS, false, false)); \
1944 return Error::success(); \
1945 }
1946#define LOOP_PASS(NAME, CREATE_PASS) \
1947 if (Name == NAME) { \
1948 FPM.addPass(createFunctionToLoopPassAdaptor(CREATE_PASS, false, false)); \
1949 return Error::success(); \
1950 }
1951#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1952 if (checkParametrizedPassName(Name, NAME)) { \
1953 auto Params = parsePassParameters(PARSER, Name, NAME); \
1954 if (!Params) \
1955 return Params.takeError(); \
1956 FPM.addPass(createFunctionToLoopPassAdaptor(CREATE_PASS(Params.get()), \
1957 false, false)); \
1958 return Error::success(); \
1959 }
1960#include "PassRegistry.def"
1961
1962 for (auto &C : FunctionPipelineParsingCallbacks)
1963 if (C(Name, FPM, InnerPipeline))
1964 return Error::success();
1965 return make_error<StringError>(
1966 formatv("unknown function pass '{0}'", Name).str(),
1968}
1969
1970Error PassBuilder::parseLoopPass(LoopPassManager &LPM,
1971 const PipelineElement &E) {
1972 StringRef Name = E.Name;
1973 auto &InnerPipeline = E.InnerPipeline;
1974
1975 // First handle complex passes like the pass managers which carry pipelines.
1976 if (!InnerPipeline.empty()) {
1977 if (Name == "loop") {
1978 LoopPassManager NestedLPM;
1979 if (auto Err = parseLoopPassPipeline(NestedLPM, InnerPipeline))
1980 return Err;
1981 // Add the nested pass manager with the appropriate adaptor.
1982 LPM.addPass(std::move(NestedLPM));
1983 return Error::success();
1984 }
1985
1986 for (auto &C : LoopPipelineParsingCallbacks)
1987 if (C(Name, LPM, InnerPipeline))
1988 return Error::success();
1989
1990 // Normal passes can't have pipelines.
1991 return make_error<StringError>(
1992 formatv("invalid use of '{0}' pass as loop pipeline", Name).str(),
1994 }
1995
1996// Now expand the basic registered passes from the .inc file.
1997#define LOOPNEST_PASS(NAME, CREATE_PASS) \
1998 if (Name == NAME) { \
1999 LPM.addPass(CREATE_PASS); \
2000 return Error::success(); \
2001 }
2002#define LOOP_PASS(NAME, CREATE_PASS) \
2003 if (Name == NAME) { \
2004 LPM.addPass(CREATE_PASS); \
2005 return Error::success(); \
2006 }
2007#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
2008 if (checkParametrizedPassName(Name, NAME)) { \
2009 auto Params = parsePassParameters(PARSER, Name, NAME); \
2010 if (!Params) \
2011 return Params.takeError(); \
2012 LPM.addPass(CREATE_PASS(Params.get())); \
2013 return Error::success(); \
2014 }
2015#define LOOP_ANALYSIS(NAME, CREATE_PASS) \
2016 if (Name == "require<" NAME ">") { \
2017 LPM.addPass(RequireAnalysisPass< \
2018 std::remove_reference_t<decltype(CREATE_PASS)>, Loop, \
2019 LoopAnalysisManager, LoopStandardAnalysisResults &, \
2020 LPMUpdater &>()); \
2021 return Error::success(); \
2022 } \
2023 if (Name == "invalidate<" NAME ">") { \
2024 LPM.addPass(InvalidateAnalysisPass< \
2025 std::remove_reference_t<decltype(CREATE_PASS)>>()); \
2026 return Error::success(); \
2027 }
2028#include "PassRegistry.def"
2029
2030 for (auto &C : LoopPipelineParsingCallbacks)
2031 if (C(Name, LPM, InnerPipeline))
2032 return Error::success();
2033 return make_error<StringError>(formatv("unknown loop pass '{0}'", Name).str(),
2035}
2036
2037Error PassBuilder::parseMachinePass(MachineFunctionPassManager &MFPM,
2038 const PipelineElement &E) {
2039 StringRef Name = E.Name;
2040 if (!E.InnerPipeline.empty())
2041 return make_error<StringError>("invalid pipeline",
2043
2044#define MACHINE_MODULE_PASS(NAME, CREATE_PASS) \
2045 if (Name == NAME) { \
2046 MFPM.addPass(CREATE_PASS); \
2047 return Error::success(); \
2048 }
2049#define MACHINE_FUNCTION_PASS(NAME, CREATE_PASS) \
2050 if (Name == NAME) { \
2051 MFPM.addPass(CREATE_PASS); \
2052 return Error::success(); \
2053 }
2054#define MACHINE_FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, \
2055 PARAMS) \
2056 if (checkParametrizedPassName(Name, NAME)) { \
2057 auto Params = parsePassParameters(PARSER, Name, NAME); \
2058 if (!Params) \
2059 return Params.takeError(); \
2060 MFPM.addPass(CREATE_PASS(Params.get())); \
2061 return Error::success(); \
2062 }
2063#define MACHINE_FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
2064 if (Name == "require<" NAME ">") { \
2065 MFPM.addPass( \
2066 RequireAnalysisPass<std::remove_reference_t<decltype(CREATE_PASS)>, \
2067 MachineFunction>()); \
2068 return Error::success(); \
2069 } \
2070 if (Name == "invalidate<" NAME ">") { \
2071 MFPM.addPass(InvalidateAnalysisPass< \
2072 std::remove_reference_t<decltype(CREATE_PASS)>>()); \
2073 return Error::success(); \
2074 }
2075#include "llvm/Passes/MachinePassRegistry.def"
2076
2077 for (auto &C : MachineFunctionPipelineParsingCallbacks)
2078 if (C(Name, MFPM, E.InnerPipeline))
2079 return Error::success();
2080 return make_error<StringError>(
2081 formatv("unknown machine pass '{0}'", Name).str(),
2083}
2084
2085bool PassBuilder::parseAAPassName(AAManager &AA, StringRef Name) {
2086#define MODULE_ALIAS_ANALYSIS(NAME, CREATE_PASS) \
2087 if (Name == NAME) { \
2088 AA.registerModuleAnalysis< \
2089 std::remove_reference_t<decltype(CREATE_PASS)>>(); \
2090 return true; \
2091 }
2092#define FUNCTION_ALIAS_ANALYSIS(NAME, CREATE_PASS) \
2093 if (Name == NAME) { \
2094 AA.registerFunctionAnalysis< \
2095 std::remove_reference_t<decltype(CREATE_PASS)>>(); \
2096 return true; \
2097 }
2098#include "PassRegistry.def"
2099
2100 for (auto &C : AAParsingCallbacks)
2101 if (C(Name, AA))
2102 return true;
2103 return false;
2104}
2105
2106Error PassBuilder::parseMachinePassPipeline(
2108 for (const auto &Element : Pipeline) {
2109 if (auto Err = parseMachinePass(MFPM, Element))
2110 return Err;
2111 }
2112 return Error::success();
2113}
2114
2115Error PassBuilder::parseLoopPassPipeline(LoopPassManager &LPM,
2116 ArrayRef<PipelineElement> Pipeline) {
2117 for (const auto &Element : Pipeline) {
2118 if (auto Err = parseLoopPass(LPM, Element))
2119 return Err;
2120 }
2121 return Error::success();
2122}
2123
2124Error PassBuilder::parseFunctionPassPipeline(
2126 for (const auto &Element : Pipeline) {
2127 if (auto Err = parseFunctionPass(FPM, Element))
2128 return Err;
2129 }
2130 return Error::success();
2131}
2132
2133Error PassBuilder::parseCGSCCPassPipeline(CGSCCPassManager &CGPM,
2134 ArrayRef<PipelineElement> Pipeline) {
2135 for (const auto &Element : Pipeline) {
2136 if (auto Err = parseCGSCCPass(CGPM, Element))
2137 return Err;
2138 }
2139 return Error::success();
2140}
2141
2154 if (MFAM) {
2156 [&] { return MachineFunctionAnalysisManagerModuleProxy(*MFAM); });
2158 [&] { return MachineFunctionAnalysisManagerFunctionProxy(*MFAM); });
2159 MFAM->registerPass(
2161 MFAM->registerPass(
2163 }
2164}
2165
2166Error PassBuilder::parseModulePassPipeline(ModulePassManager &MPM,
2167 ArrayRef<PipelineElement> Pipeline) {
2168 for (const auto &Element : Pipeline) {
2169 if (auto Err = parseModulePass(MPM, Element))
2170 return Err;
2171 }
2172 return Error::success();
2173}
2174
2175// Primary pass pipeline description parsing routine for a \c ModulePassManager
2176// FIXME: Should this routine accept a TargetMachine or require the caller to
2177// pre-populate the analysis managers with target-specific stuff?
2179 StringRef PipelineText) {
2180 auto Pipeline = parsePipelineText(PipelineText);
2181 if (!Pipeline || Pipeline->empty())
2182 return make_error<StringError>(
2183 formatv("invalid pipeline '{0}'", PipelineText).str(),
2185
2186 // If the first name isn't at the module layer, wrap the pipeline up
2187 // automatically.
2188 StringRef FirstName = Pipeline->front().Name;
2189
2190 if (!isModulePassName(FirstName, ModulePipelineParsingCallbacks)) {
2191 bool UseMemorySSA;
2192 if (isCGSCCPassName(FirstName, CGSCCPipelineParsingCallbacks)) {
2193 Pipeline = {{"cgscc", std::move(*Pipeline)}};
2194 } else if (isFunctionPassName(FirstName,
2195 FunctionPipelineParsingCallbacks)) {
2196 Pipeline = {{"function", std::move(*Pipeline)}};
2197 } else if (isLoopNestPassName(FirstName, LoopPipelineParsingCallbacks,
2198 UseMemorySSA)) {
2199 Pipeline = {{"function", {{UseMemorySSA ? "loop-mssa" : "loop",
2200 std::move(*Pipeline)}}}};
2201 } else if (isLoopPassName(FirstName, LoopPipelineParsingCallbacks,
2202 UseMemorySSA)) {
2203 Pipeline = {{"function", {{UseMemorySSA ? "loop-mssa" : "loop",
2204 std::move(*Pipeline)}}}};
2205 } else if (isMachineFunctionPassName(
2206 FirstName, MachineFunctionPipelineParsingCallbacks)) {
2207 Pipeline = {{"function", {{"machine-function", std::move(*Pipeline)}}}};
2208 } else {
2209 for (auto &C : TopLevelPipelineParsingCallbacks)
2210 if (C(MPM, *Pipeline))
2211 return Error::success();
2212
2213 // Unknown pass or pipeline name!
2214 auto &InnerPipeline = Pipeline->front().InnerPipeline;
2215 return make_error<StringError>(
2216 formatv("unknown {0} name '{1}'",
2217 (InnerPipeline.empty() ? "pass" : "pipeline"), FirstName)
2218 .str(),
2220 }
2221 }
2222
2223 if (auto Err = parseModulePassPipeline(MPM, *Pipeline))
2224 return Err;
2225 return Error::success();
2226}
2227
2228// Primary pass pipeline description parsing routine for a \c CGSCCPassManager
2230 StringRef PipelineText) {
2231 auto Pipeline = parsePipelineText(PipelineText);
2232 if (!Pipeline || Pipeline->empty())
2233 return make_error<StringError>(
2234 formatv("invalid pipeline '{0}'", PipelineText).str(),
2236
2237 StringRef FirstName = Pipeline->front().Name;
2238 if (!isCGSCCPassName(FirstName, CGSCCPipelineParsingCallbacks))
2239 return make_error<StringError>(
2240 formatv("unknown cgscc pass '{0}' in pipeline '{1}'", FirstName,
2241 PipelineText)
2242 .str(),
2244
2245 if (auto Err = parseCGSCCPassPipeline(CGPM, *Pipeline))
2246 return Err;
2247 return Error::success();
2248}
2249
2250// Primary pass pipeline description parsing routine for a \c
2251// FunctionPassManager
2253 StringRef PipelineText) {
2254 auto Pipeline = parsePipelineText(PipelineText);
2255 if (!Pipeline || Pipeline->empty())
2256 return make_error<StringError>(
2257 formatv("invalid pipeline '{0}'", PipelineText).str(),
2259
2260 StringRef FirstName = Pipeline->front().Name;
2261 if (!isFunctionPassName(FirstName, FunctionPipelineParsingCallbacks))
2262 return make_error<StringError>(
2263 formatv("unknown function pass '{0}' in pipeline '{1}'", FirstName,
2264 PipelineText)
2265 .str(),
2267
2268 if (auto Err = parseFunctionPassPipeline(FPM, *Pipeline))
2269 return Err;
2270 return Error::success();
2271}
2272
2273// Primary pass pipeline description parsing routine for a \c LoopPassManager
2275 StringRef PipelineText) {
2276 auto Pipeline = parsePipelineText(PipelineText);
2277 if (!Pipeline || Pipeline->empty())
2278 return make_error<StringError>(
2279 formatv("invalid pipeline '{0}'", PipelineText).str(),
2281
2282 if (auto Err = parseLoopPassPipeline(CGPM, *Pipeline))
2283 return Err;
2284
2285 return Error::success();
2286}
2287
2289 StringRef PipelineText) {
2290 auto Pipeline = parsePipelineText(PipelineText);
2291 if (!Pipeline || Pipeline->empty())
2292 return make_error<StringError>(
2293 formatv("invalid machine pass pipeline '{0}'", PipelineText).str(),
2295
2296 if (auto Err = parseMachinePassPipeline(MFPM, *Pipeline))
2297 return Err;
2298
2299 return Error::success();
2300}
2301
2303 // If the pipeline just consists of the word 'default' just replace the AA
2304 // manager with our default one.
2305 if (PipelineText == "default") {
2307 return Error::success();
2308 }
2309
2310 while (!PipelineText.empty()) {
2312 std::tie(Name, PipelineText) = PipelineText.split(',');
2313 if (!parseAAPassName(AA, Name))
2314 return make_error<StringError>(
2315 formatv("unknown alias analysis name '{0}'", Name).str(),
2317 }
2318
2319 return Error::success();
2320}
2321
2322std::optional<RegAllocFilterFunc>
2324 if (FilterName == "all")
2325 return nullptr;
2326 for (auto &C : RegClassFilterParsingCallbacks)
2327 if (auto F = C(FilterName))
2328 return F;
2329 return std::nullopt;
2330}
2331
2333 OS << " " << PassName << "\n";
2334}
2336 raw_ostream &OS) {
2337 OS << " " << PassName << "<" << Params << ">\n";
2338}
2339
2341 // TODO: print pass descriptions when they are available
2342
2343 OS << "Module passes:\n";
2344#define MODULE_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2345#include "PassRegistry.def"
2346
2347 OS << "Module passes with params:\n";
2348#define MODULE_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
2349 printPassName(NAME, PARAMS, OS);
2350#include "PassRegistry.def"
2351
2352 OS << "Module analyses:\n";
2353#define MODULE_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2354#include "PassRegistry.def"
2355
2356 OS << "Module alias analyses:\n";
2357#define MODULE_ALIAS_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2358#include "PassRegistry.def"
2359
2360 OS << "CGSCC passes:\n";
2361#define CGSCC_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2362#include "PassRegistry.def"
2363
2364 OS << "CGSCC passes with params:\n";
2365#define CGSCC_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
2366 printPassName(NAME, PARAMS, OS);
2367#include "PassRegistry.def"
2368
2369 OS << "CGSCC analyses:\n";
2370#define CGSCC_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2371#include "PassRegistry.def"
2372
2373 OS << "Function passes:\n";
2374#define FUNCTION_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2375#include "PassRegistry.def"
2376
2377 OS << "Function passes with params:\n";
2378#define FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
2379 printPassName(NAME, PARAMS, OS);
2380#include "PassRegistry.def"
2381
2382 OS << "Function analyses:\n";
2383#define FUNCTION_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2384#include "PassRegistry.def"
2385
2386 OS << "Function alias analyses:\n";
2387#define FUNCTION_ALIAS_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2388#include "PassRegistry.def"
2389
2390 OS << "LoopNest passes:\n";
2391#define LOOPNEST_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2392#include "PassRegistry.def"
2393
2394 OS << "Loop passes:\n";
2395#define LOOP_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2396#include "PassRegistry.def"
2397
2398 OS << "Loop passes with params:\n";
2399#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
2400 printPassName(NAME, PARAMS, OS);
2401#include "PassRegistry.def"
2402
2403 OS << "Loop analyses:\n";
2404#define LOOP_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2405#include "PassRegistry.def"
2406
2407 OS << "Machine module passes (WIP):\n";
2408#define MACHINE_MODULE_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2409#include "llvm/Passes/MachinePassRegistry.def"
2410
2411 OS << "Machine function passes (WIP):\n";
2412#define MACHINE_FUNCTION_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2413#include "llvm/Passes/MachinePassRegistry.def"
2414
2415 OS << "Machine function analyses (WIP):\n";
2416#define MACHINE_FUNCTION_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2417#include "llvm/Passes/MachinePassRegistry.def"
2418}
2419
2421 const std::function<bool(ModulePassManager &, ArrayRef<PipelineElement>)>
2422 &C) {
2423 TopLevelPipelineParsingCallbacks.push_back(C);
2424}
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