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)
1504 if (!
Prefix.empty() || Digit.getAsInteger(10,
N))
1506 Param.str().c_str());
1509 if (!
Level.has_value())
1511 "invalid optimization level for expand-fp pass: %s",
1512 Digit.str().c_str());
1519 if (Params.
empty() || Params ==
"all")
1520 return RAGreedyPass::Options();
1524 return RAGreedyPass::Options{*
Filter, Params};
1527 formatv(
"invalid regallocgreedy register filter '{}'", Params).str(),
1533 "MachineSinkingPass");
1537 bool AllowTailMerge =
true;
1538 if (!Params.
empty()) {
1540 if (Params !=
"tail-merge")
1542 formatv(
"invalid MachineBlockPlacementPass parameter '{}'", Params)
1546 return AllowTailMerge;
1550 bool ClearVirtRegs =
true;
1551 if (!Params.
empty()) {
1553 if (Params !=
"clear-vregs")
1555 formatv(
"invalid VirtRegRewriter pass parameter '{}'", Params).str(),
1558 return ClearVirtRegs;
1561struct FatLTOOptions {
1562 OptimizationLevel OptLevel;
1563 bool ThinLTO =
false;
1564 bool EmitSummary =
false;
1569 bool HaveOptLevel =
false;
1570 while (!Params.
empty()) {
1572 std::tie(ParamName, Params) = Params.
split(
';');
1574 if (ParamName ==
"thinlto") {
1576 }
else if (ParamName ==
"emit-summary") {
1577 Result.EmitSummary =
true;
1578 }
else if (std::optional<OptimizationLevel> OptLevel =
1580 Result.OptLevel = *OptLevel;
1581 HaveOptLevel =
true;
1584 formatv(
"invalid fatlto-pre-link pass parameter '{}'", ParamName)
1591 "missing optimization level for fatlto-pre-link pipeline",
1606template <
typename PassManagerT,
typename CallbacksT>
1608 if (!Callbacks.empty()) {
1609 PassManagerT DummyPM;
1610 for (
auto &CB : Callbacks)
1611 if (CB(Name, DummyPM, {}))
1617template <
typename CallbacksT>
1619 StringRef NameNoBracket = Name.take_until([](
char C) {
return C ==
'<'; });
1622 if (Name ==
"module")
1624 if (Name ==
"cgscc")
1626 if (NameNoBracket ==
"function")
1628 if (Name ==
"coro-cond")
1631#define MODULE_PASS(NAME, CREATE_PASS) \
1634#define MODULE_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1635 if (PassBuilder::checkParametrizedPassName(Name, NAME)) \
1637#define MODULE_ANALYSIS(NAME, CREATE_PASS) \
1638 if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
1640#include "PassRegistry.def"
1645template <
typename CallbacksT>
1648 StringRef NameNoBracket = Name.take_until([](
char C) {
return C ==
'<'; });
1649 if (Name ==
"cgscc")
1651 if (NameNoBracket ==
"function")
1658#define CGSCC_PASS(NAME, CREATE_PASS) \
1661#define CGSCC_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1662 if (PassBuilder::checkParametrizedPassName(Name, NAME)) \
1664#define CGSCC_ANALYSIS(NAME, CREATE_PASS) \
1665 if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
1667#include "PassRegistry.def"
1672template <
typename CallbacksT>
1675 StringRef NameNoBracket = Name.take_until([](
char C) {
return C ==
'<'; });
1676 if (NameNoBracket ==
"function")
1678 if (Name ==
"loop" || Name ==
"loop-mssa" || Name ==
"machine-function")
1681#define FUNCTION_PASS(NAME, CREATE_PASS) \
1684#define FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1685 if (PassBuilder::checkParametrizedPassName(Name, NAME)) \
1687#define FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
1688 if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
1690#include "PassRegistry.def"
1695template <
typename CallbacksT>
1698 if (Name ==
"machine-function")
1701#define MACHINE_FUNCTION_PASS(NAME, CREATE_PASS) \
1704#define MACHINE_FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, \
1706 if (PassBuilder::checkParametrizedPassName(Name, NAME)) \
1709#define MACHINE_FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
1710 if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
1713#include "llvm/Passes/MachinePassRegistry.def"
1718template <
typename CallbacksT>
1720 bool &UseMemorySSA) {
1721 UseMemorySSA =
false;
1724 UseMemorySSA =
true;
1728#define LOOPNEST_PASS(NAME, CREATE_PASS) \
1731#include "PassRegistry.def"
1736template <
typename CallbacksT>
1738 bool &UseMemorySSA) {
1739 UseMemorySSA =
false;
1742 UseMemorySSA =
true;
1746#define LOOP_PASS(NAME, CREATE_PASS) \
1749#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1750 if (PassBuilder::checkParametrizedPassName(Name, NAME)) \
1752#define LOOP_ANALYSIS(NAME, CREATE_PASS) \
1753 if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
1755#include "PassRegistry.def"
1760std::optional<std::vector<PassBuilder::PipelineElement>>
1761PassBuilder::parsePipelineText(
StringRef Text) {
1762 std::vector<PipelineElement> ResultPipeline;
1767 std::vector<PipelineElement> &Pipeline = *PipelineStack.
back();
1768 size_t Pos =
Text.find_first_of(
",()");
1769 Pipeline.push_back({
Text.substr(0, Pos), {}});
1772 if (Pos ==
Text.npos)
1775 char Sep =
Text[Pos];
1783 PipelineStack.
push_back(&Pipeline.back().InnerPipeline);
1787 assert(Sep ==
')' &&
"Bogus separator!");
1792 if (PipelineStack.
size() == 1)
1793 return std::nullopt;
1796 }
while (
Text.consume_front(
")"));
1804 if (!
Text.consume_front(
","))
1805 return std::nullopt;
1808 if (PipelineStack.
size() > 1)
1810 return std::nullopt;
1812 assert(PipelineStack.
back() == &ResultPipeline &&
1813 "Wrong pipeline at the bottom of the stack!");
1814 return {std::move(ResultPipeline)};
1827 const PipelineElement &
E) {
1828 auto &
Name =
E.Name;
1829 auto &InnerPipeline =
E.InnerPipeline;
1832 if (!InnerPipeline.empty()) {
1833 if (Name ==
"module") {
1835 if (
auto Err = parseModulePassPipeline(NestedMPM, InnerPipeline))
1837 MPM.
addPass(std::move(NestedMPM));
1840 if (Name ==
"coro-cond") {
1842 if (
auto Err = parseModulePassPipeline(NestedMPM, InnerPipeline))
1844 MPM.
addPass(CoroConditionalWrapper(std::move(NestedMPM)));
1847 if (Name ==
"cgscc") {
1849 if (
auto Err = parseCGSCCPassPipeline(CGPM, InnerPipeline))
1857 "cannot have a no-rerun module to function adaptor",
1860 if (
auto Err = parseFunctionPassPipeline(FPM, InnerPipeline))
1867 for (
auto &
C : ModulePipelineParsingCallbacks)
1868 if (
C(Name, MPM, InnerPipeline))
1873 formatv(
"invalid use of '{}' pass as module pipeline", Name).str(),
1879#define MODULE_PASS(NAME, CREATE_PASS) \
1880 if (Name == NAME) { \
1881 MPM.addPass(CREATE_PASS); \
1882 return Error::success(); \
1884#define MODULE_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1885 if (checkParametrizedPassName(Name, NAME)) { \
1886 auto Params = parsePassParameters(PARSER, Name, NAME); \
1888 return Params.takeError(); \
1889 MPM.addPass(CREATE_PASS(Params.get())); \
1890 return Error::success(); \
1892#define MODULE_ANALYSIS(NAME, CREATE_PASS) \
1893 if (Name == "require<" NAME ">") { \
1895 RequireAnalysisPass< \
1896 std::remove_reference_t<decltype(CREATE_PASS)>, Module>()); \
1897 return Error::success(); \
1899 if (Name == "invalidate<" NAME ">") { \
1900 MPM.addPass(InvalidateAnalysisPass< \
1901 std::remove_reference_t<decltype(CREATE_PASS)>>()); \
1902 return Error::success(); \
1904#define CGSCC_PASS(NAME, CREATE_PASS) \
1905 if (Name == NAME) { \
1906 MPM.addPass(createModuleToPostOrderCGSCCPassAdaptor(CREATE_PASS)); \
1907 return Error::success(); \
1909#define CGSCC_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1910 if (checkParametrizedPassName(Name, NAME)) { \
1911 auto Params = parsePassParameters(PARSER, Name, NAME); \
1913 return Params.takeError(); \
1915 createModuleToPostOrderCGSCCPassAdaptor(CREATE_PASS(Params.get()))); \
1916 return Error::success(); \
1918#define FUNCTION_PASS(NAME, CREATE_PASS) \
1919 if (Name == NAME) { \
1920 MPM.addPass(createModuleToFunctionPassAdaptor(CREATE_PASS)); \
1921 return Error::success(); \
1923#define FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1924 if (checkParametrizedPassName(Name, NAME)) { \
1925 auto Params = parsePassParameters(PARSER, Name, NAME); \
1927 return Params.takeError(); \
1928 MPM.addPass(createModuleToFunctionPassAdaptor(CREATE_PASS(Params.get()))); \
1929 return Error::success(); \
1931#define LOOPNEST_PASS(NAME, CREATE_PASS) \
1932 if (Name == NAME) { \
1933 MPM.addPass(createModuleToFunctionPassAdaptor( \
1934 createFunctionToLoopPassAdaptor(CREATE_PASS, false, false))); \
1935 return Error::success(); \
1937#define LOOP_PASS(NAME, CREATE_PASS) \
1938 if (Name == NAME) { \
1939 MPM.addPass(createModuleToFunctionPassAdaptor( \
1940 createFunctionToLoopPassAdaptor(CREATE_PASS, false, false))); \
1941 return Error::success(); \
1943#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1944 if (checkParametrizedPassName(Name, NAME)) { \
1945 auto Params = parsePassParameters(PARSER, Name, NAME); \
1947 return Params.takeError(); \
1949 createModuleToFunctionPassAdaptor(createFunctionToLoopPassAdaptor( \
1950 CREATE_PASS(Params.get()), false, false))); \
1951 return Error::success(); \
1953#include "PassRegistry.def"
1955 for (
auto &
C : ModulePipelineParsingCallbacks)
1956 if (
C(Name, MPM, InnerPipeline))
1959 formatv(
"unknown module pass '{}'", Name).str(),
1964 const PipelineElement &
E) {
1965 auto &
Name =
E.Name;
1966 auto &InnerPipeline =
E.InnerPipeline;
1969 if (!InnerPipeline.empty()) {
1970 if (Name ==
"cgscc") {
1972 if (
auto Err = parseCGSCCPassPipeline(NestedCGPM, InnerPipeline))
1975 CGPM.
addPass(std::move(NestedCGPM));
1980 if (
auto Err = parseFunctionPassPipeline(FPM, InnerPipeline))
1984 std::move(FPM), Params->first, Params->second));
1989 if (
auto Err = parseCGSCCPassPipeline(NestedCGPM, InnerPipeline))
1996 for (
auto &
C : CGSCCPipelineParsingCallbacks)
1997 if (
C(Name, CGPM, InnerPipeline))
2002 formatv(
"invalid use of '{}' pass as cgscc pipeline", Name).str(),
2007#define CGSCC_PASS(NAME, CREATE_PASS) \
2008 if (Name == NAME) { \
2009 CGPM.addPass(CREATE_PASS); \
2010 return Error::success(); \
2012#define CGSCC_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
2013 if (checkParametrizedPassName(Name, NAME)) { \
2014 auto Params = parsePassParameters(PARSER, Name, NAME); \
2016 return Params.takeError(); \
2017 CGPM.addPass(CREATE_PASS(Params.get())); \
2018 return Error::success(); \
2020#define CGSCC_ANALYSIS(NAME, CREATE_PASS) \
2021 if (Name == "require<" NAME ">") { \
2022 CGPM.addPass(RequireAnalysisPass< \
2023 std::remove_reference_t<decltype(CREATE_PASS)>, \
2024 LazyCallGraph::SCC, CGSCCAnalysisManager, LazyCallGraph &, \
2025 CGSCCUpdateResult &>()); \
2026 return Error::success(); \
2028 if (Name == "invalidate<" NAME ">") { \
2029 CGPM.addPass(InvalidateAnalysisPass< \
2030 std::remove_reference_t<decltype(CREATE_PASS)>>()); \
2031 return Error::success(); \
2033#define FUNCTION_PASS(NAME, CREATE_PASS) \
2034 if (Name == NAME) { \
2035 CGPM.addPass(createCGSCCToFunctionPassAdaptor(CREATE_PASS)); \
2036 return Error::success(); \
2038#define FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
2039 if (checkParametrizedPassName(Name, NAME)) { \
2040 auto Params = parsePassParameters(PARSER, Name, NAME); \
2042 return Params.takeError(); \
2043 CGPM.addPass(createCGSCCToFunctionPassAdaptor(CREATE_PASS(Params.get()))); \
2044 return Error::success(); \
2046#define LOOPNEST_PASS(NAME, CREATE_PASS) \
2047 if (Name == NAME) { \
2048 CGPM.addPass(createCGSCCToFunctionPassAdaptor( \
2049 createFunctionToLoopPassAdaptor(CREATE_PASS, false, false))); \
2050 return Error::success(); \
2052#define LOOP_PASS(NAME, CREATE_PASS) \
2053 if (Name == NAME) { \
2054 CGPM.addPass(createCGSCCToFunctionPassAdaptor( \
2055 createFunctionToLoopPassAdaptor(CREATE_PASS, false, false))); \
2056 return Error::success(); \
2058#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
2059 if (checkParametrizedPassName(Name, NAME)) { \
2060 auto Params = parsePassParameters(PARSER, Name, NAME); \
2062 return Params.takeError(); \
2064 createCGSCCToFunctionPassAdaptor(createFunctionToLoopPassAdaptor( \
2065 CREATE_PASS(Params.get()), false, false))); \
2066 return Error::success(); \
2068#include "PassRegistry.def"
2070 for (
auto &
C : CGSCCPipelineParsingCallbacks)
2071 if (
C(Name, CGPM, InnerPipeline))
2078 const PipelineElement &
E) {
2079 auto &
Name =
E.Name;
2080 auto &InnerPipeline =
E.InnerPipeline;
2083 if (!InnerPipeline.empty()) {
2084 if (Name ==
"function") {
2086 if (
auto Err = parseFunctionPassPipeline(NestedFPM, InnerPipeline))
2089 FPM.
addPass(std::move(NestedFPM));
2092 if (Name ==
"loop" || Name ==
"loop-mssa") {
2094 if (
auto Err = parseLoopPassPipeline(LPM, InnerPipeline))
2097 bool UseMemorySSA = (
Name ==
"loop-mssa");
2099 return Pipeline.Name.contains(
"simple-loop-unswitch");
2101 bool UseBPI =
llvm::any_of(InnerPipeline, [](
auto Pipeline) {
2102 return Pipeline.Name ==
"loop-predication";
2108 if (Name ==
"machine-function") {
2110 if (
auto Err = parseMachinePassPipeline(MFPM, InnerPipeline))
2116 for (
auto &
C : FunctionPipelineParsingCallbacks)
2117 if (
C(Name, FPM, InnerPipeline))
2122 formatv(
"invalid use of '{}' pass as function pipeline", Name).str(),
2127#define FUNCTION_PASS(NAME, CREATE_PASS) \
2128 if (Name == NAME) { \
2129 FPM.addPass(CREATE_PASS); \
2130 return Error::success(); \
2132#define FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
2133 if (checkParametrizedPassName(Name, NAME)) { \
2134 auto Params = parsePassParameters(PARSER, Name, NAME); \
2136 return Params.takeError(); \
2137 FPM.addPass(CREATE_PASS(Params.get())); \
2138 return Error::success(); \
2140#define FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
2141 if (Name == "require<" NAME ">") { \
2143 RequireAnalysisPass< \
2144 std::remove_reference_t<decltype(CREATE_PASS)>, Function>()); \
2145 return Error::success(); \
2147 if (Name == "invalidate<" NAME ">") { \
2148 FPM.addPass(InvalidateAnalysisPass< \
2149 std::remove_reference_t<decltype(CREATE_PASS)>>()); \
2150 return Error::success(); \
2156#define LOOPNEST_PASS(NAME, CREATE_PASS) \
2157 if (Name == NAME) { \
2158 FPM.addPass(createFunctionToLoopPassAdaptor(CREATE_PASS, false, false)); \
2159 return Error::success(); \
2161#define LOOP_PASS(NAME, CREATE_PASS) \
2162 if (Name == NAME) { \
2163 FPM.addPass(createFunctionToLoopPassAdaptor(CREATE_PASS, false, false)); \
2164 return Error::success(); \
2166#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
2167 if (checkParametrizedPassName(Name, NAME)) { \
2168 auto Params = parsePassParameters(PARSER, Name, NAME); \
2170 return Params.takeError(); \
2171 FPM.addPass(createFunctionToLoopPassAdaptor(CREATE_PASS(Params.get()), \
2173 return Error::success(); \
2175#include "PassRegistry.def"
2177 for (
auto &
C : FunctionPipelineParsingCallbacks)
2178 if (
C(Name, FPM, InnerPipeline))
2181 formatv(
"unknown function pass '{}'", Name).str(),
2186 const PipelineElement &
E) {
2187 StringRef
Name =
E.Name;
2188 auto &InnerPipeline =
E.InnerPipeline;
2191 if (!InnerPipeline.empty()) {
2192 if (Name ==
"loop") {
2194 if (
auto Err = parseLoopPassPipeline(NestedLPM, InnerPipeline))
2197 LPM.addPass(std::move(NestedLPM));
2201 for (
auto &
C : LoopPipelineParsingCallbacks)
2202 if (
C(Name, LPM, InnerPipeline))
2207 formatv(
"invalid use of '{}' pass as loop pipeline", Name).str(),
2212#define LOOPNEST_PASS(NAME, CREATE_PASS) \
2213 if (Name == NAME) { \
2214 LPM.addPass(CREATE_PASS); \
2215 return Error::success(); \
2217#define LOOP_PASS(NAME, CREATE_PASS) \
2218 if (Name == NAME) { \
2219 LPM.addPass(CREATE_PASS); \
2220 return Error::success(); \
2222#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
2223 if (checkParametrizedPassName(Name, NAME)) { \
2224 auto Params = parsePassParameters(PARSER, Name, NAME); \
2226 return Params.takeError(); \
2227 LPM.addPass(CREATE_PASS(Params.get())); \
2228 return Error::success(); \
2230#define LOOP_ANALYSIS(NAME, CREATE_PASS) \
2231 if (Name == "require<" NAME ">") { \
2232 LPM.addPass(RequireAnalysisPass< \
2233 std::remove_reference_t<decltype(CREATE_PASS)>, Loop, \
2234 LoopAnalysisManager, LoopStandardAnalysisResults &, \
2236 return Error::success(); \
2238 if (Name == "invalidate<" NAME ">") { \
2239 LPM.addPass(InvalidateAnalysisPass< \
2240 std::remove_reference_t<decltype(CREATE_PASS)>>()); \
2241 return Error::success(); \
2243#include "PassRegistry.def"
2245 for (
auto &
C : LoopPipelineParsingCallbacks)
2246 if (
C(Name, LPM, InnerPipeline))
2253 const PipelineElement &
E) {
2254 StringRef
Name =
E.Name;
2256 if (!
E.InnerPipeline.empty()) {
2257 if (
E.Name ==
"machine-function") {
2259 if (
auto Err = parseMachinePassPipeline(NestedPM,
E.InnerPipeline))
2261 MFPM.
addPass(std::move(NestedPM));
2268#define MACHINE_MODULE_PASS(NAME, CREATE_PASS) \
2269 if (Name == NAME) { \
2270 MFPM.addPass(CREATE_PASS); \
2271 return Error::success(); \
2273#define MACHINE_FUNCTION_PASS(NAME, CREATE_PASS) \
2274 if (Name == NAME) { \
2275 MFPM.addPass(CREATE_PASS); \
2276 return Error::success(); \
2278#define MACHINE_FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, \
2280 if (checkParametrizedPassName(Name, NAME)) { \
2281 auto Params = parsePassParameters(PARSER, Name, NAME); \
2283 return Params.takeError(); \
2284 MFPM.addPass(CREATE_PASS(Params.get())); \
2285 return Error::success(); \
2287#define MACHINE_FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
2288 if (Name == "require<" NAME ">") { \
2290 RequireAnalysisPass<std::remove_reference_t<decltype(CREATE_PASS)>, \
2291 MachineFunction>()); \
2292 return Error::success(); \
2294 if (Name == "invalidate<" NAME ">") { \
2295 MFPM.addPass(InvalidateAnalysisPass< \
2296 std::remove_reference_t<decltype(CREATE_PASS)>>()); \
2297 return Error::success(); \
2299#include "llvm/Passes/MachinePassRegistry.def"
2301 for (
auto &
C : MachineFunctionPipelineParsingCallbacks)
2302 if (
C(Name, MFPM,
E.InnerPipeline))
2305 formatv(
"unknown machine pass '{}'", Name).str(),
2310#define MODULE_ALIAS_ANALYSIS(NAME, CREATE_PASS) \
2311 if (Name == NAME) { \
2312 AA.registerModuleAnalysis< \
2313 std::remove_reference_t<decltype(CREATE_PASS)>>(); \
2316#define FUNCTION_ALIAS_ANALYSIS(NAME, CREATE_PASS) \
2317 if (Name == NAME) { \
2318 AA.registerFunctionAnalysis< \
2319 std::remove_reference_t<decltype(CREATE_PASS)>>(); \
2322#include "PassRegistry.def"
2324 for (
auto &
C : AAParsingCallbacks)
2330Error PassBuilder::parseMachinePassPipeline(
2332 for (
const auto &Element : Pipeline) {
2333 if (
auto Err = parseMachinePass(MFPM, Element))
2341 for (
const auto &Element : Pipeline) {
2342 if (
auto Err = parseLoopPass(LPM, Element))
2348Error PassBuilder::parseFunctionPassPipeline(
2350 for (
const auto &Element : Pipeline) {
2351 if (
auto Err = parseFunctionPass(FPM, Element))
2359 for (
const auto &Element : Pipeline) {
2360 if (
auto Err = parseCGSCCPass(CGPM, Element))
2392 for (
const auto &Element : Pipeline) {
2393 if (
auto Err = parseModulePass(MPM, Element))
2404 auto Pipeline = parsePipelineText(PipelineText);
2405 if (!Pipeline || Pipeline->empty())
2407 formatv(
"invalid pipeline '{}'", PipelineText).str(),
2417 Pipeline = {{
"cgscc", std::move(*Pipeline)}};
2419 FunctionPipelineParsingCallbacks)) {
2420 Pipeline = {{
"function", std::move(*Pipeline)}};
2423 Pipeline = {{
"function", {{UseMemorySSA ?
"loop-mssa" :
"loop",
2424 std::move(*Pipeline)}}}};
2425 }
else if (
isLoopPassName(FirstName, LoopPipelineParsingCallbacks,
2427 Pipeline = {{
"function", {{UseMemorySSA ?
"loop-mssa" :
"loop",
2428 std::move(*Pipeline)}}}};
2430 FirstName, MachineFunctionPipelineParsingCallbacks)) {
2431 Pipeline = {{
"function", {{
"machine-function", std::move(*Pipeline)}}}};
2433 for (
auto &
C : TopLevelPipelineParsingCallbacks)
2434 if (
C(MPM, *Pipeline))
2438 auto &InnerPipeline = Pipeline->front().InnerPipeline;
2440 formatv(
"unknown {} name '{}'",
2441 (InnerPipeline.empty() ?
"pass" :
"pipeline"), FirstName)
2447 if (
auto Err = parseModulePassPipeline(MPM, *Pipeline))
2455 auto Pipeline = parsePipelineText(PipelineText);
2456 if (!Pipeline || Pipeline->empty())
2458 formatv(
"invalid pipeline '{}'", PipelineText).str(),
2464 formatv(
"unknown cgscc pass '{}' in pipeline '{}'", FirstName,
2469 if (
auto Err = parseCGSCCPassPipeline(CGPM, *Pipeline))
2478 auto Pipeline = parsePipelineText(PipelineText);
2479 if (!Pipeline || Pipeline->empty())
2481 formatv(
"invalid pipeline '{}'", PipelineText).str(),
2487 formatv(
"unknown function pass '{}' in pipeline '{}'", FirstName,
2492 if (
auto Err = parseFunctionPassPipeline(FPM, *Pipeline))
2500 auto Pipeline = parsePipelineText(PipelineText);
2501 if (!Pipeline || Pipeline->empty())
2503 formatv(
"invalid pipeline '{}'", PipelineText).str(),
2506 if (
auto Err = parseLoopPassPipeline(CGPM, *Pipeline))
2514 auto Pipeline = parsePipelineText(PipelineText);
2515 if (!Pipeline || Pipeline->empty())
2517 formatv(
"invalid machine pass pipeline '{}'", PipelineText).str(),
2520 if (
auto Err = parseMachinePassPipeline(MFPM, *Pipeline))
2529 if (PipelineText ==
"default") {
2534 while (!PipelineText.
empty()) {
2536 std::tie(Name, PipelineText) = PipelineText.
split(
',');
2537 if (!parseAAPassName(
AA, Name))
2539 formatv(
"unknown alias analysis name '{}'", Name).str(),
2546std::optional<RegAllocFilterFunc>
2548 if (FilterName ==
"all")
2550 for (
auto &
C : RegClassFilterParsingCallbacks)
2551 if (
auto F =
C(FilterName))
2553 return std::nullopt;
2561 OS <<
" " <<
PassName <<
"<" << Params <<
">\n";
2567 OS <<
"Module passes:\n";
2568#define MODULE_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2569#include "PassRegistry.def"
2571 OS <<
"Module passes with params:\n";
2572#define MODULE_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
2573 printPassName(NAME, PARAMS, OS);
2574#include "PassRegistry.def"
2576 OS <<
"Module analyses:\n";
2577#define MODULE_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2578#include "PassRegistry.def"
2580 OS <<
"Module alias analyses:\n";
2581#define MODULE_ALIAS_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2582#include "PassRegistry.def"
2584 OS <<
"CGSCC passes:\n";
2585#define CGSCC_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2586#include "PassRegistry.def"
2588 OS <<
"CGSCC passes with params:\n";
2589#define CGSCC_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
2590 printPassName(NAME, PARAMS, OS);
2591#include "PassRegistry.def"
2593 OS <<
"CGSCC analyses:\n";
2594#define CGSCC_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2595#include "PassRegistry.def"
2597 OS <<
"Function passes:\n";
2598#define FUNCTION_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2599#include "PassRegistry.def"
2601 OS <<
"Function passes with params:\n";
2602#define FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
2603 printPassName(NAME, PARAMS, OS);
2604#include "PassRegistry.def"
2606 OS <<
"Function analyses:\n";
2607#define FUNCTION_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2608#include "PassRegistry.def"
2610 OS <<
"Function alias analyses:\n";
2611#define FUNCTION_ALIAS_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2612#include "PassRegistry.def"
2614 OS <<
"LoopNest passes:\n";
2615#define LOOPNEST_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2616#include "PassRegistry.def"
2618 OS <<
"Loop passes:\n";
2619#define LOOP_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2620#include "PassRegistry.def"
2622 OS <<
"Loop passes with params:\n";
2623#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
2624 printPassName(NAME, PARAMS, OS);
2625#include "PassRegistry.def"
2627 OS <<
"Loop analyses:\n";
2628#define LOOP_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2629#include "PassRegistry.def"
2631 OS <<
"Machine module passes (WIP):\n";
2632#define MACHINE_MODULE_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2633#include "llvm/Passes/MachinePassRegistry.def"
2635 OS <<
"Machine function passes (WIP):\n";
2636#define MACHINE_FUNCTION_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2637#include "llvm/Passes/MachinePassRegistry.def"
2639 OS <<
"Machine function analyses (WIP):\n";
2640#define MACHINE_FUNCTION_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2641#include "llvm/Passes/MachinePassRegistry.def"
2647 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