388 "print-pipeline-passes",
389 cl::desc(
"Print a '-passes' compatible string describing the pipeline "
390 "(best-effort only)."));
401class TriggerCrashModulePass :
public PassInfoMixin<TriggerCrashModulePass> {
407 static StringRef
name() {
return "TriggerCrashModulePass"; }
410class TriggerCrashFunctionPass
417 static StringRef
name() {
return "TriggerCrashFunctionPass"; }
422class TriggerVerifierErrorPass
428 auto *PtrTy = PointerType::getUnqual(
M.getContext());
430 GlobalValue::LinkageTypes::InternalLinkage,
431 "__bad_alias",
nullptr, &M);
451 static StringRef
name() {
return "TriggerVerifierErrorPass"; }
456class RequireAllMachineFunctionPropertiesPass
457 :
public PassInfoMixin<RequireAllMachineFunctionPropertiesPass> {
464 static MachineFunctionProperties getRequiredProperties() {
465 return MachineFunctionProperties()
467 .setFailsVerification()
472 .setRegBankSelected()
474 .setTiedOpsRewritten()
475 .setTracksDebugUserValues()
476 .setTracksLiveness();
478 static StringRef
name() {
return "RequireAllMachineFunctionPropertiesPass"; }
484 std::optional<PGOOptions> PGOOpt,
486 : TM(TM), PTO(PTO), PGOOpt(PGOOpt), PIC(PIC) {
488 TM->registerPassBuilderCallbacks(*
this);
490 PIC->registerClassToPassNameCallback([
this, PIC]() {
494#define MODULE_PASS(NAME, CREATE_PASS) \
495 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
496#define MODULE_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
497 PIC->addClassToPassName(CLASS, NAME);
498#define MODULE_ANALYSIS(NAME, CREATE_PASS) \
499 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
500#define FUNCTION_PASS(NAME, CREATE_PASS) \
501 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
502#define FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
503 PIC->addClassToPassName(CLASS, NAME);
504#define FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
505 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
506#define LOOPNEST_PASS(NAME, CREATE_PASS) \
507 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
508#define LOOP_PASS(NAME, CREATE_PASS) \
509 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
510#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
511 PIC->addClassToPassName(CLASS, NAME);
512#define LOOP_ANALYSIS(NAME, CREATE_PASS) \
513 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
514#define CGSCC_PASS(NAME, CREATE_PASS) \
515 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
516#define CGSCC_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
517 PIC->addClassToPassName(CLASS, NAME);
518#define CGSCC_ANALYSIS(NAME, CREATE_PASS) \
519 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
520#include "PassRegistry.def"
522#define MACHINE_FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
523 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
524#define MACHINE_FUNCTION_PASS(NAME, CREATE_PASS) \
525 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
526#define MACHINE_FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, \
528 PIC->addClassToPassName(CLASS, NAME);
529#include "llvm/Passes/MachinePassRegistry.def"
535#define MODULE_ANALYSIS(NAME, CREATE_PASS) \
536 MAM.registerPass([&] { return CREATE_PASS; });
537#include "PassRegistry.def"
539 for (
auto &
C : ModuleAnalysisRegistrationCallbacks)
544#define CGSCC_ANALYSIS(NAME, CREATE_PASS) \
545 CGAM.registerPass([&] { return CREATE_PASS; });
546#include "PassRegistry.def"
548 for (
auto &
C : CGSCCAnalysisRegistrationCallbacks)
558#define FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
559 FAM.registerPass([&] { return CREATE_PASS; });
560#include "PassRegistry.def"
562 for (
auto &
C : FunctionAnalysisRegistrationCallbacks)
569#define MACHINE_FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
570 MFAM.registerPass([&] { return CREATE_PASS; });
571#include "llvm/Passes/MachinePassRegistry.def"
573 for (
auto &
C : MachineFunctionAnalysisRegistrationCallbacks)
578#define LOOP_ANALYSIS(NAME, CREATE_PASS) \
579 LAM.registerPass([&] { return CREATE_PASS; });
580#include "PassRegistry.def"
582 for (
auto &
C : LoopAnalysisRegistrationCallbacks)
586static std::optional<std::pair<bool, bool>>
588 std::pair<bool, bool> Params;
589 if (!Name.consume_front(
"function"))
593 if (!Name.consume_front(
"<") || !Name.consume_back(
">"))
595 while (!Name.empty()) {
596 auto [Front, Back] = Name.split(
';');
598 if (Front ==
"eager-inv")
600 else if (Front ==
"no-rerun")
601 Params.second =
true;
609 if (!Name.consume_front(
"devirt<") || !Name.consume_back(
">"))
629 std::optional<OptimizationLevel> OptLevel =
parseOptLevel(S);
633 formatv(
"invalid optimization level '{}'", S).str(),
641 while (!Params.
empty()) {
643 std::tie(ParamName, Params) = Params.
split(
';');
645 if (ParamName == OptionName) {
662 while (!Params.
empty()) {
664 std::tie(ParamName, Params) = Params.
split(
';');
669 formatv(
"invalid HardwareLoopPass parameter '{}'", ParamName).str(),
674 if (ParamName.
consume_front(
"hardware-loop-counter-bitwidth=")) {
678 formatv(
"invalid HardwareLoopPass parameter '{}'", ParamName).str(),
683 if (ParamName ==
"force-hardware-loops") {
685 }
else if (ParamName ==
"force-hardware-loop-phi") {
687 }
else if (ParamName ==
"force-nested-hardware-loop") {
689 }
else if (ParamName ==
"force-hardware-loop-guard") {
693 formatv(
"invalid HardwarePass parameter '{}'", ParamName).str(),
697 return HardwareLoopOpts;
709 while (!Params.
empty()) {
711 std::tie(ParamName, Params) = Params.
split(
';');
712 std::optional<OptimizationLevel> OptLevel =
parseOptLevel(ParamName);
714 if (OptLevel && !OptLevel->isOptimizingForSize()) {
715 UnrollOpts.
setOptLevel(OptLevel->getSpeedupLevel());
722 formatv(
"invalid LoopUnrollPass parameter '{}'", ParamName).str(),
729 if (ParamName ==
"partial") {
731 }
else if (ParamName ==
"peeling") {
733 }
else if (ParamName ==
"profile-peeling") {
735 }
else if (ParamName ==
"runtime") {
737 }
else if (ParamName ==
"upperbound") {
741 formatv(
"invalid LoopUnrollPass parameter '{}'", ParamName).str(),
750 Params,
"vfe-linkage-unit-visibility",
"GlobalDCE");
770 Params,
"skip-non-recursive-function-attrs",
"PostOrderFunctionAttrs");
780 formatv(
"too many CFGuardPass parameters '{}'", Params).str(),
783 if (Param ==
"check")
785 if (Param ==
"dispatch")
789 formatv(
"invalid CFGuardPass mechanism: '{}'", Param).str(),
799 "EntryExitInstrumenter");
808 "LowerMatrixIntrinsics");
813 while (!Params.
empty()) {
815 std::tie(ParamName, Params) = Params.
split(
';');
818 if (ParamName ==
"preserve-order")
820 else if (ParamName ==
"rename-all")
822 else if (ParamName ==
"fold-all")
824 else if (ParamName ==
"reorder-operands")
828 formatv(
"invalid normalize pass parameter '{}'", ParamName).str(),
838 while (!Params.
empty()) {
840 std::tie(ParamName, Params) = Params.
split(
';');
842 if (ParamName ==
"kernel") {
843 Result.CompileKernel =
true;
844 }
else if (ParamName ==
"use-after-scope") {
845 Result.UseAfterScope =
true;
848 formatv(
"invalid AddressSanitizer pass parameter '{}'", ParamName)
858 while (!Params.
empty()) {
860 std::tie(ParamName, Params) = Params.
split(
';');
862 if (ParamName ==
"recover") {
864 }
else if (ParamName ==
"kernel") {
865 Result.CompileKernel =
true;
868 formatv(
"invalid HWAddressSanitizer pass parameter '{}'", ParamName)
878 while (!Params.
empty()) {
880 std::tie(ParamName, Params) = Params.
split(
';');
882 if (ParamName ==
"thinlto") {
884 }
else if (ParamName ==
"emit-summary") {
885 Result.EmitLTOSummary =
true;
888 formatv(
"invalid EmbedBitcode pass parameter '{}'", ParamName).str(),
896parseLowerAllowCheckPassOptions(
StringRef Params) {
898 while (!Params.
empty()) {
900 std::tie(ParamName, Params) = Params.
split(
';');
911 std::tie(IndicesStr, CutoffStr) = ParamName.
split(
"]=");
918 formatv(
"invalid LowerAllowCheck pass cutoffs parameter '{}' ({})",
923 if (!IndicesStr.
consume_front(
"cutoffs[") || IndicesStr ==
"")
925 formatv(
"invalid LowerAllowCheck pass index parameter '{}' ({})",
926 IndicesStr, CutoffStr)
930 while (IndicesStr !=
"") {
932 std::tie(firstIndexStr, IndicesStr) = IndicesStr.
split(
'|');
938 "invalid LowerAllowCheck pass index parameter '{}' ({}) {}",
939 firstIndexStr, IndicesStr)
946 if (index >=
Result.cutoffs.size())
947 Result.cutoffs.resize(index + 1, 0);
949 Result.cutoffs[index] = cutoff;
951 }
else if (ParamName.
starts_with(
"runtime_check")) {
953 std::tie(std::ignore, ValueString) = ParamName.
split(
"=");
957 formatv(
"invalid LowerAllowCheck pass runtime_check parameter '{}' "
963 Result.runtime_check = runtime_check;
966 formatv(
"invalid LowerAllowCheck pass parameter '{}'", ParamName)
977 while (!Params.
empty()) {
979 std::tie(ParamName, Params) = Params.
split(
';');
981 if (ParamName ==
"recover") {
983 }
else if (ParamName ==
"kernel") {
988 formatv(
"invalid argument to MemorySanitizer pass track-origins "
993 }
else if (ParamName ==
"eager-checks") {
994 Result.EagerChecks =
true;
997 formatv(
"invalid MemorySanitizer pass parameter '{}'", ParamName)
1008 while (!Params.
empty()) {
1010 std::tie(ParamName, Params) = Params.
split(
';');
1013 if (ParamName ==
"speculate-blocks") {
1015 }
else if (ParamName ==
"simplify-cond-branch") {
1017 }
else if (ParamName ==
"forward-switch-cond") {
1019 }
else if (ParamName ==
"switch-range-to-icmp") {
1021 }
else if (ParamName ==
"switch-to-lookup") {
1023 }
else if (ParamName ==
"keep-loops") {
1025 }
else if (ParamName ==
"hoist-common-insts") {
1027 }
else if (ParamName ==
"hoist-loads-stores-with-cond-faulting") {
1029 }
else if (ParamName ==
"sink-common-insts") {
1031 }
else if (ParamName ==
"speculate-unpredictables") {
1034 APInt BonusInstThreshold;
1037 formatv(
"invalid argument to SimplifyCFG pass bonus-threshold "
1045 formatv(
"invalid SimplifyCFG pass parameter '{}'", ParamName).str(),
1056 Result.setVerifyFixpoint(
true);
1057 while (!Params.
empty()) {
1059 std::tie(ParamName, Params) = Params.
split(
';');
1062 if (ParamName ==
"verify-fixpoint") {
1065 APInt MaxIterations;
1068 formatv(
"invalid argument to InstCombine pass max-iterations "
1076 formatv(
"invalid InstCombine pass parameter '{}'", ParamName).str(),
1086 while (!Params.
empty()) {
1088 std::tie(ParamName, Params) = Params.
split(
';');
1091 if (ParamName ==
"interleave-forced-only") {
1093 }
else if (ParamName ==
"vectorize-forced-only") {
1097 formatv(
"invalid LoopVectorize parameter '{}'", ParamName).str(),
1105 std::pair<bool, bool>
Result = {
false,
true};
1106 while (!Params.
empty()) {
1108 std::tie(ParamName, Params) = Params.
split(
';');
1111 if (ParamName ==
"nontrivial") {
1113 }
else if (ParamName ==
"trivial") {
1117 formatv(
"invalid LoopUnswitch pass parameter '{}'", ParamName).str(),
1126 while (!Params.
empty()) {
1128 std::tie(ParamName, Params) = Params.
split(
';');
1131 if (ParamName ==
"allowspeculation") {
1135 formatv(
"invalid LICM pass parameter '{}'", ParamName).str(),
1143 std::pair<bool, bool>
Result = {
true,
false};
1144 while (!Params.
empty()) {
1146 std::tie(ParamName, Params) = Params.
split(
';');
1149 if (ParamName ==
"header-duplication") {
1151 }
else if (ParamName ==
"prepare-for-lto") {
1155 formatv(
"invalid LoopRotate pass parameter '{}'", ParamName).str(),
1164 while (!Params.
empty()) {
1166 std::tie(ParamName, Params) = Params.
split(
';');
1169 if (ParamName ==
"split-footer-bb") {
1173 formatv(
"invalid MergedLoadStoreMotion pass parameter '{}'",
1184 while (!Params.
empty()) {
1186 std::tie(ParamName, Params) = Params.
split(
';');
1189 if (ParamName ==
"pre") {
1191 }
else if (ParamName ==
"load-pre") {
1193 }
else if (ParamName ==
"split-backedge-load-pre") {
1195 }
else if (ParamName ==
"memdep") {
1199 }
else if (ParamName ==
"memoryssa") {
1205 formatv(
"invalid GVN pass parameter '{}'", ParamName).str(),
1214 while (!Params.
empty()) {
1216 std::tie(ParamName, Params) = Params.
split(
';');
1219 if (ParamName ==
"func-spec")
1223 formatv(
"invalid IPSCCP pass parameter '{}'", ParamName).str(),
1231 while (!Params.
empty()) {
1233 std::tie(ParamName, Params) = Params.
split(
';');
1238 formatv(
"invalid argument to Scalarizer pass min-bits "
1249 if (ParamName ==
"load-store")
1251 else if (ParamName ==
"variable-insert-extract")
1255 formatv(
"invalid Scalarizer pass parameter '{}'", ParamName).str(),
1264 if (Params.
empty() || Params ==
"modify-cfg")
1266 if (Params ==
"preserve-cfg")
1269 formatv(
"invalid SROA pass parameter '{}' (either preserve-cfg or "
1270 "modify-cfg can be specified)",
1277parseStackLifetimeOptions(
StringRef Params) {
1279 while (!Params.
empty()) {
1281 std::tie(ParamName, Params) = Params.
split(
';');
1283 if (ParamName ==
"may") {
1285 }
else if (ParamName ==
"must") {
1289 formatv(
"invalid StackLifetime parameter '{}'", ParamName).str(),
1298 "DependenceAnalysisPrinter");
1303 "SeparateConstOffsetFromGEP");
1312parseFunctionSimplificationPipelineOptions(
StringRef Params) {
1316 formatv(
"invalid function-simplification parameter '{}'", Params).str(),
1324 "MemorySSAPrinterPass");
1329 "SpeculativeExecutionPass");
1334 while (!Params.
empty()) {
1336 std::tie(ParamName, Params) = Params.
split(
';');
1342 formatv(
"invalid MemProfUse pass parameter '{}'", ParamName).str(),
1350parseStructuralHashPrinterPassOptions(
StringRef Params) {
1353 if (Params ==
"detailed")
1355 if (Params ==
"call-target-ignored")
1358 formatv(
"invalid structural hash printer parameter '{}'", Params).str(),
1364 "WinEHPreparePass");
1369 while (!Params.
empty()) {
1371 std::tie(ParamName, Params) = Params.
split(
';');
1374 if (ParamName ==
"group-by-use")
1376 else if (ParamName ==
"ignore-single-use")
1378 else if (ParamName ==
"merge-const")
1380 else if (ParamName ==
"merge-const-aggressive")
1382 else if (ParamName ==
"merge-external")
1387 formatv(
"invalid GlobalMergePass parameter '{}'", ParamName).str(),
1391 formatv(
"invalid global-merge pass parameter '{}'", Params).str(),
1400 while (!Params.
empty()) {
1402 std::tie(ParamName, Params) = Params.
split(
';');
1408 formatv(
"invalid Internalize pass parameter '{}'", ParamName).str(),
1419 while (!Params.
empty()) {
1421 std::tie(ParamName, Params) = Params.
split(
';');
1424 std::optional<RegAllocFilterFunc>
Filter =
1428 formatv(
"invalid regallocfast register filter '{}'", ParamName)
1437 if (ParamName ==
"no-clear-vregs") {
1443 formatv(
"invalid regallocfast pass parameter '{}'", ParamName).str(),
1450parseBoundsCheckingOptions(
StringRef Params) {
1452 while (!Params.
empty()) {
1454 std::tie(ParamName, Params) = Params.
split(
';');
1455 if (ParamName ==
"trap") {
1457 }
else if (ParamName ==
"rt") {
1462 }
else if (ParamName ==
"rt-abort") {
1467 }
else if (ParamName ==
"min-rt") {
1472 }
else if (ParamName ==
"min-rt-abort") {
1477 }
else if (ParamName ==
"merge") {
1482 std::tie(ParamEQ, Val) = ParamName.
split(
'=');
1488 formatv(
"invalid BoundsChecking pass parameter '{}'", ParamName)
1505 if (!
Prefix.empty() || Digit.getAsInteger(10,
N))
1507 Param.str().c_str());
1510 if (!
Level.has_value())
1512 "invalid optimization level for expand-fp pass: %s",
1513 Digit.str().c_str());
1520 if (Params.
empty() || Params ==
"all")
1521 return RAGreedyPass::Options();
1525 return RAGreedyPass::Options{*
Filter, Params};
1528 formatv(
"invalid regallocgreedy register filter '{}'", Params).str(),
1534 "MachineSinkingPass");
1538 bool AllowTailMerge =
true;
1539 if (!Params.
empty()) {
1541 if (Params !=
"tail-merge")
1543 formatv(
"invalid MachineBlockPlacementPass parameter '{}'", Params)
1547 return AllowTailMerge;
1551 bool ClearVirtRegs =
true;
1552 if (!Params.
empty()) {
1554 if (Params !=
"clear-vregs")
1556 formatv(
"invalid VirtRegRewriter pass parameter '{}'", Params).str(),
1559 return ClearVirtRegs;
1562struct FatLTOOptions {
1563 OptimizationLevel OptLevel;
1564 bool ThinLTO =
false;
1565 bool EmitSummary =
false;
1570 bool HaveOptLevel =
false;
1571 while (!Params.
empty()) {
1573 std::tie(ParamName, Params) = Params.
split(
';');
1575 if (ParamName ==
"thinlto") {
1577 }
else if (ParamName ==
"emit-summary") {
1578 Result.EmitSummary =
true;
1579 }
else if (std::optional<OptimizationLevel> OptLevel =
1581 Result.OptLevel = *OptLevel;
1582 HaveOptLevel =
true;
1585 formatv(
"invalid fatlto-pre-link pass parameter '{}'", ParamName)
1592 "missing optimization level for fatlto-pre-link pipeline",
1607template <
typename PassManagerT,
typename CallbacksT>
1609 if (!Callbacks.empty()) {
1610 PassManagerT DummyPM;
1611 for (
auto &CB : Callbacks)
1612 if (CB(Name, DummyPM, {}))
1618template <
typename CallbacksT>
1620 StringRef NameNoBracket = Name.take_until([](
char C) {
return C ==
'<'; });
1623 if (Name ==
"module")
1625 if (Name ==
"cgscc")
1627 if (NameNoBracket ==
"function")
1629 if (Name ==
"coro-cond")
1632#define MODULE_PASS(NAME, CREATE_PASS) \
1635#define MODULE_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1636 if (PassBuilder::checkParametrizedPassName(Name, NAME)) \
1638#define MODULE_ANALYSIS(NAME, CREATE_PASS) \
1639 if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
1641#include "PassRegistry.def"
1646template <
typename CallbacksT>
1649 StringRef NameNoBracket = Name.take_until([](
char C) {
return C ==
'<'; });
1650 if (Name ==
"cgscc")
1652 if (NameNoBracket ==
"function")
1659#define CGSCC_PASS(NAME, CREATE_PASS) \
1662#define CGSCC_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1663 if (PassBuilder::checkParametrizedPassName(Name, NAME)) \
1665#define CGSCC_ANALYSIS(NAME, CREATE_PASS) \
1666 if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
1668#include "PassRegistry.def"
1673template <
typename CallbacksT>
1676 StringRef NameNoBracket = Name.take_until([](
char C) {
return C ==
'<'; });
1677 if (NameNoBracket ==
"function")
1679 if (Name ==
"loop" || Name ==
"loop-mssa" || Name ==
"machine-function")
1682#define FUNCTION_PASS(NAME, CREATE_PASS) \
1685#define FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1686 if (PassBuilder::checkParametrizedPassName(Name, NAME)) \
1688#define FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
1689 if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
1691#include "PassRegistry.def"
1696template <
typename CallbacksT>
1699 if (Name ==
"machine-function")
1702#define MACHINE_FUNCTION_PASS(NAME, CREATE_PASS) \
1705#define MACHINE_FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, \
1707 if (PassBuilder::checkParametrizedPassName(Name, NAME)) \
1710#define MACHINE_FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
1711 if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
1714#include "llvm/Passes/MachinePassRegistry.def"
1719template <
typename CallbacksT>
1721 bool &UseMemorySSA) {
1722 UseMemorySSA =
false;
1725 UseMemorySSA =
true;
1729#define LOOPNEST_PASS(NAME, CREATE_PASS) \
1732#include "PassRegistry.def"
1737template <
typename CallbacksT>
1739 bool &UseMemorySSA) {
1740 UseMemorySSA =
false;
1743 UseMemorySSA =
true;
1747#define LOOP_PASS(NAME, CREATE_PASS) \
1750#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1751 if (PassBuilder::checkParametrizedPassName(Name, NAME)) \
1753#define LOOP_ANALYSIS(NAME, CREATE_PASS) \
1754 if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
1756#include "PassRegistry.def"
1761std::optional<std::vector<PassBuilder::PipelineElement>>
1762PassBuilder::parsePipelineText(
StringRef Text) {
1763 std::vector<PipelineElement> ResultPipeline;
1768 std::vector<PipelineElement> &Pipeline = *PipelineStack.
back();
1769 size_t Pos =
Text.find_first_of(
",()");
1770 Pipeline.push_back({
Text.substr(0, Pos), {}});
1773 if (Pos ==
Text.npos)
1776 char Sep =
Text[Pos];
1784 PipelineStack.
push_back(&Pipeline.back().InnerPipeline);
1788 assert(Sep ==
')' &&
"Bogus separator!");
1793 if (PipelineStack.
size() == 1)
1794 return std::nullopt;
1797 }
while (
Text.consume_front(
")"));
1805 if (!
Text.consume_front(
","))
1806 return std::nullopt;
1809 if (PipelineStack.
size() > 1)
1811 return std::nullopt;
1813 assert(PipelineStack.
back() == &ResultPipeline &&
1814 "Wrong pipeline at the bottom of the stack!");
1815 return {std::move(ResultPipeline)};
1828 const PipelineElement &
E) {
1829 auto &
Name =
E.Name;
1830 auto &InnerPipeline =
E.InnerPipeline;
1833 if (!InnerPipeline.empty()) {
1834 if (Name ==
"module") {
1836 if (
auto Err = parseModulePassPipeline(NestedMPM, InnerPipeline))
1838 MPM.
addPass(std::move(NestedMPM));
1841 if (Name ==
"coro-cond") {
1843 if (
auto Err = parseModulePassPipeline(NestedMPM, InnerPipeline))
1845 MPM.
addPass(CoroConditionalWrapper(std::move(NestedMPM)));
1848 if (Name ==
"cgscc") {
1850 if (
auto Err = parseCGSCCPassPipeline(CGPM, InnerPipeline))
1858 "cannot have a no-rerun module to function adaptor",
1861 if (
auto Err = parseFunctionPassPipeline(FPM, InnerPipeline))
1868 for (
auto &
C : ModulePipelineParsingCallbacks)
1869 if (
C(Name, MPM, InnerPipeline))
1874 formatv(
"invalid use of '{}' pass as module pipeline", Name).str(),
1880#define MODULE_PASS(NAME, CREATE_PASS) \
1881 if (Name == NAME) { \
1882 MPM.addPass(CREATE_PASS); \
1883 return Error::success(); \
1885#define MODULE_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1886 if (checkParametrizedPassName(Name, NAME)) { \
1887 auto Params = parsePassParameters(PARSER, Name, NAME); \
1889 return Params.takeError(); \
1890 MPM.addPass(CREATE_PASS(Params.get())); \
1891 return Error::success(); \
1893#define MODULE_ANALYSIS(NAME, CREATE_PASS) \
1894 if (Name == "require<" NAME ">") { \
1896 RequireAnalysisPass< \
1897 std::remove_reference_t<decltype(CREATE_PASS)>, Module>()); \
1898 return Error::success(); \
1900 if (Name == "invalidate<" NAME ">") { \
1901 MPM.addPass(InvalidateAnalysisPass< \
1902 std::remove_reference_t<decltype(CREATE_PASS)>>()); \
1903 return Error::success(); \
1905#define CGSCC_PASS(NAME, CREATE_PASS) \
1906 if (Name == NAME) { \
1907 MPM.addPass(createModuleToPostOrderCGSCCPassAdaptor(CREATE_PASS)); \
1908 return Error::success(); \
1910#define CGSCC_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1911 if (checkParametrizedPassName(Name, NAME)) { \
1912 auto Params = parsePassParameters(PARSER, Name, NAME); \
1914 return Params.takeError(); \
1916 createModuleToPostOrderCGSCCPassAdaptor(CREATE_PASS(Params.get()))); \
1917 return Error::success(); \
1919#define FUNCTION_PASS(NAME, CREATE_PASS) \
1920 if (Name == NAME) { \
1921 MPM.addPass(createModuleToFunctionPassAdaptor(CREATE_PASS)); \
1922 return Error::success(); \
1924#define FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1925 if (checkParametrizedPassName(Name, NAME)) { \
1926 auto Params = parsePassParameters(PARSER, Name, NAME); \
1928 return Params.takeError(); \
1929 MPM.addPass(createModuleToFunctionPassAdaptor(CREATE_PASS(Params.get()))); \
1930 return Error::success(); \
1932#define LOOPNEST_PASS(NAME, CREATE_PASS) \
1933 if (Name == NAME) { \
1934 MPM.addPass(createModuleToFunctionPassAdaptor( \
1935 createFunctionToLoopPassAdaptor(CREATE_PASS, false, false))); \
1936 return Error::success(); \
1938#define LOOP_PASS(NAME, CREATE_PASS) \
1939 if (Name == NAME) { \
1940 MPM.addPass(createModuleToFunctionPassAdaptor( \
1941 createFunctionToLoopPassAdaptor(CREATE_PASS, false, false))); \
1942 return Error::success(); \
1944#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1945 if (checkParametrizedPassName(Name, NAME)) { \
1946 auto Params = parsePassParameters(PARSER, Name, NAME); \
1948 return Params.takeError(); \
1950 createModuleToFunctionPassAdaptor(createFunctionToLoopPassAdaptor( \
1951 CREATE_PASS(Params.get()), false, false))); \
1952 return Error::success(); \
1954#include "PassRegistry.def"
1956 for (
auto &
C : ModulePipelineParsingCallbacks)
1957 if (
C(Name, MPM, InnerPipeline))
1960 formatv(
"unknown module pass '{}'", Name).str(),
1965 const PipelineElement &
E) {
1966 auto &
Name =
E.Name;
1967 auto &InnerPipeline =
E.InnerPipeline;
1970 if (!InnerPipeline.empty()) {
1971 if (Name ==
"cgscc") {
1973 if (
auto Err = parseCGSCCPassPipeline(NestedCGPM, InnerPipeline))
1976 CGPM.
addPass(std::move(NestedCGPM));
1981 if (
auto Err = parseFunctionPassPipeline(FPM, InnerPipeline))
1985 std::move(FPM), Params->first, Params->second));
1990 if (
auto Err = parseCGSCCPassPipeline(NestedCGPM, InnerPipeline))
1997 for (
auto &
C : CGSCCPipelineParsingCallbacks)
1998 if (
C(Name, CGPM, InnerPipeline))
2003 formatv(
"invalid use of '{}' pass as cgscc pipeline", Name).str(),
2008#define CGSCC_PASS(NAME, CREATE_PASS) \
2009 if (Name == NAME) { \
2010 CGPM.addPass(CREATE_PASS); \
2011 return Error::success(); \
2013#define CGSCC_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
2014 if (checkParametrizedPassName(Name, NAME)) { \
2015 auto Params = parsePassParameters(PARSER, Name, NAME); \
2017 return Params.takeError(); \
2018 CGPM.addPass(CREATE_PASS(Params.get())); \
2019 return Error::success(); \
2021#define CGSCC_ANALYSIS(NAME, CREATE_PASS) \
2022 if (Name == "require<" NAME ">") { \
2023 CGPM.addPass(RequireAnalysisPass< \
2024 std::remove_reference_t<decltype(CREATE_PASS)>, \
2025 LazyCallGraph::SCC, CGSCCAnalysisManager, LazyCallGraph &, \
2026 CGSCCUpdateResult &>()); \
2027 return Error::success(); \
2029 if (Name == "invalidate<" NAME ">") { \
2030 CGPM.addPass(InvalidateAnalysisPass< \
2031 std::remove_reference_t<decltype(CREATE_PASS)>>()); \
2032 return Error::success(); \
2034#define FUNCTION_PASS(NAME, CREATE_PASS) \
2035 if (Name == NAME) { \
2036 CGPM.addPass(createCGSCCToFunctionPassAdaptor(CREATE_PASS)); \
2037 return Error::success(); \
2039#define FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
2040 if (checkParametrizedPassName(Name, NAME)) { \
2041 auto Params = parsePassParameters(PARSER, Name, NAME); \
2043 return Params.takeError(); \
2044 CGPM.addPass(createCGSCCToFunctionPassAdaptor(CREATE_PASS(Params.get()))); \
2045 return Error::success(); \
2047#define LOOPNEST_PASS(NAME, CREATE_PASS) \
2048 if (Name == NAME) { \
2049 CGPM.addPass(createCGSCCToFunctionPassAdaptor( \
2050 createFunctionToLoopPassAdaptor(CREATE_PASS, false, false))); \
2051 return Error::success(); \
2053#define LOOP_PASS(NAME, CREATE_PASS) \
2054 if (Name == NAME) { \
2055 CGPM.addPass(createCGSCCToFunctionPassAdaptor( \
2056 createFunctionToLoopPassAdaptor(CREATE_PASS, false, false))); \
2057 return Error::success(); \
2059#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
2060 if (checkParametrizedPassName(Name, NAME)) { \
2061 auto Params = parsePassParameters(PARSER, Name, NAME); \
2063 return Params.takeError(); \
2065 createCGSCCToFunctionPassAdaptor(createFunctionToLoopPassAdaptor( \
2066 CREATE_PASS(Params.get()), false, false))); \
2067 return Error::success(); \
2069#include "PassRegistry.def"
2071 for (
auto &
C : CGSCCPipelineParsingCallbacks)
2072 if (
C(Name, CGPM, InnerPipeline))
2079 const PipelineElement &
E) {
2080 auto &
Name =
E.Name;
2081 auto &InnerPipeline =
E.InnerPipeline;
2084 if (!InnerPipeline.empty()) {
2085 if (Name ==
"function") {
2087 if (
auto Err = parseFunctionPassPipeline(NestedFPM, InnerPipeline))
2090 FPM.
addPass(std::move(NestedFPM));
2093 if (Name ==
"loop" || Name ==
"loop-mssa") {
2095 if (
auto Err = parseLoopPassPipeline(LPM, InnerPipeline))
2098 bool UseMemorySSA = (
Name ==
"loop-mssa");
2100 return Pipeline.Name.contains(
"simple-loop-unswitch");
2106 if (Name ==
"machine-function") {
2108 if (
auto Err = parseMachinePassPipeline(MFPM, InnerPipeline))
2114 for (
auto &
C : FunctionPipelineParsingCallbacks)
2115 if (
C(Name, FPM, InnerPipeline))
2120 formatv(
"invalid use of '{}' pass as function pipeline", Name).str(),
2125#define FUNCTION_PASS(NAME, CREATE_PASS) \
2126 if (Name == NAME) { \
2127 FPM.addPass(CREATE_PASS); \
2128 return Error::success(); \
2130#define FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
2131 if (checkParametrizedPassName(Name, NAME)) { \
2132 auto Params = parsePassParameters(PARSER, Name, NAME); \
2134 return Params.takeError(); \
2135 FPM.addPass(CREATE_PASS(Params.get())); \
2136 return Error::success(); \
2138#define FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
2139 if (Name == "require<" NAME ">") { \
2141 RequireAnalysisPass< \
2142 std::remove_reference_t<decltype(CREATE_PASS)>, Function>()); \
2143 return Error::success(); \
2145 if (Name == "invalidate<" NAME ">") { \
2146 FPM.addPass(InvalidateAnalysisPass< \
2147 std::remove_reference_t<decltype(CREATE_PASS)>>()); \
2148 return Error::success(); \
2154#define LOOPNEST_PASS(NAME, CREATE_PASS) \
2155 if (Name == NAME) { \
2156 FPM.addPass(createFunctionToLoopPassAdaptor(CREATE_PASS, false, false)); \
2157 return Error::success(); \
2159#define LOOP_PASS(NAME, CREATE_PASS) \
2160 if (Name == NAME) { \
2161 FPM.addPass(createFunctionToLoopPassAdaptor(CREATE_PASS, false, false)); \
2162 return Error::success(); \
2164#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
2165 if (checkParametrizedPassName(Name, NAME)) { \
2166 auto Params = parsePassParameters(PARSER, Name, NAME); \
2168 return Params.takeError(); \
2169 FPM.addPass(createFunctionToLoopPassAdaptor(CREATE_PASS(Params.get()), \
2171 return Error::success(); \
2173#include "PassRegistry.def"
2175 for (
auto &
C : FunctionPipelineParsingCallbacks)
2176 if (
C(Name, FPM, InnerPipeline))
2179 formatv(
"unknown function pass '{}'", Name).str(),
2184 const PipelineElement &
E) {
2185 StringRef
Name =
E.Name;
2186 auto &InnerPipeline =
E.InnerPipeline;
2189 if (!InnerPipeline.empty()) {
2190 if (Name ==
"loop") {
2192 if (
auto Err = parseLoopPassPipeline(NestedLPM, InnerPipeline))
2195 LPM.addPass(std::move(NestedLPM));
2199 for (
auto &
C : LoopPipelineParsingCallbacks)
2200 if (
C(Name, LPM, InnerPipeline))
2205 formatv(
"invalid use of '{}' pass as loop pipeline", Name).str(),
2210#define LOOPNEST_PASS(NAME, CREATE_PASS) \
2211 if (Name == NAME) { \
2212 LPM.addPass(CREATE_PASS); \
2213 return Error::success(); \
2215#define LOOP_PASS(NAME, CREATE_PASS) \
2216 if (Name == NAME) { \
2217 LPM.addPass(CREATE_PASS); \
2218 return Error::success(); \
2220#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
2221 if (checkParametrizedPassName(Name, NAME)) { \
2222 auto Params = parsePassParameters(PARSER, Name, NAME); \
2224 return Params.takeError(); \
2225 LPM.addPass(CREATE_PASS(Params.get())); \
2226 return Error::success(); \
2228#define LOOP_ANALYSIS(NAME, CREATE_PASS) \
2229 if (Name == "require<" NAME ">") { \
2230 LPM.addPass(RequireAnalysisPass< \
2231 std::remove_reference_t<decltype(CREATE_PASS)>, Loop, \
2232 LoopAnalysisManager, LoopStandardAnalysisResults &, \
2234 return Error::success(); \
2236 if (Name == "invalidate<" NAME ">") { \
2237 LPM.addPass(InvalidateAnalysisPass< \
2238 std::remove_reference_t<decltype(CREATE_PASS)>>()); \
2239 return Error::success(); \
2241#include "PassRegistry.def"
2243 for (
auto &
C : LoopPipelineParsingCallbacks)
2244 if (
C(Name, LPM, InnerPipeline))
2251 const PipelineElement &
E) {
2252 StringRef
Name =
E.Name;
2254 if (!
E.InnerPipeline.empty()) {
2255 if (
E.Name ==
"machine-function") {
2257 if (
auto Err = parseMachinePassPipeline(NestedPM,
E.InnerPipeline))
2259 MFPM.
addPass(std::move(NestedPM));
2266#define MACHINE_MODULE_PASS(NAME, CREATE_PASS) \
2267 if (Name == NAME) { \
2268 MFPM.addPass(CREATE_PASS); \
2269 return Error::success(); \
2271#define MACHINE_FUNCTION_PASS(NAME, CREATE_PASS) \
2272 if (Name == NAME) { \
2273 MFPM.addPass(CREATE_PASS); \
2274 return Error::success(); \
2276#define MACHINE_FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, \
2278 if (checkParametrizedPassName(Name, NAME)) { \
2279 auto Params = parsePassParameters(PARSER, Name, NAME); \
2281 return Params.takeError(); \
2282 MFPM.addPass(CREATE_PASS(Params.get())); \
2283 return Error::success(); \
2285#define MACHINE_FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
2286 if (Name == "require<" NAME ">") { \
2288 RequireAnalysisPass<std::remove_reference_t<decltype(CREATE_PASS)>, \
2289 MachineFunction>()); \
2290 return Error::success(); \
2292 if (Name == "invalidate<" NAME ">") { \
2293 MFPM.addPass(InvalidateAnalysisPass< \
2294 std::remove_reference_t<decltype(CREATE_PASS)>>()); \
2295 return Error::success(); \
2297#include "llvm/Passes/MachinePassRegistry.def"
2299 for (
auto &
C : MachineFunctionPipelineParsingCallbacks)
2300 if (
C(Name, MFPM,
E.InnerPipeline))
2303 formatv(
"unknown machine pass '{}'", Name).str(),
2308#define MODULE_ALIAS_ANALYSIS(NAME, CREATE_PASS) \
2309 if (Name == NAME) { \
2310 AA.registerModuleAnalysis< \
2311 std::remove_reference_t<decltype(CREATE_PASS)>>(); \
2314#define FUNCTION_ALIAS_ANALYSIS(NAME, CREATE_PASS) \
2315 if (Name == NAME) { \
2316 AA.registerFunctionAnalysis< \
2317 std::remove_reference_t<decltype(CREATE_PASS)>>(); \
2320#include "PassRegistry.def"
2322 for (
auto &
C : AAParsingCallbacks)
2328Error PassBuilder::parseMachinePassPipeline(
2330 for (
const auto &Element : Pipeline) {
2331 if (
auto Err = parseMachinePass(MFPM, Element))
2339 for (
const auto &Element : Pipeline) {
2340 if (
auto Err = parseLoopPass(LPM, Element))
2346Error PassBuilder::parseFunctionPassPipeline(
2348 for (
const auto &Element : Pipeline) {
2349 if (
auto Err = parseFunctionPass(FPM, Element))
2357 for (
const auto &Element : Pipeline) {
2358 if (
auto Err = parseCGSCCPass(CGPM, Element))
2390 for (
const auto &Element : Pipeline) {
2391 if (
auto Err = parseModulePass(MPM, Element))
2402 auto Pipeline = parsePipelineText(PipelineText);
2403 if (!Pipeline || Pipeline->empty())
2405 formatv(
"invalid pipeline '{}'", PipelineText).str(),
2415 Pipeline = {{
"cgscc", std::move(*Pipeline)}};
2417 FunctionPipelineParsingCallbacks)) {
2418 Pipeline = {{
"function", std::move(*Pipeline)}};
2421 Pipeline = {{
"function", {{UseMemorySSA ?
"loop-mssa" :
"loop",
2422 std::move(*Pipeline)}}}};
2423 }
else if (
isLoopPassName(FirstName, LoopPipelineParsingCallbacks,
2425 Pipeline = {{
"function", {{UseMemorySSA ?
"loop-mssa" :
"loop",
2426 std::move(*Pipeline)}}}};
2428 FirstName, MachineFunctionPipelineParsingCallbacks)) {
2429 Pipeline = {{
"function", {{
"machine-function", std::move(*Pipeline)}}}};
2431 for (
auto &
C : TopLevelPipelineParsingCallbacks)
2432 if (
C(MPM, *Pipeline))
2436 auto &InnerPipeline = Pipeline->front().InnerPipeline;
2438 formatv(
"unknown {} name '{}'",
2439 (InnerPipeline.empty() ?
"pass" :
"pipeline"), FirstName)
2445 if (
auto Err = parseModulePassPipeline(MPM, *Pipeline))
2453 auto Pipeline = parsePipelineText(PipelineText);
2454 if (!Pipeline || Pipeline->empty())
2456 formatv(
"invalid pipeline '{}'", PipelineText).str(),
2462 formatv(
"unknown cgscc pass '{}' in pipeline '{}'", FirstName,
2467 if (
auto Err = parseCGSCCPassPipeline(CGPM, *Pipeline))
2476 auto Pipeline = parsePipelineText(PipelineText);
2477 if (!Pipeline || Pipeline->empty())
2479 formatv(
"invalid pipeline '{}'", PipelineText).str(),
2485 formatv(
"unknown function pass '{}' in pipeline '{}'", FirstName,
2490 if (
auto Err = parseFunctionPassPipeline(FPM, *Pipeline))
2498 auto Pipeline = parsePipelineText(PipelineText);
2499 if (!Pipeline || Pipeline->empty())
2501 formatv(
"invalid pipeline '{}'", PipelineText).str(),
2504 if (
auto Err = parseLoopPassPipeline(CGPM, *Pipeline))
2512 auto Pipeline = parsePipelineText(PipelineText);
2513 if (!Pipeline || Pipeline->empty())
2515 formatv(
"invalid machine pass pipeline '{}'", PipelineText).str(),
2518 if (
auto Err = parseMachinePassPipeline(MFPM, *Pipeline))
2527 if (PipelineText ==
"default") {
2532 while (!PipelineText.
empty()) {
2534 std::tie(Name, PipelineText) = PipelineText.
split(
',');
2535 if (!parseAAPassName(
AA, Name))
2537 formatv(
"unknown alias analysis name '{}'", Name).str(),
2544std::optional<RegAllocFilterFunc>
2546 if (FilterName ==
"all")
2548 for (
auto &
C : RegClassFilterParsingCallbacks)
2549 if (
auto F =
C(FilterName))
2551 return std::nullopt;
2559 OS <<
" " <<
PassName <<
"<" << Params <<
">\n";
2565 OS <<
"Module passes:\n";
2566#define MODULE_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2567#include "PassRegistry.def"
2569 OS <<
"Module passes with params:\n";
2570#define MODULE_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
2571 printPassName(NAME, PARAMS, OS);
2572#include "PassRegistry.def"
2574 OS <<
"Module analyses:\n";
2575#define MODULE_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2576#include "PassRegistry.def"
2578 OS <<
"Module alias analyses:\n";
2579#define MODULE_ALIAS_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2580#include "PassRegistry.def"
2582 OS <<
"CGSCC passes:\n";
2583#define CGSCC_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2584#include "PassRegistry.def"
2586 OS <<
"CGSCC passes with params:\n";
2587#define CGSCC_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
2588 printPassName(NAME, PARAMS, OS);
2589#include "PassRegistry.def"
2591 OS <<
"CGSCC analyses:\n";
2592#define CGSCC_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2593#include "PassRegistry.def"
2595 OS <<
"Function passes:\n";
2596#define FUNCTION_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2597#include "PassRegistry.def"
2599 OS <<
"Function passes with params:\n";
2600#define FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
2601 printPassName(NAME, PARAMS, OS);
2602#include "PassRegistry.def"
2604 OS <<
"Function analyses:\n";
2605#define FUNCTION_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2606#include "PassRegistry.def"
2608 OS <<
"Function alias analyses:\n";
2609#define FUNCTION_ALIAS_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2610#include "PassRegistry.def"
2612 OS <<
"LoopNest passes:\n";
2613#define LOOPNEST_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2614#include "PassRegistry.def"
2616 OS <<
"Loop passes:\n";
2617#define LOOP_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2618#include "PassRegistry.def"
2620 OS <<
"Loop passes with params:\n";
2621#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
2622 printPassName(NAME, PARAMS, OS);
2623#include "PassRegistry.def"
2625 OS <<
"Loop analyses:\n";
2626#define LOOP_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2627#include "PassRegistry.def"
2629 OS <<
"Machine module passes (WIP):\n";
2630#define MACHINE_MODULE_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2631#include "llvm/Passes/MachinePassRegistry.def"
2633 OS <<
"Machine function passes (WIP):\n";
2634#define MACHINE_FUNCTION_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2635#include "llvm/Passes/MachinePassRegistry.def"
2637 OS <<
"Machine function analyses (WIP):\n";
2638#define MACHINE_FUNCTION_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2639#include "llvm/Passes/MachinePassRegistry.def"
2645 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)
FunctionToLoopPassAdaptor createFunctionToLoopPassAdaptor(LoopPassT &&Pass, bool UseMemorySSA=false, bool UseBlockFrequencyInfo=false)
A function to deduce a loop pass type and wrap it in the templated adaptor.
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.
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