390 "print-pipeline-passes",
391 cl::desc(
"Print a '-passes' compatible string describing the pipeline "
392 "(best-effort only)."));
403class TriggerCrashModulePass :
public PassInfoMixin<TriggerCrashModulePass> {
409 static StringRef
name() {
return "TriggerCrashModulePass"; }
412class TriggerCrashFunctionPass
419 static StringRef
name() {
return "TriggerCrashFunctionPass"; }
424class TriggerVerifierErrorPass
430 auto *PtrTy = PointerType::getUnqual(
M.getContext());
432 GlobalValue::LinkageTypes::InternalLinkage,
433 "__bad_alias",
nullptr, &M);
453 static StringRef
name() {
return "TriggerVerifierErrorPass"; }
458class RequireAllMachineFunctionPropertiesPass
459 :
public PassInfoMixin<RequireAllMachineFunctionPropertiesPass> {
466 static MachineFunctionProperties getRequiredProperties() {
467 return MachineFunctionProperties()
469 .setFailsVerification()
474 .setRegBankSelected()
476 .setTiedOpsRewritten()
477 .setTracksDebugUserValues()
478 .setTracksLiveness();
480 static StringRef
name() {
return "RequireAllMachineFunctionPropertiesPass"; }
497 std::optional<OptimizationLevel> OptLevel =
parseOptLevel(S);
501 formatv(
"invalid optimization level '{}'", S).str(),
506 std::optional<PGOOptions> PGOOpt,
509 : TM(TM), PTO(PTO), PGOOpt(PGOOpt), PIC(PIC), FS(
std::
move(FS)) {
511 TM->registerPassBuilderCallbacks(*
this);
513 PIC->registerClassToPassNameCallback([
this, PIC]() {
517#define MODULE_PASS(NAME, CREATE_PASS) \
518 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
519#define MODULE_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
520 PIC->addClassToPassName(CLASS, NAME);
521#define MODULE_ANALYSIS(NAME, CREATE_PASS) \
522 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
523#define FUNCTION_PASS(NAME, CREATE_PASS) \
524 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
525#define FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
526 PIC->addClassToPassName(CLASS, NAME);
527#define FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
528 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
529#define LOOPNEST_PASS(NAME, CREATE_PASS) \
530 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
531#define LOOP_PASS(NAME, CREATE_PASS) \
532 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
533#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
534 PIC->addClassToPassName(CLASS, NAME);
535#define LOOP_ANALYSIS(NAME, CREATE_PASS) \
536 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
537#define CGSCC_PASS(NAME, CREATE_PASS) \
538 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
539#define CGSCC_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
540 PIC->addClassToPassName(CLASS, NAME);
541#define CGSCC_ANALYSIS(NAME, CREATE_PASS) \
542 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
543#include "PassRegistry.def"
545#define MACHINE_FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
546 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
547#define MACHINE_FUNCTION_PASS(NAME, CREATE_PASS) \
548 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
549#define MACHINE_FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, \
551 PIC->addClassToPassName(CLASS, NAME);
552#include "llvm/Passes/MachinePassRegistry.def"
560#define MODULE_CALLBACK(NAME, INVOKE) \
561 if (PassBuilder::checkParametrizedPassName(Name, NAME)) { \
562 auto L = PassBuilder::parsePassParameters(parseOptLevelParam, Name, NAME); \
564 errs() << NAME ": " << toString(L.takeError()) << '\n'; \
567 INVOKE(PM, L.get()); \
570#include "PassRegistry.def"
578#define MODULE_LTO_CALLBACK(NAME, INVOKE) \
579 if (PassBuilder::checkParametrizedPassName(Name, NAME)) { \
580 auto L = PassBuilder::parsePassParameters(parseOptLevelParam, Name, NAME); \
582 errs() << NAME ": " << toString(L.takeError()) << '\n'; \
585 INVOKE(PM, L.get(), ThinOrFullLTOPhase::None); \
588#include "PassRegistry.def"
596#define FUNCTION_CALLBACK(NAME, INVOKE) \
597 if (PassBuilder::checkParametrizedPassName(Name, NAME)) { \
598 auto L = PassBuilder::parsePassParameters(parseOptLevelParam, Name, NAME); \
600 errs() << NAME ": " << toString(L.takeError()) << '\n'; \
603 INVOKE(PM, L.get()); \
606#include "PassRegistry.def"
614#define CGSCC_CALLBACK(NAME, INVOKE) \
615 if (PassBuilder::checkParametrizedPassName(Name, NAME)) { \
616 auto L = PassBuilder::parsePassParameters(parseOptLevelParam, Name, NAME); \
618 errs() << NAME ": " << toString(L.takeError()) << '\n'; \
621 INVOKE(PM, L.get()); \
624#include "PassRegistry.def"
632#define LOOP_CALLBACK(NAME, INVOKE) \
633 if (PassBuilder::checkParametrizedPassName(Name, NAME)) { \
634 auto L = PassBuilder::parsePassParameters(parseOptLevelParam, Name, NAME); \
636 errs() << NAME ": " << toString(L.takeError()) << '\n'; \
639 INVOKE(PM, L.get()); \
642#include "PassRegistry.def"
648#define MODULE_ANALYSIS(NAME, CREATE_PASS) \
649 MAM.registerPass([&] { return CREATE_PASS; });
650#include "PassRegistry.def"
652 for (
auto &
C : ModuleAnalysisRegistrationCallbacks)
657#define CGSCC_ANALYSIS(NAME, CREATE_PASS) \
658 CGAM.registerPass([&] { return CREATE_PASS; });
659#include "PassRegistry.def"
661 for (
auto &
C : CGSCCAnalysisRegistrationCallbacks)
671#define FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
672 FAM.registerPass([&] { return CREATE_PASS; });
673#include "PassRegistry.def"
675 for (
auto &
C : FunctionAnalysisRegistrationCallbacks)
682#define MACHINE_FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
683 MFAM.registerPass([&] { return CREATE_PASS; });
684#include "llvm/Passes/MachinePassRegistry.def"
686 for (
auto &
C : MachineFunctionAnalysisRegistrationCallbacks)
691#define LOOP_ANALYSIS(NAME, CREATE_PASS) \
692 LAM.registerPass([&] { return CREATE_PASS; });
693#include "PassRegistry.def"
695 for (
auto &
C : LoopAnalysisRegistrationCallbacks)
699static std::optional<std::pair<bool, bool>>
701 std::pair<bool, bool> Params;
702 if (!Name.consume_front(
"function"))
706 if (!Name.consume_front(
"<") || !Name.consume_back(
">"))
708 while (!Name.empty()) {
709 auto [Front, Back] = Name.split(
';');
711 if (Front ==
"eager-inv")
713 else if (Front ==
"no-rerun")
714 Params.second =
true;
722 if (!Name.consume_front(
"devirt<") || !Name.consume_back(
">"))
734 while (!Params.
empty()) {
736 std::tie(ParamName, Params) = Params.
split(
';');
738 if (ParamName == OptionName) {
755 while (!Params.
empty()) {
757 std::tie(ParamName, Params) = Params.
split(
';');
762 formatv(
"invalid HardwareLoopPass parameter '{}'", ParamName).str(),
767 if (ParamName.
consume_front(
"hardware-loop-counter-bitwidth=")) {
771 formatv(
"invalid HardwareLoopPass parameter '{}'", ParamName).str(),
776 if (ParamName ==
"force-hardware-loops") {
778 }
else if (ParamName ==
"force-hardware-loop-phi") {
780 }
else if (ParamName ==
"force-nested-hardware-loop") {
782 }
else if (ParamName ==
"force-hardware-loop-guard") {
786 formatv(
"invalid HardwarePass parameter '{}'", ParamName).str(),
790 return HardwareLoopOpts;
802 while (!Params.
empty()) {
804 std::tie(ParamName, Params) = Params.
split(
';');
805 std::optional<OptimizationLevel> OptLevel =
parseOptLevel(ParamName);
807 if (OptLevel && !OptLevel->isOptimizingForSize()) {
808 UnrollOpts.
setOptLevel(OptLevel->getSpeedupLevel());
815 formatv(
"invalid LoopUnrollPass parameter '{}'", ParamName).str(),
822 if (ParamName ==
"partial") {
824 }
else if (ParamName ==
"peeling") {
826 }
else if (ParamName ==
"profile-peeling") {
828 }
else if (ParamName ==
"runtime") {
830 }
else if (ParamName ==
"upperbound") {
834 formatv(
"invalid LoopUnrollPass parameter '{}'", ParamName).str(),
843 Params,
"vfe-linkage-unit-visibility",
"GlobalDCE");
863 Params,
"skip-non-recursive-function-attrs",
"PostOrderFunctionAttrs");
873 formatv(
"too many CFGuardPass parameters '{}'", Params).str(),
876 if (Param ==
"check")
878 if (Param ==
"dispatch")
882 formatv(
"invalid CFGuardPass mechanism: '{}'", Param).str(),
892 "EntryExitInstrumenter");
901 "LowerMatrixIntrinsics");
906 while (!Params.
empty()) {
908 std::tie(ParamName, Params) = Params.
split(
';');
911 if (ParamName ==
"preserve-order")
913 else if (ParamName ==
"rename-all")
915 else if (ParamName ==
"fold-all")
917 else if (ParamName ==
"reorder-operands")
921 formatv(
"invalid normalize pass parameter '{}'", ParamName).str(),
931 while (!Params.
empty()) {
933 std::tie(ParamName, Params) = Params.
split(
';');
935 if (ParamName ==
"kernel") {
936 Result.CompileKernel =
true;
937 }
else if (ParamName ==
"use-after-scope") {
938 Result.UseAfterScope =
true;
941 formatv(
"invalid AddressSanitizer pass parameter '{}'", ParamName)
951 while (!Params.
empty()) {
953 std::tie(ParamName, Params) = Params.
split(
';');
955 if (ParamName ==
"recover") {
957 }
else if (ParamName ==
"kernel") {
958 Result.CompileKernel =
true;
961 formatv(
"invalid HWAddressSanitizer pass parameter '{}'", ParamName)
971 while (!Params.
empty()) {
973 std::tie(ParamName, Params) = Params.
split(
';');
975 if (ParamName ==
"thinlto") {
977 }
else if (ParamName ==
"emit-summary") {
978 Result.EmitLTOSummary =
true;
981 formatv(
"invalid EmbedBitcode pass parameter '{}'", ParamName).str(),
989parseLowerAllowCheckPassOptions(
StringRef Params) {
991 while (!Params.
empty()) {
993 std::tie(ParamName, Params) = Params.
split(
';');
1004 std::tie(IndicesStr, CutoffStr) = ParamName.
split(
"]=");
1011 formatv(
"invalid LowerAllowCheck pass cutoffs parameter '{}' ({})",
1016 if (!IndicesStr.
consume_front(
"cutoffs[") || IndicesStr ==
"")
1018 formatv(
"invalid LowerAllowCheck pass index parameter '{}' ({})",
1019 IndicesStr, CutoffStr)
1023 while (IndicesStr !=
"") {
1025 std::tie(firstIndexStr, IndicesStr) = IndicesStr.
split(
'|');
1031 "invalid LowerAllowCheck pass index parameter '{}' ({}) {}",
1032 firstIndexStr, IndicesStr)
1039 if (index >=
Result.cutoffs.size())
1040 Result.cutoffs.resize(index + 1, 0);
1042 Result.cutoffs[index] = cutoff;
1044 }
else if (ParamName.
starts_with(
"runtime_check")) {
1046 std::tie(std::ignore, ValueString) = ParamName.
split(
"=");
1050 formatv(
"invalid LowerAllowCheck pass runtime_check parameter '{}' "
1052 ValueString, Params)
1056 Result.runtime_check = runtime_check;
1059 formatv(
"invalid LowerAllowCheck pass parameter '{}'", ParamName)
1070 while (!Params.
empty()) {
1072 std::tie(ParamName, Params) = Params.
split(
';');
1074 if (ParamName ==
"recover") {
1076 }
else if (ParamName ==
"kernel") {
1081 formatv(
"invalid argument to MemorySanitizer pass track-origins "
1086 }
else if (ParamName ==
"eager-checks") {
1087 Result.EagerChecks =
true;
1090 formatv(
"invalid MemorySanitizer pass parameter '{}'", ParamName)
1101 while (!Params.
empty()) {
1103 std::tie(ParamName, Params) = Params.
split(
';');
1106 if (ParamName ==
"speculate-blocks") {
1108 }
else if (ParamName ==
"simplify-cond-branch") {
1110 }
else if (ParamName ==
"forward-switch-cond") {
1112 }
else if (ParamName ==
"switch-range-to-icmp") {
1114 }
else if (ParamName ==
"switch-to-lookup") {
1116 }
else if (ParamName ==
"keep-loops") {
1118 }
else if (ParamName ==
"hoist-common-insts") {
1120 }
else if (ParamName ==
"hoist-loads-stores-with-cond-faulting") {
1122 }
else if (ParamName ==
"sink-common-insts") {
1124 }
else if (ParamName ==
"speculate-unpredictables") {
1127 APInt BonusInstThreshold;
1130 formatv(
"invalid argument to SimplifyCFG pass bonus-threshold "
1138 formatv(
"invalid SimplifyCFG pass parameter '{}'", ParamName).str(),
1149 Result.setVerifyFixpoint(
true);
1150 while (!Params.
empty()) {
1152 std::tie(ParamName, Params) = Params.
split(
';');
1155 if (ParamName ==
"verify-fixpoint") {
1158 APInt MaxIterations;
1161 formatv(
"invalid argument to InstCombine pass max-iterations "
1169 formatv(
"invalid InstCombine pass parameter '{}'", ParamName).str(),
1179 while (!Params.
empty()) {
1181 std::tie(ParamName, Params) = Params.
split(
';');
1184 if (ParamName ==
"interleave-forced-only") {
1186 }
else if (ParamName ==
"vectorize-forced-only") {
1190 formatv(
"invalid LoopVectorize parameter '{}'", ParamName).str(),
1198 std::pair<bool, bool>
Result = {
false,
true};
1199 while (!Params.
empty()) {
1201 std::tie(ParamName, Params) = Params.
split(
';');
1204 if (ParamName ==
"nontrivial") {
1206 }
else if (ParamName ==
"trivial") {
1210 formatv(
"invalid LoopUnswitch pass parameter '{}'", ParamName).str(),
1219 while (!Params.
empty()) {
1221 std::tie(ParamName, Params) = Params.
split(
';');
1224 if (ParamName ==
"allowspeculation") {
1228 formatv(
"invalid LICM pass parameter '{}'", ParamName).str(),
1236 std::pair<bool, bool>
Result = {
true,
false};
1237 while (!Params.
empty()) {
1239 std::tie(ParamName, Params) = Params.
split(
';');
1242 if (ParamName ==
"header-duplication") {
1244 }
else if (ParamName ==
"prepare-for-lto") {
1248 formatv(
"invalid LoopRotate pass parameter '{}'", ParamName).str(),
1257 while (!Params.
empty()) {
1259 std::tie(ParamName, Params) = Params.
split(
';');
1262 if (ParamName ==
"split-footer-bb") {
1266 formatv(
"invalid MergedLoadStoreMotion pass parameter '{}'",
1277 while (!Params.
empty()) {
1279 std::tie(ParamName, Params) = Params.
split(
';');
1282 if (ParamName ==
"pre") {
1284 }
else if (ParamName ==
"load-pre") {
1286 }
else if (ParamName ==
"split-backedge-load-pre") {
1288 }
else if (ParamName ==
"memdep") {
1292 }
else if (ParamName ==
"memoryssa") {
1298 formatv(
"invalid GVN pass parameter '{}'", ParamName).str(),
1307 while (!Params.
empty()) {
1309 std::tie(ParamName, Params) = Params.
split(
';');
1312 if (ParamName ==
"func-spec")
1316 formatv(
"invalid IPSCCP pass parameter '{}'", ParamName).str(),
1324 while (!Params.
empty()) {
1326 std::tie(ParamName, Params) = Params.
split(
';');
1331 formatv(
"invalid argument to Scalarizer pass min-bits "
1342 if (ParamName ==
"load-store")
1344 else if (ParamName ==
"variable-insert-extract")
1348 formatv(
"invalid Scalarizer pass parameter '{}'", ParamName).str(),
1357 if (Params.
empty() || Params ==
"modify-cfg")
1359 if (Params ==
"preserve-cfg")
1362 formatv(
"invalid SROA pass parameter '{}' (either preserve-cfg or "
1363 "modify-cfg can be specified)",
1370parseStackLifetimeOptions(
StringRef Params) {
1372 while (!Params.
empty()) {
1374 std::tie(ParamName, Params) = Params.
split(
';');
1376 if (ParamName ==
"may") {
1378 }
else if (ParamName ==
"must") {
1382 formatv(
"invalid StackLifetime parameter '{}'", ParamName).str(),
1391 "DependenceAnalysisPrinter");
1396 "SeparateConstOffsetFromGEP");
1405parseFunctionSimplificationPipelineOptions(
StringRef Params) {
1409 formatv(
"invalid function-simplification parameter '{}'", Params).str(),
1417 "MemorySSAPrinterPass");
1422 "SpeculativeExecutionPass");
1427 while (!Params.
empty()) {
1429 std::tie(ParamName, Params) = Params.
split(
';');
1435 formatv(
"invalid MemProfUse pass parameter '{}'", ParamName).str(),
1443parseStructuralHashPrinterPassOptions(
StringRef Params) {
1446 if (Params ==
"detailed")
1448 if (Params ==
"call-target-ignored")
1451 formatv(
"invalid structural hash printer parameter '{}'", Params).str(),
1457 "WinEHPreparePass");
1462 while (!Params.
empty()) {
1464 std::tie(ParamName, Params) = Params.
split(
';');
1467 if (ParamName ==
"group-by-use")
1469 else if (ParamName ==
"ignore-single-use")
1471 else if (ParamName ==
"merge-const")
1473 else if (ParamName ==
"merge-const-aggressive")
1475 else if (ParamName ==
"merge-external")
1480 formatv(
"invalid GlobalMergePass parameter '{}'", ParamName).str(),
1484 formatv(
"invalid global-merge pass parameter '{}'", Params).str(),
1493 while (!Params.
empty()) {
1495 std::tie(ParamName, Params) = Params.
split(
';');
1501 formatv(
"invalid Internalize pass parameter '{}'", ParamName).str(),
1512 while (!Params.
empty()) {
1514 std::tie(ParamName, Params) = Params.
split(
';');
1517 std::optional<RegAllocFilterFunc>
Filter =
1521 formatv(
"invalid regallocfast register filter '{}'", ParamName)
1530 if (ParamName ==
"no-clear-vregs") {
1536 formatv(
"invalid regallocfast pass parameter '{}'", ParamName).str(),
1543parseBoundsCheckingOptions(
StringRef Params) {
1545 while (!Params.
empty()) {
1547 std::tie(ParamName, Params) = Params.
split(
';');
1548 if (ParamName ==
"trap") {
1550 }
else if (ParamName ==
"rt") {
1555 }
else if (ParamName ==
"rt-abort") {
1560 }
else if (ParamName ==
"min-rt") {
1565 }
else if (ParamName ==
"min-rt-abort") {
1570 }
else if (ParamName ==
"merge") {
1575 std::tie(ParamEQ, Val) = ParamName.
split(
'=');
1581 formatv(
"invalid BoundsChecking pass parameter '{}'", ParamName)
1598 if (!
Prefix.empty() || Digit.getAsInteger(10,
N))
1600 Param.str().c_str());
1603 if (!
Level.has_value())
1605 "invalid optimization level for expand-fp pass: %s",
1606 Digit.str().c_str());
1613 if (Params.
empty() || Params ==
"all")
1614 return RAGreedyPass::Options();
1618 return RAGreedyPass::Options{*
Filter, Params};
1621 formatv(
"invalid regallocgreedy register filter '{}'", Params).str(),
1627 "MachineSinkingPass");
1631 bool AllowTailMerge =
true;
1632 if (!Params.
empty()) {
1634 if (Params !=
"tail-merge")
1636 formatv(
"invalid MachineBlockPlacementPass parameter '{}'", Params)
1640 return AllowTailMerge;
1644 bool ClearVirtRegs =
true;
1645 if (!Params.
empty()) {
1647 if (Params !=
"clear-vregs")
1649 formatv(
"invalid VirtRegRewriter pass parameter '{}'", Params).str(),
1652 return ClearVirtRegs;
1655struct FatLTOOptions {
1656 OptimizationLevel OptLevel;
1657 bool ThinLTO =
false;
1658 bool EmitSummary =
false;
1663 bool HaveOptLevel =
false;
1664 while (!Params.
empty()) {
1666 std::tie(ParamName, Params) = Params.
split(
';');
1668 if (ParamName ==
"thinlto") {
1670 }
else if (ParamName ==
"emit-summary") {
1671 Result.EmitSummary =
true;
1672 }
else if (std::optional<OptimizationLevel> OptLevel =
1674 Result.OptLevel = *OptLevel;
1675 HaveOptLevel =
true;
1678 formatv(
"invalid fatlto-pre-link pass parameter '{}'", ParamName)
1685 "missing optimization level for fatlto-pre-link pipeline",
1700template <
typename PassManagerT,
typename CallbacksT>
1702 if (!Callbacks.empty()) {
1703 PassManagerT DummyPM;
1704 for (
auto &CB : Callbacks)
1705 if (CB(Name, DummyPM, {}))
1711template <
typename CallbacksT>
1713 StringRef NameNoBracket = Name.take_until([](
char C) {
return C ==
'<'; });
1716 if (Name ==
"module")
1718 if (Name ==
"cgscc")
1720 if (NameNoBracket ==
"function")
1722 if (Name ==
"coro-cond")
1725#define MODULE_PASS(NAME, CREATE_PASS) \
1728#define MODULE_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1729 if (PassBuilder::checkParametrizedPassName(Name, NAME)) \
1731#define MODULE_ANALYSIS(NAME, CREATE_PASS) \
1732 if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
1734#include "PassRegistry.def"
1739template <
typename CallbacksT>
1742 StringRef NameNoBracket = Name.take_until([](
char C) {
return C ==
'<'; });
1743 if (Name ==
"cgscc")
1745 if (NameNoBracket ==
"function")
1752#define CGSCC_PASS(NAME, CREATE_PASS) \
1755#define CGSCC_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1756 if (PassBuilder::checkParametrizedPassName(Name, NAME)) \
1758#define CGSCC_ANALYSIS(NAME, CREATE_PASS) \
1759 if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
1761#include "PassRegistry.def"
1766template <
typename CallbacksT>
1769 StringRef NameNoBracket = Name.take_until([](
char C) {
return C ==
'<'; });
1770 if (NameNoBracket ==
"function")
1772 if (Name ==
"loop" || Name ==
"loop-mssa" || Name ==
"machine-function")
1775#define FUNCTION_PASS(NAME, CREATE_PASS) \
1778#define FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1779 if (PassBuilder::checkParametrizedPassName(Name, NAME)) \
1781#define FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
1782 if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
1784#include "PassRegistry.def"
1789template <
typename CallbacksT>
1792 if (Name ==
"machine-function")
1795#define MACHINE_FUNCTION_PASS(NAME, CREATE_PASS) \
1798#define MACHINE_FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, \
1800 if (PassBuilder::checkParametrizedPassName(Name, NAME)) \
1803#define MACHINE_FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
1804 if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
1807#include "llvm/Passes/MachinePassRegistry.def"
1812template <
typename CallbacksT>
1814 bool &UseMemorySSA) {
1815 UseMemorySSA =
false;
1818 UseMemorySSA =
true;
1822#define LOOPNEST_PASS(NAME, CREATE_PASS) \
1825#include "PassRegistry.def"
1830template <
typename CallbacksT>
1832 bool &UseMemorySSA) {
1833 UseMemorySSA =
false;
1836 UseMemorySSA =
true;
1840#define LOOP_PASS(NAME, CREATE_PASS) \
1843#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1844 if (PassBuilder::checkParametrizedPassName(Name, NAME)) \
1846#define LOOP_ANALYSIS(NAME, CREATE_PASS) \
1847 if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
1849#include "PassRegistry.def"
1854std::optional<std::vector<PassBuilder::PipelineElement>>
1855PassBuilder::parsePipelineText(
StringRef Text) {
1856 std::vector<PipelineElement> ResultPipeline;
1861 std::vector<PipelineElement> &Pipeline = *PipelineStack.
back();
1862 size_t Pos =
Text.find_first_of(
",()");
1863 Pipeline.push_back({
Text.substr(0, Pos), {}});
1866 if (Pos ==
Text.npos)
1869 char Sep =
Text[Pos];
1877 PipelineStack.
push_back(&Pipeline.back().InnerPipeline);
1881 assert(Sep ==
')' &&
"Bogus separator!");
1886 if (PipelineStack.
size() == 1)
1887 return std::nullopt;
1890 }
while (
Text.consume_front(
")"));
1898 if (!
Text.consume_front(
","))
1899 return std::nullopt;
1902 if (PipelineStack.
size() > 1)
1904 return std::nullopt;
1906 assert(PipelineStack.
back() == &ResultPipeline &&
1907 "Wrong pipeline at the bottom of the stack!");
1908 return {std::move(ResultPipeline)};
1921 const PipelineElement &
E) {
1922 auto &
Name =
E.Name;
1923 auto &InnerPipeline =
E.InnerPipeline;
1926 if (!InnerPipeline.empty()) {
1927 if (Name ==
"module") {
1929 if (
auto Err = parseModulePassPipeline(NestedMPM, InnerPipeline))
1931 MPM.
addPass(std::move(NestedMPM));
1934 if (Name ==
"coro-cond") {
1936 if (
auto Err = parseModulePassPipeline(NestedMPM, InnerPipeline))
1938 MPM.
addPass(CoroConditionalWrapper(std::move(NestedMPM)));
1941 if (Name ==
"cgscc") {
1943 if (
auto Err = parseCGSCCPassPipeline(CGPM, InnerPipeline))
1951 "cannot have a no-rerun module to function adaptor",
1954 if (
auto Err = parseFunctionPassPipeline(FPM, InnerPipeline))
1961 for (
auto &
C : ModulePipelineParsingCallbacks)
1962 if (
C(Name, MPM, InnerPipeline))
1967 formatv(
"invalid use of '{}' pass as module pipeline", Name).str(),
1973#define MODULE_PASS(NAME, CREATE_PASS) \
1974 if (Name == NAME) { \
1975 MPM.addPass(CREATE_PASS); \
1976 return Error::success(); \
1978#define MODULE_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1979 if (checkParametrizedPassName(Name, NAME)) { \
1980 auto Params = parsePassParameters(PARSER, Name, NAME); \
1982 return Params.takeError(); \
1983 MPM.addPass(CREATE_PASS(Params.get())); \
1984 return Error::success(); \
1986#define MODULE_ANALYSIS(NAME, CREATE_PASS) \
1987 if (Name == "require<" NAME ">") { \
1989 RequireAnalysisPass< \
1990 std::remove_reference_t<decltype(CREATE_PASS)>, Module>()); \
1991 return Error::success(); \
1993 if (Name == "invalidate<" NAME ">") { \
1994 MPM.addPass(InvalidateAnalysisPass< \
1995 std::remove_reference_t<decltype(CREATE_PASS)>>()); \
1996 return Error::success(); \
1998#define CGSCC_PASS(NAME, CREATE_PASS) \
1999 if (Name == NAME) { \
2000 MPM.addPass(createModuleToPostOrderCGSCCPassAdaptor(CREATE_PASS)); \
2001 return Error::success(); \
2003#define CGSCC_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
2004 if (checkParametrizedPassName(Name, NAME)) { \
2005 auto Params = parsePassParameters(PARSER, Name, NAME); \
2007 return Params.takeError(); \
2009 createModuleToPostOrderCGSCCPassAdaptor(CREATE_PASS(Params.get()))); \
2010 return Error::success(); \
2012#define FUNCTION_PASS(NAME, CREATE_PASS) \
2013 if (Name == NAME) { \
2014 MPM.addPass(createModuleToFunctionPassAdaptor(CREATE_PASS)); \
2015 return Error::success(); \
2017#define FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
2018 if (checkParametrizedPassName(Name, NAME)) { \
2019 auto Params = parsePassParameters(PARSER, Name, NAME); \
2021 return Params.takeError(); \
2022 MPM.addPass(createModuleToFunctionPassAdaptor(CREATE_PASS(Params.get()))); \
2023 return Error::success(); \
2025#define LOOPNEST_PASS(NAME, CREATE_PASS) \
2026 if (Name == NAME) { \
2027 MPM.addPass(createModuleToFunctionPassAdaptor( \
2028 createFunctionToLoopPassAdaptor(CREATE_PASS, false, false))); \
2029 return Error::success(); \
2031#define LOOP_PASS(NAME, CREATE_PASS) \
2032 if (Name == NAME) { \
2033 MPM.addPass(createModuleToFunctionPassAdaptor( \
2034 createFunctionToLoopPassAdaptor(CREATE_PASS, false, false))); \
2035 return Error::success(); \
2037#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
2038 if (checkParametrizedPassName(Name, NAME)) { \
2039 auto Params = parsePassParameters(PARSER, Name, NAME); \
2041 return Params.takeError(); \
2043 createModuleToFunctionPassAdaptor(createFunctionToLoopPassAdaptor( \
2044 CREATE_PASS(Params.get()), false, false))); \
2045 return Error::success(); \
2047#include "PassRegistry.def"
2049 for (
auto &
C : ModulePipelineParsingCallbacks)
2050 if (
C(Name, MPM, InnerPipeline))
2053 formatv(
"unknown module pass '{}'", Name).str(),
2058 const PipelineElement &
E) {
2059 auto &
Name =
E.Name;
2060 auto &InnerPipeline =
E.InnerPipeline;
2063 if (!InnerPipeline.empty()) {
2064 if (Name ==
"cgscc") {
2066 if (
auto Err = parseCGSCCPassPipeline(NestedCGPM, InnerPipeline))
2069 CGPM.
addPass(std::move(NestedCGPM));
2074 if (
auto Err = parseFunctionPassPipeline(FPM, InnerPipeline))
2078 std::move(FPM), Params->first, Params->second));
2083 if (
auto Err = parseCGSCCPassPipeline(NestedCGPM, InnerPipeline))
2090 for (
auto &
C : CGSCCPipelineParsingCallbacks)
2091 if (
C(Name, CGPM, InnerPipeline))
2096 formatv(
"invalid use of '{}' pass as cgscc pipeline", Name).str(),
2101#define CGSCC_PASS(NAME, CREATE_PASS) \
2102 if (Name == NAME) { \
2103 CGPM.addPass(CREATE_PASS); \
2104 return Error::success(); \
2106#define CGSCC_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
2107 if (checkParametrizedPassName(Name, NAME)) { \
2108 auto Params = parsePassParameters(PARSER, Name, NAME); \
2110 return Params.takeError(); \
2111 CGPM.addPass(CREATE_PASS(Params.get())); \
2112 return Error::success(); \
2114#define CGSCC_ANALYSIS(NAME, CREATE_PASS) \
2115 if (Name == "require<" NAME ">") { \
2116 CGPM.addPass(RequireAnalysisPass< \
2117 std::remove_reference_t<decltype(CREATE_PASS)>, \
2118 LazyCallGraph::SCC, CGSCCAnalysisManager, LazyCallGraph &, \
2119 CGSCCUpdateResult &>()); \
2120 return Error::success(); \
2122 if (Name == "invalidate<" NAME ">") { \
2123 CGPM.addPass(InvalidateAnalysisPass< \
2124 std::remove_reference_t<decltype(CREATE_PASS)>>()); \
2125 return Error::success(); \
2127#define FUNCTION_PASS(NAME, CREATE_PASS) \
2128 if (Name == NAME) { \
2129 CGPM.addPass(createCGSCCToFunctionPassAdaptor(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 CGPM.addPass(createCGSCCToFunctionPassAdaptor(CREATE_PASS(Params.get()))); \
2138 return Error::success(); \
2140#define LOOPNEST_PASS(NAME, CREATE_PASS) \
2141 if (Name == NAME) { \
2142 CGPM.addPass(createCGSCCToFunctionPassAdaptor( \
2143 createFunctionToLoopPassAdaptor(CREATE_PASS, false, false))); \
2144 return Error::success(); \
2146#define LOOP_PASS(NAME, CREATE_PASS) \
2147 if (Name == NAME) { \
2148 CGPM.addPass(createCGSCCToFunctionPassAdaptor( \
2149 createFunctionToLoopPassAdaptor(CREATE_PASS, false, false))); \
2150 return Error::success(); \
2152#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
2153 if (checkParametrizedPassName(Name, NAME)) { \
2154 auto Params = parsePassParameters(PARSER, Name, NAME); \
2156 return Params.takeError(); \
2158 createCGSCCToFunctionPassAdaptor(createFunctionToLoopPassAdaptor( \
2159 CREATE_PASS(Params.get()), false, false))); \
2160 return Error::success(); \
2162#include "PassRegistry.def"
2164 for (
auto &
C : CGSCCPipelineParsingCallbacks)
2165 if (
C(Name, CGPM, InnerPipeline))
2172 const PipelineElement &
E) {
2173 auto &
Name =
E.Name;
2174 auto &InnerPipeline =
E.InnerPipeline;
2177 if (!InnerPipeline.empty()) {
2178 if (Name ==
"function") {
2180 if (
auto Err = parseFunctionPassPipeline(NestedFPM, InnerPipeline))
2183 FPM.
addPass(std::move(NestedFPM));
2186 if (Name ==
"loop" || Name ==
"loop-mssa") {
2188 if (
auto Err = parseLoopPassPipeline(LPM, InnerPipeline))
2191 bool UseMemorySSA = (
Name ==
"loop-mssa");
2193 return Pipeline.Name.contains(
"simple-loop-unswitch");
2199 if (Name ==
"machine-function") {
2201 if (
auto Err = parseMachinePassPipeline(MFPM, InnerPipeline))
2207 for (
auto &
C : FunctionPipelineParsingCallbacks)
2208 if (
C(Name, FPM, InnerPipeline))
2213 formatv(
"invalid use of '{}' pass as function pipeline", Name).str(),
2218#define FUNCTION_PASS(NAME, CREATE_PASS) \
2219 if (Name == NAME) { \
2220 FPM.addPass(CREATE_PASS); \
2221 return Error::success(); \
2223#define FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
2224 if (checkParametrizedPassName(Name, NAME)) { \
2225 auto Params = parsePassParameters(PARSER, Name, NAME); \
2227 return Params.takeError(); \
2228 FPM.addPass(CREATE_PASS(Params.get())); \
2229 return Error::success(); \
2231#define FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
2232 if (Name == "require<" NAME ">") { \
2234 RequireAnalysisPass< \
2235 std::remove_reference_t<decltype(CREATE_PASS)>, Function>()); \
2236 return Error::success(); \
2238 if (Name == "invalidate<" NAME ">") { \
2239 FPM.addPass(InvalidateAnalysisPass< \
2240 std::remove_reference_t<decltype(CREATE_PASS)>>()); \
2241 return Error::success(); \
2247#define LOOPNEST_PASS(NAME, CREATE_PASS) \
2248 if (Name == NAME) { \
2249 FPM.addPass(createFunctionToLoopPassAdaptor(CREATE_PASS, false, false)); \
2250 return Error::success(); \
2252#define LOOP_PASS(NAME, CREATE_PASS) \
2253 if (Name == NAME) { \
2254 FPM.addPass(createFunctionToLoopPassAdaptor(CREATE_PASS, false, false)); \
2255 return Error::success(); \
2257#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
2258 if (checkParametrizedPassName(Name, NAME)) { \
2259 auto Params = parsePassParameters(PARSER, Name, NAME); \
2261 return Params.takeError(); \
2262 FPM.addPass(createFunctionToLoopPassAdaptor(CREATE_PASS(Params.get()), \
2264 return Error::success(); \
2266#include "PassRegistry.def"
2268 for (
auto &
C : FunctionPipelineParsingCallbacks)
2269 if (
C(Name, FPM, InnerPipeline))
2272 formatv(
"unknown function pass '{}'", Name).str(),
2277 const PipelineElement &
E) {
2278 StringRef
Name =
E.Name;
2279 auto &InnerPipeline =
E.InnerPipeline;
2282 if (!InnerPipeline.empty()) {
2283 if (Name ==
"loop") {
2285 if (
auto Err = parseLoopPassPipeline(NestedLPM, InnerPipeline))
2288 LPM.addPass(std::move(NestedLPM));
2292 for (
auto &
C : LoopPipelineParsingCallbacks)
2293 if (
C(Name, LPM, InnerPipeline))
2298 formatv(
"invalid use of '{}' pass as loop pipeline", Name).str(),
2303#define LOOPNEST_PASS(NAME, CREATE_PASS) \
2304 if (Name == NAME) { \
2305 LPM.addPass(CREATE_PASS); \
2306 return Error::success(); \
2308#define LOOP_PASS(NAME, CREATE_PASS) \
2309 if (Name == NAME) { \
2310 LPM.addPass(CREATE_PASS); \
2311 return Error::success(); \
2313#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
2314 if (checkParametrizedPassName(Name, NAME)) { \
2315 auto Params = parsePassParameters(PARSER, Name, NAME); \
2317 return Params.takeError(); \
2318 LPM.addPass(CREATE_PASS(Params.get())); \
2319 return Error::success(); \
2321#define LOOP_ANALYSIS(NAME, CREATE_PASS) \
2322 if (Name == "require<" NAME ">") { \
2323 LPM.addPass(RequireAnalysisPass< \
2324 std::remove_reference_t<decltype(CREATE_PASS)>, Loop, \
2325 LoopAnalysisManager, LoopStandardAnalysisResults &, \
2327 return Error::success(); \
2329 if (Name == "invalidate<" NAME ">") { \
2330 LPM.addPass(InvalidateAnalysisPass< \
2331 std::remove_reference_t<decltype(CREATE_PASS)>>()); \
2332 return Error::success(); \
2334#include "PassRegistry.def"
2336 for (
auto &
C : LoopPipelineParsingCallbacks)
2337 if (
C(Name, LPM, InnerPipeline))
2344 const PipelineElement &
E) {
2345 StringRef
Name =
E.Name;
2347 if (!
E.InnerPipeline.empty()) {
2348 if (
E.Name ==
"machine-function") {
2350 if (
auto Err = parseMachinePassPipeline(NestedPM,
E.InnerPipeline))
2352 MFPM.
addPass(std::move(NestedPM));
2359#define MACHINE_MODULE_PASS(NAME, CREATE_PASS) \
2360 if (Name == NAME) { \
2361 MFPM.addPass(CREATE_PASS); \
2362 return Error::success(); \
2364#define MACHINE_FUNCTION_PASS(NAME, CREATE_PASS) \
2365 if (Name == NAME) { \
2366 MFPM.addPass(CREATE_PASS); \
2367 return Error::success(); \
2369#define MACHINE_FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, \
2371 if (checkParametrizedPassName(Name, NAME)) { \
2372 auto Params = parsePassParameters(PARSER, Name, NAME); \
2374 return Params.takeError(); \
2375 MFPM.addPass(CREATE_PASS(Params.get())); \
2376 return Error::success(); \
2378#define MACHINE_FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
2379 if (Name == "require<" NAME ">") { \
2381 RequireAnalysisPass<std::remove_reference_t<decltype(CREATE_PASS)>, \
2382 MachineFunction>()); \
2383 return Error::success(); \
2385 if (Name == "invalidate<" NAME ">") { \
2386 MFPM.addPass(InvalidateAnalysisPass< \
2387 std::remove_reference_t<decltype(CREATE_PASS)>>()); \
2388 return Error::success(); \
2390#include "llvm/Passes/MachinePassRegistry.def"
2392 for (
auto &
C : MachineFunctionPipelineParsingCallbacks)
2393 if (
C(Name, MFPM,
E.InnerPipeline))
2396 formatv(
"unknown machine pass '{}'", Name).str(),
2401#define MODULE_ALIAS_ANALYSIS(NAME, CREATE_PASS) \
2402 if (Name == NAME) { \
2403 AA.registerModuleAnalysis< \
2404 std::remove_reference_t<decltype(CREATE_PASS)>>(); \
2407#define FUNCTION_ALIAS_ANALYSIS(NAME, CREATE_PASS) \
2408 if (Name == NAME) { \
2409 AA.registerFunctionAnalysis< \
2410 std::remove_reference_t<decltype(CREATE_PASS)>>(); \
2413#include "PassRegistry.def"
2415 for (
auto &
C : AAParsingCallbacks)
2421Error PassBuilder::parseMachinePassPipeline(
2423 for (
const auto &Element : Pipeline) {
2424 if (
auto Err = parseMachinePass(MFPM, Element))
2432 for (
const auto &Element : Pipeline) {
2433 if (
auto Err = parseLoopPass(LPM, Element))
2439Error PassBuilder::parseFunctionPassPipeline(
2441 for (
const auto &Element : Pipeline) {
2442 if (
auto Err = parseFunctionPass(FPM, Element))
2450 for (
const auto &Element : Pipeline) {
2451 if (
auto Err = parseCGSCCPass(CGPM, Element))
2483 for (
const auto &Element : Pipeline) {
2484 if (
auto Err = parseModulePass(MPM, Element))
2495 auto Pipeline = parsePipelineText(PipelineText);
2496 if (!Pipeline || Pipeline->empty())
2498 formatv(
"invalid pipeline '{}'", PipelineText).str(),
2508 Pipeline = {{
"cgscc", std::move(*Pipeline)}};
2510 FunctionPipelineParsingCallbacks)) {
2511 Pipeline = {{
"function", std::move(*Pipeline)}};
2514 Pipeline = {{
"function", {{UseMemorySSA ?
"loop-mssa" :
"loop",
2515 std::move(*Pipeline)}}}};
2516 }
else if (
isLoopPassName(FirstName, LoopPipelineParsingCallbacks,
2518 Pipeline = {{
"function", {{UseMemorySSA ?
"loop-mssa" :
"loop",
2519 std::move(*Pipeline)}}}};
2521 FirstName, MachineFunctionPipelineParsingCallbacks)) {
2522 Pipeline = {{
"function", {{
"machine-function", std::move(*Pipeline)}}}};
2524 for (
auto &
C : TopLevelPipelineParsingCallbacks)
2525 if (
C(MPM, *Pipeline))
2529 auto &InnerPipeline = Pipeline->front().InnerPipeline;
2531 formatv(
"unknown {} name '{}'",
2532 (InnerPipeline.empty() ?
"pass" :
"pipeline"), FirstName)
2538 if (
auto Err = parseModulePassPipeline(MPM, *Pipeline))
2546 auto Pipeline = parsePipelineText(PipelineText);
2547 if (!Pipeline || Pipeline->empty())
2549 formatv(
"invalid pipeline '{}'", PipelineText).str(),
2555 formatv(
"unknown cgscc pass '{}' in pipeline '{}'", FirstName,
2560 if (
auto Err = parseCGSCCPassPipeline(CGPM, *Pipeline))
2569 auto Pipeline = parsePipelineText(PipelineText);
2570 if (!Pipeline || Pipeline->empty())
2572 formatv(
"invalid pipeline '{}'", PipelineText).str(),
2578 formatv(
"unknown function pass '{}' in pipeline '{}'", FirstName,
2583 if (
auto Err = parseFunctionPassPipeline(FPM, *Pipeline))
2591 auto Pipeline = parsePipelineText(PipelineText);
2592 if (!Pipeline || Pipeline->empty())
2594 formatv(
"invalid pipeline '{}'", PipelineText).str(),
2597 if (
auto Err = parseLoopPassPipeline(CGPM, *Pipeline))
2605 auto Pipeline = parsePipelineText(PipelineText);
2606 if (!Pipeline || Pipeline->empty())
2608 formatv(
"invalid machine pass pipeline '{}'", PipelineText).str(),
2611 if (
auto Err = parseMachinePassPipeline(MFPM, *Pipeline))
2620 if (PipelineText ==
"default") {
2625 while (!PipelineText.
empty()) {
2627 std::tie(Name, PipelineText) = PipelineText.
split(
',');
2628 if (!parseAAPassName(
AA, Name))
2630 formatv(
"unknown alias analysis name '{}'", Name).str(),
2637std::optional<RegAllocFilterFunc>
2639 if (FilterName ==
"all")
2641 for (
auto &
C : RegClassFilterParsingCallbacks)
2642 if (
auto F =
C(FilterName))
2644 return std::nullopt;
2652 OS <<
" " <<
PassName <<
"<" << Params <<
">\n";
2658 OS <<
"Module passes:\n";
2659#define MODULE_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2660#include "PassRegistry.def"
2662 OS <<
"Module passes with params:\n";
2663#define MODULE_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
2664 printPassName(NAME, PARAMS, OS);
2665#include "PassRegistry.def"
2667 OS <<
"Module analyses:\n";
2668#define MODULE_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2669#include "PassRegistry.def"
2671 OS <<
"Module alias analyses:\n";
2672#define MODULE_ALIAS_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2673#include "PassRegistry.def"
2675 OS <<
"CGSCC passes:\n";
2676#define CGSCC_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2677#include "PassRegistry.def"
2679 OS <<
"CGSCC passes with params:\n";
2680#define CGSCC_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
2681 printPassName(NAME, PARAMS, OS);
2682#include "PassRegistry.def"
2684 OS <<
"CGSCC analyses:\n";
2685#define CGSCC_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2686#include "PassRegistry.def"
2688 OS <<
"Function passes:\n";
2689#define FUNCTION_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2690#include "PassRegistry.def"
2692 OS <<
"Function passes with params:\n";
2693#define FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
2694 printPassName(NAME, PARAMS, OS);
2695#include "PassRegistry.def"
2697 OS <<
"Function analyses:\n";
2698#define FUNCTION_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2699#include "PassRegistry.def"
2701 OS <<
"Function alias analyses:\n";
2702#define FUNCTION_ALIAS_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2703#include "PassRegistry.def"
2705 OS <<
"LoopNest passes:\n";
2706#define LOOPNEST_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2707#include "PassRegistry.def"
2709 OS <<
"Loop passes:\n";
2710#define LOOP_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2711#include "PassRegistry.def"
2713 OS <<
"Loop passes with params:\n";
2714#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
2715 printPassName(NAME, PARAMS, OS);
2716#include "PassRegistry.def"
2718 OS <<
"Loop analyses:\n";
2719#define LOOP_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2720#include "PassRegistry.def"
2722 OS <<
"Machine module passes (WIP):\n";
2723#define MACHINE_MODULE_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2724#include "llvm/Passes/MachinePassRegistry.def"
2726 OS <<
"Machine function passes (WIP):\n";
2727#define MACHINE_FUNCTION_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2728#include "llvm/Passes/MachinePassRegistry.def"
2730 OS <<
"Machine function analyses (WIP):\n";
2731#define MACHINE_FUNCTION_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2732#include "llvm/Passes/MachinePassRegistry.def"
2738 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...
A smart pointer to a reference-counted object that inherits from RefCountedBase or ThreadSafeRefCount...
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 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 PassBuilder(TargetMachine *TM=nullptr, PipelineTuningOptions PTO=PipelineTuningOptions(), std::optional< PGOOptions > PGOOpt=std::nullopt, PassInstrumentationCallbacks *PIC=nullptr, IntrusiveRefCntPtr< vfs::FileSystem > FS=vfs::getRealFileSystem())
LLVM_ABI Error parsePassPipeline(ModulePassManager &MPM, StringRef PipelineText)
Parse a textual pass pipeline description into a ModulePassManager.
void registerPipelineParsingCallback(const std::function< bool(StringRef Name, CGSCCPassManager &, ArrayRef< PipelineElement >)> &C)
{{@ Register pipeline parsing callbacks with this pass builder instance.
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 >
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
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.
Implement std::hash so that hash_code can be used in STL containers.
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