387 "print-pipeline-passes",
388 cl::desc(
"Print a '-passes' compatible string describing the pipeline "
389 "(best-effort only)."));
400class TriggerCrashModulePass :
public PassInfoMixin<TriggerCrashModulePass> {
406 static StringRef
name() {
return "TriggerCrashModulePass"; }
409class TriggerCrashFunctionPass
416 static StringRef
name() {
return "TriggerCrashFunctionPass"; }
421class TriggerVerifierErrorPass
427 auto *PtrTy = PointerType::getUnqual(
M.getContext());
429 GlobalValue::LinkageTypes::InternalLinkage,
430 "__bad_alias",
nullptr, &M);
450 static StringRef
name() {
return "TriggerVerifierErrorPass"; }
455class RequireAllMachineFunctionPropertiesPass
456 :
public PassInfoMixin<RequireAllMachineFunctionPropertiesPass> {
463 static MachineFunctionProperties getRequiredProperties() {
464 return MachineFunctionProperties()
466 .setFailsVerification()
471 .setRegBankSelected()
473 .setTiedOpsRewritten()
474 .setTracksDebugUserValues()
475 .setTracksLiveness();
477 static StringRef
name() {
return "RequireAllMachineFunctionPropertiesPass"; }
483 std::optional<PGOOptions> PGOOpt,
485 : TM(TM), PTO(PTO), PGOOpt(PGOOpt), PIC(PIC) {
487 TM->registerPassBuilderCallbacks(*
this);
489 PIC->registerClassToPassNameCallback([
this, PIC]() {
493#define MODULE_PASS(NAME, CREATE_PASS) \
494 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
495#define MODULE_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
496 PIC->addClassToPassName(CLASS, NAME);
497#define MODULE_ANALYSIS(NAME, CREATE_PASS) \
498 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
499#define FUNCTION_PASS(NAME, CREATE_PASS) \
500 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
501#define FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
502 PIC->addClassToPassName(CLASS, NAME);
503#define FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
504 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
505#define LOOPNEST_PASS(NAME, CREATE_PASS) \
506 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
507#define LOOP_PASS(NAME, CREATE_PASS) \
508 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
509#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
510 PIC->addClassToPassName(CLASS, NAME);
511#define LOOP_ANALYSIS(NAME, CREATE_PASS) \
512 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
513#define CGSCC_PASS(NAME, CREATE_PASS) \
514 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
515#define CGSCC_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
516 PIC->addClassToPassName(CLASS, NAME);
517#define CGSCC_ANALYSIS(NAME, CREATE_PASS) \
518 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
519#include "PassRegistry.def"
521#define MACHINE_FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
522 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
523#define MACHINE_FUNCTION_PASS(NAME, CREATE_PASS) \
524 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
525#define MACHINE_FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, \
527 PIC->addClassToPassName(CLASS, NAME);
528#include "llvm/Passes/MachinePassRegistry.def"
534#define MODULE_ANALYSIS(NAME, CREATE_PASS) \
535 MAM.registerPass([&] { return CREATE_PASS; });
536#include "PassRegistry.def"
538 for (
auto &
C : ModuleAnalysisRegistrationCallbacks)
543#define CGSCC_ANALYSIS(NAME, CREATE_PASS) \
544 CGAM.registerPass([&] { return CREATE_PASS; });
545#include "PassRegistry.def"
547 for (
auto &
C : CGSCCAnalysisRegistrationCallbacks)
557#define FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
558 FAM.registerPass([&] { return CREATE_PASS; });
559#include "PassRegistry.def"
561 for (
auto &
C : FunctionAnalysisRegistrationCallbacks)
568#define MACHINE_FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
569 MFAM.registerPass([&] { return CREATE_PASS; });
570#include "llvm/Passes/MachinePassRegistry.def"
572 for (
auto &
C : MachineFunctionAnalysisRegistrationCallbacks)
577#define LOOP_ANALYSIS(NAME, CREATE_PASS) \
578 LAM.registerPass([&] { return CREATE_PASS; });
579#include "PassRegistry.def"
581 for (
auto &
C : LoopAnalysisRegistrationCallbacks)
585static std::optional<std::pair<bool, bool>>
587 std::pair<bool, bool> Params;
588 if (!Name.consume_front(
"function"))
592 if (!Name.consume_front(
"<") || !Name.consume_back(
">"))
594 while (!Name.empty()) {
595 auto [Front, Back] = Name.split(
';');
597 if (Front ==
"eager-inv")
599 else if (Front ==
"no-rerun")
600 Params.second =
true;
608 if (!Name.consume_front(
"devirt<") || !Name.consume_back(
">"))
628 std::optional<OptimizationLevel> OptLevel =
parseOptLevel(S);
632 formatv(
"invalid optimization level '{}'", S).str(),
640 while (!Params.
empty()) {
642 std::tie(ParamName, Params) = Params.
split(
';');
644 if (ParamName == OptionName) {
661 while (!Params.
empty()) {
663 std::tie(ParamName, Params) = Params.
split(
';');
668 formatv(
"invalid HardwareLoopPass parameter '{}'", ParamName).str(),
673 if (ParamName.
consume_front(
"hardware-loop-counter-bitwidth=")) {
677 formatv(
"invalid HardwareLoopPass parameter '{}'", ParamName).str(),
682 if (ParamName ==
"force-hardware-loops") {
684 }
else if (ParamName ==
"force-hardware-loop-phi") {
686 }
else if (ParamName ==
"force-nested-hardware-loop") {
688 }
else if (ParamName ==
"force-hardware-loop-guard") {
692 formatv(
"invalid HardwarePass parameter '{}'", ParamName).str(),
696 return HardwareLoopOpts;
708 while (!Params.
empty()) {
710 std::tie(ParamName, Params) = Params.
split(
';');
711 std::optional<OptimizationLevel> OptLevel =
parseOptLevel(ParamName);
713 if (OptLevel && !OptLevel->isOptimizingForSize()) {
714 UnrollOpts.
setOptLevel(OptLevel->getSpeedupLevel());
721 formatv(
"invalid LoopUnrollPass parameter '{}'", ParamName).str(),
728 if (ParamName ==
"partial") {
730 }
else if (ParamName ==
"peeling") {
732 }
else if (ParamName ==
"profile-peeling") {
734 }
else if (ParamName ==
"runtime") {
736 }
else if (ParamName ==
"upperbound") {
740 formatv(
"invalid LoopUnrollPass parameter '{}'", ParamName).str(),
749 Params,
"vfe-linkage-unit-visibility",
"GlobalDCE");
769 Params,
"skip-non-recursive-function-attrs",
"PostOrderFunctionAttrs");
779 formatv(
"too many CFGuardPass parameters '{}'", Params).str(),
782 if (Param ==
"check")
784 if (Param ==
"dispatch")
788 formatv(
"invalid CFGuardPass mechanism: '{}'", Param).str(),
798 "EntryExitInstrumenter");
807 "LowerMatrixIntrinsics");
812 while (!Params.
empty()) {
814 std::tie(ParamName, Params) = Params.
split(
';');
817 if (ParamName ==
"preserve-order")
819 else if (ParamName ==
"rename-all")
821 else if (ParamName ==
"fold-all")
823 else if (ParamName ==
"reorder-operands")
827 formatv(
"invalid normalize pass parameter '{}'", ParamName).str(),
837 while (!Params.
empty()) {
839 std::tie(ParamName, Params) = Params.
split(
';');
841 if (ParamName ==
"kernel") {
842 Result.CompileKernel =
true;
843 }
else if (ParamName ==
"use-after-scope") {
844 Result.UseAfterScope =
true;
847 formatv(
"invalid AddressSanitizer pass parameter '{}'", ParamName)
857 while (!Params.
empty()) {
859 std::tie(ParamName, Params) = Params.
split(
';');
861 if (ParamName ==
"recover") {
863 }
else if (ParamName ==
"kernel") {
864 Result.CompileKernel =
true;
867 formatv(
"invalid HWAddressSanitizer pass parameter '{}'", ParamName)
877 while (!Params.
empty()) {
879 std::tie(ParamName, Params) = Params.
split(
';');
881 if (ParamName ==
"thinlto") {
883 }
else if (ParamName ==
"emit-summary") {
884 Result.EmitLTOSummary =
true;
887 formatv(
"invalid EmbedBitcode pass parameter '{}'", ParamName).str(),
895parseLowerAllowCheckPassOptions(
StringRef Params) {
897 while (!Params.
empty()) {
899 std::tie(ParamName, Params) = Params.
split(
';');
910 std::tie(IndicesStr, CutoffStr) = ParamName.
split(
"]=");
917 formatv(
"invalid LowerAllowCheck pass cutoffs parameter '{}' ({})",
922 if (!IndicesStr.
consume_front(
"cutoffs[") || IndicesStr ==
"")
924 formatv(
"invalid LowerAllowCheck pass index parameter '{}' ({})",
925 IndicesStr, CutoffStr)
929 while (IndicesStr !=
"") {
931 std::tie(firstIndexStr, IndicesStr) = IndicesStr.
split(
'|');
937 "invalid LowerAllowCheck pass index parameter '{}' ({}) {}",
938 firstIndexStr, IndicesStr)
945 if (index >=
Result.cutoffs.size())
946 Result.cutoffs.resize(index + 1, 0);
948 Result.cutoffs[index] = cutoff;
950 }
else if (ParamName.
starts_with(
"runtime_check")) {
952 std::tie(std::ignore, ValueString) = ParamName.
split(
"=");
956 formatv(
"invalid LowerAllowCheck pass runtime_check parameter '{}' "
962 Result.runtime_check = runtime_check;
965 formatv(
"invalid LowerAllowCheck pass parameter '{}'", ParamName)
976 while (!Params.
empty()) {
978 std::tie(ParamName, Params) = Params.
split(
';');
980 if (ParamName ==
"recover") {
982 }
else if (ParamName ==
"kernel") {
987 formatv(
"invalid argument to MemorySanitizer pass track-origins "
992 }
else if (ParamName ==
"eager-checks") {
993 Result.EagerChecks =
true;
996 formatv(
"invalid MemorySanitizer pass parameter '{}'", ParamName)
1007 while (!Params.
empty()) {
1009 std::tie(ParamName, Params) = Params.
split(
';');
1012 if (ParamName ==
"speculate-blocks") {
1014 }
else if (ParamName ==
"simplify-cond-branch") {
1016 }
else if (ParamName ==
"forward-switch-cond") {
1018 }
else if (ParamName ==
"switch-range-to-icmp") {
1020 }
else if (ParamName ==
"switch-to-lookup") {
1022 }
else if (ParamName ==
"keep-loops") {
1024 }
else if (ParamName ==
"hoist-common-insts") {
1026 }
else if (ParamName ==
"hoist-loads-stores-with-cond-faulting") {
1028 }
else if (ParamName ==
"sink-common-insts") {
1030 }
else if (ParamName ==
"speculate-unpredictables") {
1033 APInt BonusInstThreshold;
1036 formatv(
"invalid argument to SimplifyCFG pass bonus-threshold "
1044 formatv(
"invalid SimplifyCFG pass parameter '{}'", ParamName).str(),
1055 Result.setVerifyFixpoint(
true);
1056 while (!Params.
empty()) {
1058 std::tie(ParamName, Params) = Params.
split(
';');
1061 if (ParamName ==
"verify-fixpoint") {
1064 APInt MaxIterations;
1067 formatv(
"invalid argument to InstCombine pass max-iterations "
1075 formatv(
"invalid InstCombine pass parameter '{}'", ParamName).str(),
1085 while (!Params.
empty()) {
1087 std::tie(ParamName, Params) = Params.
split(
';');
1090 if (ParamName ==
"interleave-forced-only") {
1092 }
else if (ParamName ==
"vectorize-forced-only") {
1096 formatv(
"invalid LoopVectorize parameter '{}'", ParamName).str(),
1104 std::pair<bool, bool>
Result = {
false,
true};
1105 while (!Params.
empty()) {
1107 std::tie(ParamName, Params) = Params.
split(
';');
1110 if (ParamName ==
"nontrivial") {
1112 }
else if (ParamName ==
"trivial") {
1116 formatv(
"invalid LoopUnswitch pass parameter '{}'", ParamName).str(),
1125 while (!Params.
empty()) {
1127 std::tie(ParamName, Params) = Params.
split(
';');
1130 if (ParamName ==
"allowspeculation") {
1134 formatv(
"invalid LICM pass parameter '{}'", ParamName).str(),
1142 std::pair<bool, bool>
Result = {
true,
false};
1143 while (!Params.
empty()) {
1145 std::tie(ParamName, Params) = Params.
split(
';');
1148 if (ParamName ==
"header-duplication") {
1150 }
else if (ParamName ==
"prepare-for-lto") {
1154 formatv(
"invalid LoopRotate pass parameter '{}'", ParamName).str(),
1163 while (!Params.
empty()) {
1165 std::tie(ParamName, Params) = Params.
split(
';');
1168 if (ParamName ==
"split-footer-bb") {
1172 formatv(
"invalid MergedLoadStoreMotion pass parameter '{}'",
1183 while (!Params.
empty()) {
1185 std::tie(ParamName, Params) = Params.
split(
';');
1188 if (ParamName ==
"pre") {
1190 }
else if (ParamName ==
"load-pre") {
1192 }
else if (ParamName ==
"split-backedge-load-pre") {
1194 }
else if (ParamName ==
"memdep") {
1198 }
else if (ParamName ==
"memoryssa") {
1204 formatv(
"invalid GVN pass parameter '{}'", ParamName).str(),
1213 while (!Params.
empty()) {
1215 std::tie(ParamName, Params) = Params.
split(
';');
1218 if (ParamName ==
"func-spec")
1222 formatv(
"invalid IPSCCP pass parameter '{}'", ParamName).str(),
1230 while (!Params.
empty()) {
1232 std::tie(ParamName, Params) = Params.
split(
';');
1237 formatv(
"invalid argument to Scalarizer pass min-bits "
1248 if (ParamName ==
"load-store")
1250 else if (ParamName ==
"variable-insert-extract")
1254 formatv(
"invalid Scalarizer pass parameter '{}'", ParamName).str(),
1263 if (Params.
empty() || Params ==
"modify-cfg")
1265 if (Params ==
"preserve-cfg")
1268 formatv(
"invalid SROA pass parameter '{}' (either preserve-cfg or "
1269 "modify-cfg can be specified)",
1276parseStackLifetimeOptions(
StringRef Params) {
1278 while (!Params.
empty()) {
1280 std::tie(ParamName, Params) = Params.
split(
';');
1282 if (ParamName ==
"may") {
1284 }
else if (ParamName ==
"must") {
1288 formatv(
"invalid StackLifetime parameter '{}'", ParamName).str(),
1297 "DependenceAnalysisPrinter");
1302 "SeparateConstOffsetFromGEP");
1311parseFunctionSimplificationPipelineOptions(
StringRef Params) {
1315 formatv(
"invalid function-simplification parameter '{}'", Params).str(),
1323 "MemorySSAPrinterPass");
1328 "SpeculativeExecutionPass");
1333 while (!Params.
empty()) {
1335 std::tie(ParamName, Params) = Params.
split(
';');
1341 formatv(
"invalid MemProfUse pass parameter '{}'", ParamName).str(),
1349parseStructuralHashPrinterPassOptions(
StringRef Params) {
1352 if (Params ==
"detailed")
1354 if (Params ==
"call-target-ignored")
1357 formatv(
"invalid structural hash printer parameter '{}'", Params).str(),
1363 "WinEHPreparePass");
1368 while (!Params.
empty()) {
1370 std::tie(ParamName, Params) = Params.
split(
';');
1373 if (ParamName ==
"group-by-use")
1375 else if (ParamName ==
"ignore-single-use")
1377 else if (ParamName ==
"merge-const")
1379 else if (ParamName ==
"merge-const-aggressive")
1381 else if (ParamName ==
"merge-external")
1386 formatv(
"invalid GlobalMergePass parameter '{}'", ParamName).str(),
1390 formatv(
"invalid global-merge pass parameter '{}'", Params).str(),
1399 while (!Params.
empty()) {
1401 std::tie(ParamName, Params) = Params.
split(
';');
1407 formatv(
"invalid Internalize pass parameter '{}'", ParamName).str(),
1418 while (!Params.
empty()) {
1420 std::tie(ParamName, Params) = Params.
split(
';');
1423 std::optional<RegAllocFilterFunc>
Filter =
1427 formatv(
"invalid regallocfast register filter '{}'", ParamName)
1436 if (ParamName ==
"no-clear-vregs") {
1442 formatv(
"invalid regallocfast pass parameter '{}'", ParamName).str(),
1449parseBoundsCheckingOptions(
StringRef Params) {
1451 while (!Params.
empty()) {
1453 std::tie(ParamName, Params) = Params.
split(
';');
1454 if (ParamName ==
"trap") {
1456 }
else if (ParamName ==
"rt") {
1461 }
else if (ParamName ==
"rt-abort") {
1466 }
else if (ParamName ==
"min-rt") {
1471 }
else if (ParamName ==
"min-rt-abort") {
1476 }
else if (ParamName ==
"merge") {
1481 std::tie(ParamEQ, Val) = ParamName.
split(
'=');
1487 formatv(
"invalid BoundsChecking pass parameter '{}'", ParamName)
1501 std::tie(Param, Params) = Params.
split(
';');
1502 if (!Params.
empty())
1506 if (Name !=
"opt-level")
1508 Param.str().c_str());
1512 if (!
Level.has_value())
1521 if (Params.
empty() || Params ==
"all")
1522 return RAGreedyPass::Options();
1526 return RAGreedyPass::Options{*
Filter, Params};
1529 formatv(
"invalid regallocgreedy register filter '{}'", Params).str(),
1535 "MachineSinkingPass");
1539 bool AllowTailMerge =
true;
1540 if (!Params.
empty()) {
1542 if (Params !=
"tail-merge")
1544 formatv(
"invalid MachineBlockPlacementPass parameter '{}'", Params)
1548 return AllowTailMerge;
1552 bool ClearVirtRegs =
true;
1553 if (!Params.
empty()) {
1555 if (Params !=
"clear-vregs")
1557 formatv(
"invalid VirtRegRewriter pass parameter '{}'", Params).str(),
1560 return ClearVirtRegs;
1563struct FatLTOOptions {
1564 OptimizationLevel OptLevel;
1565 bool ThinLTO =
false;
1566 bool EmitSummary =
false;
1571 bool HaveOptLevel =
false;
1572 while (!Params.
empty()) {
1574 std::tie(ParamName, Params) = Params.
split(
';');
1576 if (ParamName ==
"thinlto") {
1578 }
else if (ParamName ==
"emit-summary") {
1579 Result.EmitSummary =
true;
1580 }
else if (std::optional<OptimizationLevel> OptLevel =
1582 Result.OptLevel = *OptLevel;
1583 HaveOptLevel =
true;
1586 formatv(
"invalid fatlto-pre-link pass parameter '{}'", ParamName)
1593 "missing optimization level for fatlto-pre-link pipeline",
1608template <
typename PassManagerT,
typename CallbacksT>
1610 if (!Callbacks.empty()) {
1611 PassManagerT DummyPM;
1612 for (
auto &CB : Callbacks)
1613 if (CB(Name, DummyPM, {}))
1619template <
typename CallbacksT>
1621 StringRef NameNoBracket = Name.take_until([](
char C) {
return C ==
'<'; });
1624 if (Name ==
"module")
1626 if (Name ==
"cgscc")
1628 if (NameNoBracket ==
"function")
1630 if (Name ==
"coro-cond")
1633#define MODULE_PASS(NAME, CREATE_PASS) \
1636#define MODULE_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1637 if (PassBuilder::checkParametrizedPassName(Name, NAME)) \
1639#define MODULE_ANALYSIS(NAME, CREATE_PASS) \
1640 if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
1642#include "PassRegistry.def"
1647template <
typename CallbacksT>
1650 StringRef NameNoBracket = Name.take_until([](
char C) {
return C ==
'<'; });
1651 if (Name ==
"cgscc")
1653 if (NameNoBracket ==
"function")
1660#define CGSCC_PASS(NAME, CREATE_PASS) \
1663#define CGSCC_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1664 if (PassBuilder::checkParametrizedPassName(Name, NAME)) \
1666#define CGSCC_ANALYSIS(NAME, CREATE_PASS) \
1667 if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
1669#include "PassRegistry.def"
1674template <
typename CallbacksT>
1677 StringRef NameNoBracket = Name.take_until([](
char C) {
return C ==
'<'; });
1678 if (NameNoBracket ==
"function")
1680 if (Name ==
"loop" || Name ==
"loop-mssa" || Name ==
"machine-function")
1683#define FUNCTION_PASS(NAME, CREATE_PASS) \
1686#define FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1687 if (PassBuilder::checkParametrizedPassName(Name, NAME)) \
1689#define FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
1690 if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
1692#include "PassRegistry.def"
1697template <
typename CallbacksT>
1700 if (Name ==
"machine-function")
1703#define MACHINE_FUNCTION_PASS(NAME, CREATE_PASS) \
1706#define MACHINE_FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, \
1708 if (PassBuilder::checkParametrizedPassName(Name, NAME)) \
1711#define MACHINE_FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
1712 if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
1715#include "llvm/Passes/MachinePassRegistry.def"
1720template <
typename CallbacksT>
1722 bool &UseMemorySSA) {
1723 UseMemorySSA =
false;
1726 UseMemorySSA =
true;
1730#define LOOPNEST_PASS(NAME, CREATE_PASS) \
1733#include "PassRegistry.def"
1738template <
typename CallbacksT>
1740 bool &UseMemorySSA) {
1741 UseMemorySSA =
false;
1744 UseMemorySSA =
true;
1748#define LOOP_PASS(NAME, CREATE_PASS) \
1751#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1752 if (PassBuilder::checkParametrizedPassName(Name, NAME)) \
1754#define LOOP_ANALYSIS(NAME, CREATE_PASS) \
1755 if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
1757#include "PassRegistry.def"
1762std::optional<std::vector<PassBuilder::PipelineElement>>
1763PassBuilder::parsePipelineText(
StringRef Text) {
1764 std::vector<PipelineElement> ResultPipeline;
1769 std::vector<PipelineElement> &Pipeline = *PipelineStack.
back();
1770 size_t Pos =
Text.find_first_of(
",()");
1771 Pipeline.push_back({
Text.substr(0, Pos), {}});
1774 if (Pos ==
Text.npos)
1777 char Sep =
Text[Pos];
1785 PipelineStack.
push_back(&Pipeline.back().InnerPipeline);
1789 assert(Sep ==
')' &&
"Bogus separator!");
1794 if (PipelineStack.
size() == 1)
1795 return std::nullopt;
1798 }
while (
Text.consume_front(
")"));
1806 if (!
Text.consume_front(
","))
1807 return std::nullopt;
1810 if (PipelineStack.
size() > 1)
1812 return std::nullopt;
1814 assert(PipelineStack.
back() == &ResultPipeline &&
1815 "Wrong pipeline at the bottom of the stack!");
1816 return {std::move(ResultPipeline)};
1829 const PipelineElement &
E) {
1830 auto &
Name =
E.Name;
1831 auto &InnerPipeline =
E.InnerPipeline;
1834 if (!InnerPipeline.empty()) {
1835 if (Name ==
"module") {
1837 if (
auto Err = parseModulePassPipeline(NestedMPM, InnerPipeline))
1839 MPM.
addPass(std::move(NestedMPM));
1842 if (Name ==
"coro-cond") {
1844 if (
auto Err = parseModulePassPipeline(NestedMPM, InnerPipeline))
1846 MPM.
addPass(CoroConditionalWrapper(std::move(NestedMPM)));
1849 if (Name ==
"cgscc") {
1851 if (
auto Err = parseCGSCCPassPipeline(CGPM, InnerPipeline))
1859 "cannot have a no-rerun module to function adaptor",
1862 if (
auto Err = parseFunctionPassPipeline(FPM, InnerPipeline))
1869 for (
auto &
C : ModulePipelineParsingCallbacks)
1870 if (
C(Name, MPM, InnerPipeline))
1875 formatv(
"invalid use of '{}' pass as module pipeline", Name).str(),
1881#define MODULE_PASS(NAME, CREATE_PASS) \
1882 if (Name == NAME) { \
1883 MPM.addPass(CREATE_PASS); \
1884 return Error::success(); \
1886#define MODULE_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1887 if (checkParametrizedPassName(Name, NAME)) { \
1888 auto Params = parsePassParameters(PARSER, Name, NAME); \
1890 return Params.takeError(); \
1891 MPM.addPass(CREATE_PASS(Params.get())); \
1892 return Error::success(); \
1894#define MODULE_ANALYSIS(NAME, CREATE_PASS) \
1895 if (Name == "require<" NAME ">") { \
1897 RequireAnalysisPass< \
1898 std::remove_reference_t<decltype(CREATE_PASS)>, Module>()); \
1899 return Error::success(); \
1901 if (Name == "invalidate<" NAME ">") { \
1902 MPM.addPass(InvalidateAnalysisPass< \
1903 std::remove_reference_t<decltype(CREATE_PASS)>>()); \
1904 return Error::success(); \
1906#define CGSCC_PASS(NAME, CREATE_PASS) \
1907 if (Name == NAME) { \
1908 MPM.addPass(createModuleToPostOrderCGSCCPassAdaptor(CREATE_PASS)); \
1909 return Error::success(); \
1911#define CGSCC_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1912 if (checkParametrizedPassName(Name, NAME)) { \
1913 auto Params = parsePassParameters(PARSER, Name, NAME); \
1915 return Params.takeError(); \
1917 createModuleToPostOrderCGSCCPassAdaptor(CREATE_PASS(Params.get()))); \
1918 return Error::success(); \
1920#define FUNCTION_PASS(NAME, CREATE_PASS) \
1921 if (Name == NAME) { \
1922 MPM.addPass(createModuleToFunctionPassAdaptor(CREATE_PASS)); \
1923 return Error::success(); \
1925#define FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1926 if (checkParametrizedPassName(Name, NAME)) { \
1927 auto Params = parsePassParameters(PARSER, Name, NAME); \
1929 return Params.takeError(); \
1930 MPM.addPass(createModuleToFunctionPassAdaptor(CREATE_PASS(Params.get()))); \
1931 return Error::success(); \
1933#define LOOPNEST_PASS(NAME, CREATE_PASS) \
1934 if (Name == NAME) { \
1935 MPM.addPass(createModuleToFunctionPassAdaptor( \
1936 createFunctionToLoopPassAdaptor(CREATE_PASS, false, false))); \
1937 return Error::success(); \
1939#define LOOP_PASS(NAME, CREATE_PASS) \
1940 if (Name == NAME) { \
1941 MPM.addPass(createModuleToFunctionPassAdaptor( \
1942 createFunctionToLoopPassAdaptor(CREATE_PASS, false, false))); \
1943 return Error::success(); \
1945#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1946 if (checkParametrizedPassName(Name, NAME)) { \
1947 auto Params = parsePassParameters(PARSER, Name, NAME); \
1949 return Params.takeError(); \
1951 createModuleToFunctionPassAdaptor(createFunctionToLoopPassAdaptor( \
1952 CREATE_PASS(Params.get()), false, false))); \
1953 return Error::success(); \
1955#include "PassRegistry.def"
1957 for (
auto &
C : ModulePipelineParsingCallbacks)
1958 if (
C(Name, MPM, InnerPipeline))
1961 formatv(
"unknown module pass '{}'", Name).str(),
1966 const PipelineElement &
E) {
1967 auto &
Name =
E.Name;
1968 auto &InnerPipeline =
E.InnerPipeline;
1971 if (!InnerPipeline.empty()) {
1972 if (Name ==
"cgscc") {
1974 if (
auto Err = parseCGSCCPassPipeline(NestedCGPM, InnerPipeline))
1977 CGPM.
addPass(std::move(NestedCGPM));
1982 if (
auto Err = parseFunctionPassPipeline(FPM, InnerPipeline))
1986 std::move(FPM), Params->first, Params->second));
1991 if (
auto Err = parseCGSCCPassPipeline(NestedCGPM, InnerPipeline))
1998 for (
auto &
C : CGSCCPipelineParsingCallbacks)
1999 if (
C(Name, CGPM, InnerPipeline))
2004 formatv(
"invalid use of '{}' pass as cgscc pipeline", Name).str(),
2009#define CGSCC_PASS(NAME, CREATE_PASS) \
2010 if (Name == NAME) { \
2011 CGPM.addPass(CREATE_PASS); \
2012 return Error::success(); \
2014#define CGSCC_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
2015 if (checkParametrizedPassName(Name, NAME)) { \
2016 auto Params = parsePassParameters(PARSER, Name, NAME); \
2018 return Params.takeError(); \
2019 CGPM.addPass(CREATE_PASS(Params.get())); \
2020 return Error::success(); \
2022#define CGSCC_ANALYSIS(NAME, CREATE_PASS) \
2023 if (Name == "require<" NAME ">") { \
2024 CGPM.addPass(RequireAnalysisPass< \
2025 std::remove_reference_t<decltype(CREATE_PASS)>, \
2026 LazyCallGraph::SCC, CGSCCAnalysisManager, LazyCallGraph &, \
2027 CGSCCUpdateResult &>()); \
2028 return Error::success(); \
2030 if (Name == "invalidate<" NAME ">") { \
2031 CGPM.addPass(InvalidateAnalysisPass< \
2032 std::remove_reference_t<decltype(CREATE_PASS)>>()); \
2033 return Error::success(); \
2035#define FUNCTION_PASS(NAME, CREATE_PASS) \
2036 if (Name == NAME) { \
2037 CGPM.addPass(createCGSCCToFunctionPassAdaptor(CREATE_PASS)); \
2038 return Error::success(); \
2040#define FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
2041 if (checkParametrizedPassName(Name, NAME)) { \
2042 auto Params = parsePassParameters(PARSER, Name, NAME); \
2044 return Params.takeError(); \
2045 CGPM.addPass(createCGSCCToFunctionPassAdaptor(CREATE_PASS(Params.get()))); \
2046 return Error::success(); \
2048#define LOOPNEST_PASS(NAME, CREATE_PASS) \
2049 if (Name == NAME) { \
2050 CGPM.addPass(createCGSCCToFunctionPassAdaptor( \
2051 createFunctionToLoopPassAdaptor(CREATE_PASS, false, false))); \
2052 return Error::success(); \
2054#define LOOP_PASS(NAME, CREATE_PASS) \
2055 if (Name == NAME) { \
2056 CGPM.addPass(createCGSCCToFunctionPassAdaptor( \
2057 createFunctionToLoopPassAdaptor(CREATE_PASS, false, false))); \
2058 return Error::success(); \
2060#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
2061 if (checkParametrizedPassName(Name, NAME)) { \
2062 auto Params = parsePassParameters(PARSER, Name, NAME); \
2064 return Params.takeError(); \
2066 createCGSCCToFunctionPassAdaptor(createFunctionToLoopPassAdaptor( \
2067 CREATE_PASS(Params.get()), false, false))); \
2068 return Error::success(); \
2070#include "PassRegistry.def"
2072 for (
auto &
C : CGSCCPipelineParsingCallbacks)
2073 if (
C(Name, CGPM, InnerPipeline))
2080 const PipelineElement &
E) {
2081 auto &
Name =
E.Name;
2082 auto &InnerPipeline =
E.InnerPipeline;
2085 if (!InnerPipeline.empty()) {
2086 if (Name ==
"function") {
2088 if (
auto Err = parseFunctionPassPipeline(NestedFPM, InnerPipeline))
2091 FPM.
addPass(std::move(NestedFPM));
2094 if (Name ==
"loop" || Name ==
"loop-mssa") {
2096 if (
auto Err = parseLoopPassPipeline(LPM, InnerPipeline))
2099 bool UseMemorySSA = (
Name ==
"loop-mssa");
2101 return Pipeline.Name.contains(
"simple-loop-unswitch");
2103 bool UseBPI =
llvm::any_of(InnerPipeline, [](
auto Pipeline) {
2104 return Pipeline.Name ==
"loop-predication";
2110 if (Name ==
"machine-function") {
2112 if (
auto Err = parseMachinePassPipeline(MFPM, InnerPipeline))
2118 for (
auto &
C : FunctionPipelineParsingCallbacks)
2119 if (
C(Name, FPM, InnerPipeline))
2124 formatv(
"invalid use of '{}' pass as function pipeline", Name).str(),
2129#define FUNCTION_PASS(NAME, CREATE_PASS) \
2130 if (Name == NAME) { \
2131 FPM.addPass(CREATE_PASS); \
2132 return Error::success(); \
2134#define FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
2135 if (checkParametrizedPassName(Name, NAME)) { \
2136 auto Params = parsePassParameters(PARSER, Name, NAME); \
2138 return Params.takeError(); \
2139 FPM.addPass(CREATE_PASS(Params.get())); \
2140 return Error::success(); \
2142#define FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
2143 if (Name == "require<" NAME ">") { \
2145 RequireAnalysisPass< \
2146 std::remove_reference_t<decltype(CREATE_PASS)>, Function>()); \
2147 return Error::success(); \
2149 if (Name == "invalidate<" NAME ">") { \
2150 FPM.addPass(InvalidateAnalysisPass< \
2151 std::remove_reference_t<decltype(CREATE_PASS)>>()); \
2152 return Error::success(); \
2158#define LOOPNEST_PASS(NAME, CREATE_PASS) \
2159 if (Name == NAME) { \
2160 FPM.addPass(createFunctionToLoopPassAdaptor(CREATE_PASS, false, false)); \
2161 return Error::success(); \
2163#define LOOP_PASS(NAME, CREATE_PASS) \
2164 if (Name == NAME) { \
2165 FPM.addPass(createFunctionToLoopPassAdaptor(CREATE_PASS, false, false)); \
2166 return Error::success(); \
2168#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
2169 if (checkParametrizedPassName(Name, NAME)) { \
2170 auto Params = parsePassParameters(PARSER, Name, NAME); \
2172 return Params.takeError(); \
2173 FPM.addPass(createFunctionToLoopPassAdaptor(CREATE_PASS(Params.get()), \
2175 return Error::success(); \
2177#include "PassRegistry.def"
2179 for (
auto &
C : FunctionPipelineParsingCallbacks)
2180 if (
C(Name, FPM, InnerPipeline))
2183 formatv(
"unknown function pass '{}'", Name).str(),
2188 const PipelineElement &
E) {
2189 StringRef
Name =
E.Name;
2190 auto &InnerPipeline =
E.InnerPipeline;
2193 if (!InnerPipeline.empty()) {
2194 if (Name ==
"loop") {
2196 if (
auto Err = parseLoopPassPipeline(NestedLPM, InnerPipeline))
2199 LPM.addPass(std::move(NestedLPM));
2203 for (
auto &
C : LoopPipelineParsingCallbacks)
2204 if (
C(Name, LPM, InnerPipeline))
2209 formatv(
"invalid use of '{}' pass as loop pipeline", Name).str(),
2214#define LOOPNEST_PASS(NAME, CREATE_PASS) \
2215 if (Name == NAME) { \
2216 LPM.addPass(CREATE_PASS); \
2217 return Error::success(); \
2219#define LOOP_PASS(NAME, CREATE_PASS) \
2220 if (Name == NAME) { \
2221 LPM.addPass(CREATE_PASS); \
2222 return Error::success(); \
2224#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
2225 if (checkParametrizedPassName(Name, NAME)) { \
2226 auto Params = parsePassParameters(PARSER, Name, NAME); \
2228 return Params.takeError(); \
2229 LPM.addPass(CREATE_PASS(Params.get())); \
2230 return Error::success(); \
2232#define LOOP_ANALYSIS(NAME, CREATE_PASS) \
2233 if (Name == "require<" NAME ">") { \
2234 LPM.addPass(RequireAnalysisPass< \
2235 std::remove_reference_t<decltype(CREATE_PASS)>, Loop, \
2236 LoopAnalysisManager, LoopStandardAnalysisResults &, \
2238 return Error::success(); \
2240 if (Name == "invalidate<" NAME ">") { \
2241 LPM.addPass(InvalidateAnalysisPass< \
2242 std::remove_reference_t<decltype(CREATE_PASS)>>()); \
2243 return Error::success(); \
2245#include "PassRegistry.def"
2247 for (
auto &
C : LoopPipelineParsingCallbacks)
2248 if (
C(Name, LPM, InnerPipeline))
2255 const PipelineElement &
E) {
2256 StringRef
Name =
E.Name;
2258 if (!
E.InnerPipeline.empty()) {
2259 if (
E.Name ==
"machine-function") {
2261 if (
auto Err = parseMachinePassPipeline(NestedPM,
E.InnerPipeline))
2263 MFPM.
addPass(std::move(NestedPM));
2270#define MACHINE_MODULE_PASS(NAME, CREATE_PASS) \
2271 if (Name == NAME) { \
2272 MFPM.addPass(CREATE_PASS); \
2273 return Error::success(); \
2275#define MACHINE_FUNCTION_PASS(NAME, CREATE_PASS) \
2276 if (Name == NAME) { \
2277 MFPM.addPass(CREATE_PASS); \
2278 return Error::success(); \
2280#define MACHINE_FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, \
2282 if (checkParametrizedPassName(Name, NAME)) { \
2283 auto Params = parsePassParameters(PARSER, Name, NAME); \
2285 return Params.takeError(); \
2286 MFPM.addPass(CREATE_PASS(Params.get())); \
2287 return Error::success(); \
2289#define MACHINE_FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
2290 if (Name == "require<" NAME ">") { \
2292 RequireAnalysisPass<std::remove_reference_t<decltype(CREATE_PASS)>, \
2293 MachineFunction>()); \
2294 return Error::success(); \
2296 if (Name == "invalidate<" NAME ">") { \
2297 MFPM.addPass(InvalidateAnalysisPass< \
2298 std::remove_reference_t<decltype(CREATE_PASS)>>()); \
2299 return Error::success(); \
2301#include "llvm/Passes/MachinePassRegistry.def"
2303 for (
auto &
C : MachineFunctionPipelineParsingCallbacks)
2304 if (
C(Name, MFPM,
E.InnerPipeline))
2307 formatv(
"unknown machine pass '{}'", Name).str(),
2312#define MODULE_ALIAS_ANALYSIS(NAME, CREATE_PASS) \
2313 if (Name == NAME) { \
2314 AA.registerModuleAnalysis< \
2315 std::remove_reference_t<decltype(CREATE_PASS)>>(); \
2318#define FUNCTION_ALIAS_ANALYSIS(NAME, CREATE_PASS) \
2319 if (Name == NAME) { \
2320 AA.registerFunctionAnalysis< \
2321 std::remove_reference_t<decltype(CREATE_PASS)>>(); \
2324#include "PassRegistry.def"
2326 for (
auto &
C : AAParsingCallbacks)
2332Error PassBuilder::parseMachinePassPipeline(
2334 for (
const auto &Element : Pipeline) {
2335 if (
auto Err = parseMachinePass(MFPM, Element))
2343 for (
const auto &Element : Pipeline) {
2344 if (
auto Err = parseLoopPass(LPM, Element))
2350Error PassBuilder::parseFunctionPassPipeline(
2352 for (
const auto &Element : Pipeline) {
2353 if (
auto Err = parseFunctionPass(FPM, Element))
2361 for (
const auto &Element : Pipeline) {
2362 if (
auto Err = parseCGSCCPass(CGPM, Element))
2394 for (
const auto &Element : Pipeline) {
2395 if (
auto Err = parseModulePass(MPM, Element))
2406 auto Pipeline = parsePipelineText(PipelineText);
2407 if (!Pipeline || Pipeline->empty())
2409 formatv(
"invalid pipeline '{}'", PipelineText).str(),
2419 Pipeline = {{
"cgscc", std::move(*Pipeline)}};
2421 FunctionPipelineParsingCallbacks)) {
2422 Pipeline = {{
"function", std::move(*Pipeline)}};
2425 Pipeline = {{
"function", {{UseMemorySSA ?
"loop-mssa" :
"loop",
2426 std::move(*Pipeline)}}}};
2427 }
else if (
isLoopPassName(FirstName, LoopPipelineParsingCallbacks,
2429 Pipeline = {{
"function", {{UseMemorySSA ?
"loop-mssa" :
"loop",
2430 std::move(*Pipeline)}}}};
2432 FirstName, MachineFunctionPipelineParsingCallbacks)) {
2433 Pipeline = {{
"function", {{
"machine-function", std::move(*Pipeline)}}}};
2435 for (
auto &
C : TopLevelPipelineParsingCallbacks)
2436 if (
C(MPM, *Pipeline))
2440 auto &InnerPipeline = Pipeline->front().InnerPipeline;
2442 formatv(
"unknown {} name '{}'",
2443 (InnerPipeline.empty() ?
"pass" :
"pipeline"), FirstName)
2449 if (
auto Err = parseModulePassPipeline(MPM, *Pipeline))
2457 auto Pipeline = parsePipelineText(PipelineText);
2458 if (!Pipeline || Pipeline->empty())
2460 formatv(
"invalid pipeline '{}'", PipelineText).str(),
2466 formatv(
"unknown cgscc pass '{}' in pipeline '{}'", FirstName,
2471 if (
auto Err = parseCGSCCPassPipeline(CGPM, *Pipeline))
2480 auto Pipeline = parsePipelineText(PipelineText);
2481 if (!Pipeline || Pipeline->empty())
2483 formatv(
"invalid pipeline '{}'", PipelineText).str(),
2489 formatv(
"unknown function pass '{}' in pipeline '{}'", FirstName,
2494 if (
auto Err = parseFunctionPassPipeline(FPM, *Pipeline))
2502 auto Pipeline = parsePipelineText(PipelineText);
2503 if (!Pipeline || Pipeline->empty())
2505 formatv(
"invalid pipeline '{}'", PipelineText).str(),
2508 if (
auto Err = parseLoopPassPipeline(CGPM, *Pipeline))
2516 auto Pipeline = parsePipelineText(PipelineText);
2517 if (!Pipeline || Pipeline->empty())
2519 formatv(
"invalid machine pass pipeline '{}'", PipelineText).str(),
2522 if (
auto Err = parseMachinePassPipeline(MFPM, *Pipeline))
2531 if (PipelineText ==
"default") {
2536 while (!PipelineText.
empty()) {
2538 std::tie(Name, PipelineText) = PipelineText.
split(
',');
2539 if (!parseAAPassName(
AA, Name))
2541 formatv(
"unknown alias analysis name '{}'", Name).str(),
2548std::optional<RegAllocFilterFunc>
2550 if (FilterName ==
"all")
2552 for (
auto &
C : RegClassFilterParsingCallbacks)
2553 if (
auto F =
C(FilterName))
2555 return std::nullopt;
2563 OS <<
" " <<
PassName <<
"<" << Params <<
">\n";
2569 OS <<
"Module passes:\n";
2570#define MODULE_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2571#include "PassRegistry.def"
2573 OS <<
"Module passes with params:\n";
2574#define MODULE_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
2575 printPassName(NAME, PARAMS, OS);
2576#include "PassRegistry.def"
2578 OS <<
"Module analyses:\n";
2579#define MODULE_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2580#include "PassRegistry.def"
2582 OS <<
"Module alias analyses:\n";
2583#define MODULE_ALIAS_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2584#include "PassRegistry.def"
2586 OS <<
"CGSCC passes:\n";
2587#define CGSCC_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2588#include "PassRegistry.def"
2590 OS <<
"CGSCC passes with params:\n";
2591#define CGSCC_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
2592 printPassName(NAME, PARAMS, OS);
2593#include "PassRegistry.def"
2595 OS <<
"CGSCC analyses:\n";
2596#define CGSCC_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2597#include "PassRegistry.def"
2599 OS <<
"Function passes:\n";
2600#define FUNCTION_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2601#include "PassRegistry.def"
2603 OS <<
"Function passes with params:\n";
2604#define FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
2605 printPassName(NAME, PARAMS, OS);
2606#include "PassRegistry.def"
2608 OS <<
"Function analyses:\n";
2609#define FUNCTION_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2610#include "PassRegistry.def"
2612 OS <<
"Function alias analyses:\n";
2613#define FUNCTION_ALIAS_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2614#include "PassRegistry.def"
2616 OS <<
"LoopNest passes:\n";
2617#define LOOPNEST_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2618#include "PassRegistry.def"
2620 OS <<
"Loop passes:\n";
2621#define LOOP_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2622#include "PassRegistry.def"
2624 OS <<
"Loop passes with params:\n";
2625#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
2626 printPassName(NAME, PARAMS, OS);
2627#include "PassRegistry.def"
2629 OS <<
"Loop analyses:\n";
2630#define LOOP_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2631#include "PassRegistry.def"
2633 OS <<
"Machine module passes (WIP):\n";
2634#define MACHINE_MODULE_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2635#include "llvm/Passes/MachinePassRegistry.def"
2637 OS <<
"Machine function passes (WIP):\n";
2638#define MACHINE_FUNCTION_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2639#include "llvm/Passes/MachinePassRegistry.def"
2641 OS <<
"Machine function analyses (WIP):\n";
2642#define MACHINE_FUNCTION_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2643#include "llvm/Passes/MachinePassRegistry.def"
2649 TopLevelPipelineParsingCallbacks.push_back(
C);
unsigned const MachineRegisterInfo * MRI
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
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.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
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...
Analysis that tracks defined/used subregister lanes across COPY instructions and instructions that ge...
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 ...
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.
Provides analysis for querying information about KnownBits during GISel passes.
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.
AcceleratorCodeSelection - Identify all functions reachable from a kernel, removing those that are un...
This file defines the IR2Vec vocabulary analysis(IR2VecVocabAnalysis), the core ir2vec::Embedder inte...
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.
Machine Check Debug Module
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
FunctionAnalysisManager FAM
ModuleAnalysisManager MAM
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 isLoopNestPassName(StringRef Name, CallbacksT &Callbacks, bool &UseMemorySSA)
static bool isMachineFunctionPassName(StringRef Name, CallbacksT &Callbacks)
static Expected< OptimizationLevel > parseOptLevelParam(StringRef S)
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 void setupOptionsForPipelineAlias(PipelineTuningOptions &PTO, OptimizationLevel L)
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...
This file provides the interface for LLVM's Scalar Replacement of Aggregates pass.
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 is the interface for a metadata-based TBAA.
static const char PassName[]
A manager for alias analyses.
Class for arbitrary precision integers.
uint64_t getZExtValue() const
Get zero extended value.
int64_t getSExtValue() const
Get sign extended value.
bool registerPass(PassBuilderT &&PassBuilder)
Register an analysis pass with the manager.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
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...
Lightweight error class with error context and mandatory checking.
static ErrorSuccess success()
Create a success value.
Tagged union holding either a T or a Error.
static LLVM_ABI 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...
static constexpr LLT scalar(unsigned SizeInBits)
Get a low-level scalar or aggregate "bag of bits".
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
const MachineFunctionProperties & getProperties() const
Get the function properties.
static LLVM_ABI const OptimizationLevel O3
Optimize for fast execution as much as possible.
static LLVM_ABI const OptimizationLevel Oz
A very specialized mode that will optimize for code size at any and all costs.
static LLVM_ABI const OptimizationLevel O0
Disable as many optimizations as possible.
static LLVM_ABI const OptimizationLevel Os
Similar to O2 but tries to optimize for small code size instead of fast execution without triggering ...
static LLVM_ABI const OptimizationLevel O2
Optimize for fast execution as much as possible without triggering significant incremental compile ti...
static LLVM_ABI const OptimizationLevel O1
Optimize quickly without destroying debuggability.
This class provides access to building LLVM's passes.
LLVM_ABI void printPassNames(raw_ostream &OS)
Print pass names.
static bool checkParametrizedPassName(StringRef Name, StringRef PassName)
LLVM_ABI AAManager buildDefaultAAPipeline()
Build the default AAManager with the default alias analysis pipeline registered.
LLVM_ABI Error parseAAPipeline(AAManager &AA, StringRef PipelineText)
Parse a textual alias analysis pipeline into the provided AA manager.
LLVM_ABI PassBuilder(TargetMachine *TM=nullptr, PipelineTuningOptions PTO=PipelineTuningOptions(), std::optional< PGOOptions > PGOOpt=std::nullopt, PassInstrumentationCallbacks *PIC=nullptr)
LLVM_ABI void registerLoopAnalyses(LoopAnalysisManager &LAM)
Registers all available loop analysis passes.
LLVM_ABI std::optional< RegAllocFilterFunc > parseRegAllocFilter(StringRef RegAllocFilterName)
Parse RegAllocFilterName to get RegAllocFilterFunc.
LLVM_ABI void crossRegisterProxies(LoopAnalysisManager &LAM, FunctionAnalysisManager &FAM, CGSCCAnalysisManager &CGAM, ModuleAnalysisManager &MAM, MachineFunctionAnalysisManager *MFAM=nullptr)
Cross register the analysis managers through their proxies.
LLVM_ABI Error parsePassPipeline(ModulePassManager &MPM, StringRef PipelineText)
Parse a textual pass pipeline description into a ModulePassManager.
LLVM_ABI void registerModuleAnalyses(ModuleAnalysisManager &MAM)
Registers all available module analysis passes.
LLVM_ABI void registerCGSCCAnalyses(CGSCCAnalysisManager &CGAM)
Registers all available CGSCC analysis passes.
static LLVM_ABI Expected< bool > parseSinglePassOption(StringRef Params, StringRef OptionName, StringRef PassName)
Handle passes only accept one bool-valued parameter.
LLVM_ABI void registerMachineFunctionAnalyses(MachineFunctionAnalysisManager &MFAM)
Registers all available machine function analysis passes.
LLVM_ABI void registerParseTopLevelPipelineCallback(const std::function< bool(ModulePassManager &, ArrayRef< PipelineElement >)> &C)
Register a callback for a top-level pipeline entry.
LLVM_ABI void registerFunctionAnalyses(FunctionAnalysisManager &FAM)
Registers all available function analysis passes.
This class manages callbacks registration, as well as provides a way for PassInstrumentation to pass ...
LLVM_ATTRIBUTE_MINSIZE std::enable_if_t<!std::is_same_v< PassT, PassManager > > addPass(PassT &&Pass)
Tunable parameters for passes in the default pipelines.
bool SLPVectorization
Tuning option to enable/disable slp loop vectorization, set based on opt level.
bool LoopVectorization
Tuning option to enable/disable loop vectorization, set based on opt level.
static PreservedAnalyses none()
Convenience factory function for the empty preserved set.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringRef - Represent a constant reference to a string, i.e.
std::pair< StringRef, StringRef > split(char Separator) const
Split into two substrings around the first occurrence of a separator character.
bool getAsInteger(unsigned Radix, T &Result) const
Parse the current string as an integer of the specified radix.
std::string str() const
str - Get the contents as an std::string.
bool starts_with(StringRef Prefix) const
Check if this string starts with the given Prefix.
constexpr bool empty() const
empty - Check if the string is empty.
char front() const
front - Get the first character in the string.
bool consume_front(StringRef Prefix)
Returns true if this StringRef has the given prefix and removes that prefix.
A switch()-like statement whose cases are string literals.
StringSwitch & Case(StringLiteral S, T Value)
Primary interface to the complete machine description for the target machine.
self_iterator getIterator()
This class implements an extremely fast bulk output stream that can only output to a stream.
Interfaces for registering analysis passes, producing common pass manager configurations,...
Abstract Attribute helper functions.
@ C
The default llvm calling convention, compatible with C.
std::optional< CodeGenOptLevel > getLevel(int OL)
Get the Level identified by the integer OL.
@ BasicBlock
Various leaf nodes.
PointerTypeMap run(const Module &M)
Compute the PointerTypeMap for the module M.
This is an optimization pass for GlobalISel generic memory operations.
OuterAnalysisManagerProxy< CGSCCAnalysisManager, Function > CGSCCAnalysisManagerFunctionProxy
A proxy from a CGSCCAnalysisManager to a Function.
OuterAnalysisManagerProxy< ModuleAnalysisManager, MachineFunction > ModuleAnalysisManagerMachineFunctionProxy
Provide the ModuleAnalysisManager to Function proxy.
ModuleToFunctionPassAdaptor createModuleToFunctionPassAdaptor(FunctionPassT &&Pass, bool EagerlyInvalidate=false)
A function to deduce a function pass type and wrap it in the templated adaptor.
DevirtSCCRepeatedPass createDevirtSCCRepeatedPass(CGSCCPassT &&Pass, int MaxIterations)
A function to deduce a function pass type and wrap it in the templated adaptor.
OuterAnalysisManagerProxy< ModuleAnalysisManager, Function > ModuleAnalysisManagerFunctionProxy
Provide the ModuleAnalysisManager to Function proxy.
LLVM_ABI std::error_code inconvertibleErrorCode()
The value returned by this function can be returned from convertToErrorCode for Error values where no...
InnerAnalysisManagerProxy< FunctionAnalysisManager, Module > FunctionAnalysisManagerModuleProxy
Provide the FunctionAnalysisManager to Module proxy.
InnerAnalysisManagerProxy< LoopAnalysisManager, Function > LoopAnalysisManagerFunctionProxy
A proxy from a LoopAnalysisManager to a Function.
AnalysisManager< MachineFunction > MachineFunctionAnalysisManager
Error createStringError(std::error_code EC, char const *Fmt, const Ts &... Vals)
Create formatted StringError object.
PassManager< LazyCallGraph::SCC, CGSCCAnalysisManager, LazyCallGraph &, CGSCCUpdateResult & > CGSCCPassManager
The CGSCC pass manager.
AnalysisManager< LazyCallGraph::SCC, LazyCallGraph & > CGSCCAnalysisManager
The CGSCC analysis manager.
AnalysisManager< Loop, LoopStandardAnalysisResults & > LoopAnalysisManager
The loop analysis manager.
PassManager< Loop, LoopAnalysisManager, LoopStandardAnalysisResults &, LPMUpdater & > LoopPassManager
The Loop pass manager.
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly.
ModuleToPostOrderCGSCCPassAdaptor createModuleToPostOrderCGSCCPassAdaptor(CGSCCPassT &&Pass)
A function to deduce a function pass type and wrap it in the templated adaptor.
LLVM_ABI cl::opt< bool > PrintPipelinePasses
Common option used by multiple tools to print pipeline passes.
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.
FunctionToMachineFunctionPassAdaptor createFunctionToMachineFunctionPassAdaptor(MachineFunctionPassT &&Pass)
PassManager< Module > ModulePassManager
Convenience typedef for a pass manager over modules.
FunctionAddr VTableAddr Count
class LLVM_GSL_OWNER SmallVector
Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference s...
InnerAnalysisManagerProxy< MachineFunctionAnalysisManager, Function > MachineFunctionAnalysisManagerFunctionProxy
OuterAnalysisManagerProxy< FunctionAnalysisManager, Loop, LoopStandardAnalysisResults & > FunctionAnalysisManagerLoopProxy
A proxy from a FunctionAnalysisManager to a Loop.
Error make_error(ArgTs &&... Args)
Make a Error instance representing failure using the given error info type.
OuterAnalysisManagerProxy< ModuleAnalysisManager, LazyCallGraph::SCC, LazyCallGraph & > ModuleAnalysisManagerCGSCCProxy
A proxy from a ModuleAnalysisManager to an SCC.
InnerAnalysisManagerProxy< MachineFunctionAnalysisManager, Module > MachineFunctionAnalysisManagerModuleProxy
InnerAnalysisManagerProxy< CGSCCAnalysisManager, Module > CGSCCAnalysisManagerModuleProxy
A proxy from a CGSCCAnalysisManager to a Module.
PassManager< Function > FunctionPassManager
Convenience typedef for a pass manager over functions.
MFPropsModifier(PassT &P, MachineFunction &MF) -> MFPropsModifier< PassT >
PassManager< MachineFunction > MachineFunctionPassManager
Convenience typedef for a pass manager over functions.
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.
AnalysisManager< Function > FunctionAnalysisManager
Convenience typedef for the Function analysis manager.
@ Detailed
Hash with opcode only.
@ CallTargetIgnored
Hash with opcode and operands.
AnalysisManager< Module > ModuleAnalysisManager
Convenience typedef for the Module analysis manager.
A special type used by analysis passes to provide an address that identifies that particular analysis...
A set of parameters to control various transforms performed by GVN pass.
HardwareLoopOptions & setForceNested(bool Force)
HardwareLoopOptions & setDecrement(unsigned Count)
HardwareLoopOptions & setForceGuard(bool Force)
HardwareLoopOptions & setForce(bool Force)
HardwareLoopOptions & setCounterBitwidth(unsigned Width)
HardwareLoopOptions & setForcePhi(bool Force)
A set of parameters to control various transforms performed by IPSCCP pass.
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.
RegAllocFilterFunc Filter