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-arithmetic") {
1116 }
else if (ParamName ==
"switch-to-lookup") {
1118 }
else if (ParamName ==
"keep-loops") {
1120 }
else if (ParamName ==
"hoist-common-insts") {
1122 }
else if (ParamName ==
"hoist-loads-stores-with-cond-faulting") {
1124 }
else if (ParamName ==
"sink-common-insts") {
1126 }
else if (ParamName ==
"speculate-unpredictables") {
1129 APInt BonusInstThreshold;
1132 formatv(
"invalid argument to SimplifyCFG pass bonus-threshold "
1140 formatv(
"invalid SimplifyCFG pass parameter '{}'", ParamName).str(),
1151 Result.setVerifyFixpoint(
true);
1152 while (!Params.
empty()) {
1154 std::tie(ParamName, Params) = Params.
split(
';');
1157 if (ParamName ==
"verify-fixpoint") {
1160 APInt MaxIterations;
1163 formatv(
"invalid argument to InstCombine pass max-iterations "
1171 formatv(
"invalid InstCombine pass parameter '{}'", ParamName).str(),
1181 while (!Params.
empty()) {
1183 std::tie(ParamName, Params) = Params.
split(
';');
1186 if (ParamName ==
"interleave-forced-only") {
1188 }
else if (ParamName ==
"vectorize-forced-only") {
1192 formatv(
"invalid LoopVectorize parameter '{}'", ParamName).str(),
1200 std::pair<bool, bool>
Result = {
false,
true};
1201 while (!Params.
empty()) {
1203 std::tie(ParamName, Params) = Params.
split(
';');
1206 if (ParamName ==
"nontrivial") {
1208 }
else if (ParamName ==
"trivial") {
1212 formatv(
"invalid LoopUnswitch pass parameter '{}'", ParamName).str(),
1221 while (!Params.
empty()) {
1223 std::tie(ParamName, Params) = Params.
split(
';');
1226 if (ParamName ==
"allowspeculation") {
1230 formatv(
"invalid LICM pass parameter '{}'", ParamName).str(),
1238 std::pair<bool, bool>
Result = {
true,
false};
1239 while (!Params.
empty()) {
1241 std::tie(ParamName, Params) = Params.
split(
';');
1244 if (ParamName ==
"header-duplication") {
1246 }
else if (ParamName ==
"prepare-for-lto") {
1250 formatv(
"invalid LoopRotate pass parameter '{}'", ParamName).str(),
1259 while (!Params.
empty()) {
1261 std::tie(ParamName, Params) = Params.
split(
';');
1264 if (ParamName ==
"split-footer-bb") {
1268 formatv(
"invalid MergedLoadStoreMotion pass parameter '{}'",
1279 while (!Params.
empty()) {
1281 std::tie(ParamName, Params) = Params.
split(
';');
1284 if (ParamName ==
"pre") {
1286 }
else if (ParamName ==
"load-pre") {
1288 }
else if (ParamName ==
"split-backedge-load-pre") {
1290 }
else if (ParamName ==
"memdep") {
1294 }
else if (ParamName ==
"memoryssa") {
1300 formatv(
"invalid GVN pass parameter '{}'", ParamName).str(),
1309 while (!Params.
empty()) {
1311 std::tie(ParamName, Params) = Params.
split(
';');
1314 if (ParamName ==
"func-spec")
1318 formatv(
"invalid IPSCCP pass parameter '{}'", ParamName).str(),
1326 while (!Params.
empty()) {
1328 std::tie(ParamName, Params) = Params.
split(
';');
1333 formatv(
"invalid argument to Scalarizer pass min-bits "
1344 if (ParamName ==
"load-store")
1346 else if (ParamName ==
"variable-insert-extract")
1350 formatv(
"invalid Scalarizer pass parameter '{}'", ParamName).str(),
1359 if (Params.
empty() || Params ==
"modify-cfg")
1361 if (Params ==
"preserve-cfg")
1364 formatv(
"invalid SROA pass parameter '{}' (either preserve-cfg or "
1365 "modify-cfg can be specified)",
1372parseStackLifetimeOptions(
StringRef Params) {
1374 while (!Params.
empty()) {
1376 std::tie(ParamName, Params) = Params.
split(
';');
1378 if (ParamName ==
"may") {
1380 }
else if (ParamName ==
"must") {
1384 formatv(
"invalid StackLifetime parameter '{}'", ParamName).str(),
1393 "DependenceAnalysisPrinter");
1398 "SeparateConstOffsetFromGEP");
1407parseFunctionSimplificationPipelineOptions(
StringRef Params) {
1411 formatv(
"invalid function-simplification parameter '{}'", Params).str(),
1419 "MemorySSAPrinterPass");
1424 "SpeculativeExecutionPass");
1429 while (!Params.
empty()) {
1431 std::tie(ParamName, Params) = Params.
split(
';');
1437 formatv(
"invalid MemProfUse pass parameter '{}'", ParamName).str(),
1445parseStructuralHashPrinterPassOptions(
StringRef Params) {
1448 if (Params ==
"detailed")
1450 if (Params ==
"call-target-ignored")
1453 formatv(
"invalid structural hash printer parameter '{}'", Params).str(),
1459 "WinEHPreparePass");
1464 while (!Params.
empty()) {
1466 std::tie(ParamName, Params) = Params.
split(
';');
1469 if (ParamName ==
"group-by-use")
1471 else if (ParamName ==
"ignore-single-use")
1473 else if (ParamName ==
"merge-const")
1475 else if (ParamName ==
"merge-const-aggressive")
1477 else if (ParamName ==
"merge-external")
1482 formatv(
"invalid GlobalMergePass parameter '{}'", ParamName).str(),
1486 formatv(
"invalid global-merge pass parameter '{}'", Params).str(),
1495 while (!Params.
empty()) {
1497 std::tie(ParamName, Params) = Params.
split(
';');
1503 formatv(
"invalid Internalize pass parameter '{}'", ParamName).str(),
1514 while (!Params.
empty()) {
1516 std::tie(ParamName, Params) = Params.
split(
';');
1519 std::optional<RegAllocFilterFunc>
Filter =
1523 formatv(
"invalid regallocfast register filter '{}'", ParamName)
1532 if (ParamName ==
"no-clear-vregs") {
1538 formatv(
"invalid regallocfast pass parameter '{}'", ParamName).str(),
1545parseBoundsCheckingOptions(
StringRef Params) {
1547 while (!Params.
empty()) {
1549 std::tie(ParamName, Params) = Params.
split(
';');
1550 if (ParamName ==
"trap") {
1552 }
else if (ParamName ==
"rt") {
1557 }
else if (ParamName ==
"rt-abort") {
1562 }
else if (ParamName ==
"min-rt") {
1567 }
else if (ParamName ==
"min-rt-abort") {
1572 }
else if (ParamName ==
"merge") {
1577 std::tie(ParamEQ, Val) = ParamName.
split(
'=');
1583 formatv(
"invalid BoundsChecking pass parameter '{}'", ParamName)
1600 if (!
Prefix.empty() || Digit.getAsInteger(10,
N))
1602 Param.str().c_str());
1605 if (!
Level.has_value())
1607 "invalid optimization level for expand-fp pass: %s",
1608 Digit.str().c_str());
1615 if (Params.
empty() || Params ==
"all")
1616 return RAGreedyPass::Options();
1620 return RAGreedyPass::Options{*
Filter, Params};
1623 formatv(
"invalid regallocgreedy register filter '{}'", Params).str(),
1629 "MachineSinkingPass");
1633 bool AllowTailMerge =
true;
1634 if (!Params.
empty()) {
1636 if (Params !=
"tail-merge")
1638 formatv(
"invalid MachineBlockPlacementPass parameter '{}'", Params)
1642 return AllowTailMerge;
1646 bool ClearVirtRegs =
true;
1647 if (!Params.
empty()) {
1649 if (Params !=
"clear-vregs")
1651 formatv(
"invalid VirtRegRewriter pass parameter '{}'", Params).str(),
1654 return ClearVirtRegs;
1657struct FatLTOOptions {
1658 OptimizationLevel OptLevel;
1659 bool ThinLTO =
false;
1660 bool EmitSummary =
false;
1665 bool HaveOptLevel =
false;
1666 while (!Params.
empty()) {
1668 std::tie(ParamName, Params) = Params.
split(
';');
1670 if (ParamName ==
"thinlto") {
1672 }
else if (ParamName ==
"emit-summary") {
1673 Result.EmitSummary =
true;
1674 }
else if (std::optional<OptimizationLevel> OptLevel =
1676 Result.OptLevel = *OptLevel;
1677 HaveOptLevel =
true;
1680 formatv(
"invalid fatlto-pre-link pass parameter '{}'", ParamName)
1687 "missing optimization level for fatlto-pre-link pipeline",
1702template <
typename PassManagerT,
typename CallbacksT>
1704 if (!Callbacks.empty()) {
1705 PassManagerT DummyPM;
1706 for (
auto &CB : Callbacks)
1707 if (CB(Name, DummyPM, {}))
1713template <
typename CallbacksT>
1715 StringRef NameNoBracket = Name.take_until([](
char C) {
return C ==
'<'; });
1718 if (Name ==
"module")
1720 if (Name ==
"cgscc")
1722 if (NameNoBracket ==
"function")
1724 if (Name ==
"coro-cond")
1727#define MODULE_PASS(NAME, CREATE_PASS) \
1730#define MODULE_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1731 if (PassBuilder::checkParametrizedPassName(Name, NAME)) \
1733#define MODULE_ANALYSIS(NAME, CREATE_PASS) \
1734 if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
1736#include "PassRegistry.def"
1741template <
typename CallbacksT>
1744 StringRef NameNoBracket = Name.take_until([](
char C) {
return C ==
'<'; });
1745 if (Name ==
"cgscc")
1747 if (NameNoBracket ==
"function")
1754#define CGSCC_PASS(NAME, CREATE_PASS) \
1757#define CGSCC_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1758 if (PassBuilder::checkParametrizedPassName(Name, NAME)) \
1760#define CGSCC_ANALYSIS(NAME, CREATE_PASS) \
1761 if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
1763#include "PassRegistry.def"
1768template <
typename CallbacksT>
1771 StringRef NameNoBracket = Name.take_until([](
char C) {
return C ==
'<'; });
1772 if (NameNoBracket ==
"function")
1774 if (Name ==
"loop" || Name ==
"loop-mssa" || Name ==
"machine-function")
1777#define FUNCTION_PASS(NAME, CREATE_PASS) \
1780#define FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1781 if (PassBuilder::checkParametrizedPassName(Name, NAME)) \
1783#define FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
1784 if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
1786#include "PassRegistry.def"
1791template <
typename CallbacksT>
1794 if (Name ==
"machine-function")
1797#define MACHINE_FUNCTION_PASS(NAME, CREATE_PASS) \
1800#define MACHINE_FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, \
1802 if (PassBuilder::checkParametrizedPassName(Name, NAME)) \
1805#define MACHINE_FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
1806 if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
1809#include "llvm/Passes/MachinePassRegistry.def"
1814template <
typename CallbacksT>
1816 bool &UseMemorySSA) {
1817 UseMemorySSA =
false;
1820 UseMemorySSA =
true;
1824#define LOOPNEST_PASS(NAME, CREATE_PASS) \
1827#include "PassRegistry.def"
1832template <
typename CallbacksT>
1834 bool &UseMemorySSA) {
1835 UseMemorySSA =
false;
1838 UseMemorySSA =
true;
1842#define LOOP_PASS(NAME, CREATE_PASS) \
1845#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1846 if (PassBuilder::checkParametrizedPassName(Name, NAME)) \
1848#define LOOP_ANALYSIS(NAME, CREATE_PASS) \
1849 if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
1851#include "PassRegistry.def"
1856std::optional<std::vector<PassBuilder::PipelineElement>>
1857PassBuilder::parsePipelineText(
StringRef Text) {
1858 std::vector<PipelineElement> ResultPipeline;
1863 std::vector<PipelineElement> &Pipeline = *PipelineStack.
back();
1864 size_t Pos =
Text.find_first_of(
",()");
1865 Pipeline.push_back({
Text.substr(0, Pos), {}});
1868 if (Pos ==
Text.npos)
1871 char Sep =
Text[Pos];
1879 PipelineStack.
push_back(&Pipeline.back().InnerPipeline);
1883 assert(Sep ==
')' &&
"Bogus separator!");
1888 if (PipelineStack.
size() == 1)
1889 return std::nullopt;
1892 }
while (
Text.consume_front(
")"));
1900 if (!
Text.consume_front(
","))
1901 return std::nullopt;
1904 if (PipelineStack.
size() > 1)
1906 return std::nullopt;
1908 assert(PipelineStack.
back() == &ResultPipeline &&
1909 "Wrong pipeline at the bottom of the stack!");
1910 return {std::move(ResultPipeline)};
1923 const PipelineElement &
E) {
1924 auto &
Name =
E.Name;
1925 auto &InnerPipeline =
E.InnerPipeline;
1928 if (!InnerPipeline.empty()) {
1929 if (Name ==
"module") {
1931 if (
auto Err = parseModulePassPipeline(NestedMPM, InnerPipeline))
1933 MPM.
addPass(std::move(NestedMPM));
1936 if (Name ==
"coro-cond") {
1938 if (
auto Err = parseModulePassPipeline(NestedMPM, InnerPipeline))
1940 MPM.
addPass(CoroConditionalWrapper(std::move(NestedMPM)));
1943 if (Name ==
"cgscc") {
1945 if (
auto Err = parseCGSCCPassPipeline(CGPM, InnerPipeline))
1953 "cannot have a no-rerun module to function adaptor",
1956 if (
auto Err = parseFunctionPassPipeline(FPM, InnerPipeline))
1963 for (
auto &
C : ModulePipelineParsingCallbacks)
1964 if (
C(Name, MPM, InnerPipeline))
1969 formatv(
"invalid use of '{}' pass as module pipeline", Name).str(),
1975#define MODULE_PASS(NAME, CREATE_PASS) \
1976 if (Name == NAME) { \
1977 MPM.addPass(CREATE_PASS); \
1978 return Error::success(); \
1980#define MODULE_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1981 if (checkParametrizedPassName(Name, NAME)) { \
1982 auto Params = parsePassParameters(PARSER, Name, NAME); \
1984 return Params.takeError(); \
1985 MPM.addPass(CREATE_PASS(Params.get())); \
1986 return Error::success(); \
1988#define MODULE_ANALYSIS(NAME, CREATE_PASS) \
1989 if (Name == "require<" NAME ">") { \
1991 RequireAnalysisPass< \
1992 std::remove_reference_t<decltype(CREATE_PASS)>, Module>()); \
1993 return Error::success(); \
1995 if (Name == "invalidate<" NAME ">") { \
1996 MPM.addPass(InvalidateAnalysisPass< \
1997 std::remove_reference_t<decltype(CREATE_PASS)>>()); \
1998 return Error::success(); \
2000#define CGSCC_PASS(NAME, CREATE_PASS) \
2001 if (Name == NAME) { \
2002 MPM.addPass(createModuleToPostOrderCGSCCPassAdaptor(CREATE_PASS)); \
2003 return Error::success(); \
2005#define CGSCC_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
2006 if (checkParametrizedPassName(Name, NAME)) { \
2007 auto Params = parsePassParameters(PARSER, Name, NAME); \
2009 return Params.takeError(); \
2011 createModuleToPostOrderCGSCCPassAdaptor(CREATE_PASS(Params.get()))); \
2012 return Error::success(); \
2014#define FUNCTION_PASS(NAME, CREATE_PASS) \
2015 if (Name == NAME) { \
2016 MPM.addPass(createModuleToFunctionPassAdaptor(CREATE_PASS)); \
2017 return Error::success(); \
2019#define FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
2020 if (checkParametrizedPassName(Name, NAME)) { \
2021 auto Params = parsePassParameters(PARSER, Name, NAME); \
2023 return Params.takeError(); \
2024 MPM.addPass(createModuleToFunctionPassAdaptor(CREATE_PASS(Params.get()))); \
2025 return Error::success(); \
2027#define LOOPNEST_PASS(NAME, CREATE_PASS) \
2028 if (Name == NAME) { \
2029 MPM.addPass(createModuleToFunctionPassAdaptor( \
2030 createFunctionToLoopPassAdaptor(CREATE_PASS, false, false))); \
2031 return Error::success(); \
2033#define LOOP_PASS(NAME, CREATE_PASS) \
2034 if (Name == NAME) { \
2035 MPM.addPass(createModuleToFunctionPassAdaptor( \
2036 createFunctionToLoopPassAdaptor(CREATE_PASS, false, false))); \
2037 return Error::success(); \
2039#define LOOP_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(); \
2045 createModuleToFunctionPassAdaptor(createFunctionToLoopPassAdaptor( \
2046 CREATE_PASS(Params.get()), false, false))); \
2047 return Error::success(); \
2049#include "PassRegistry.def"
2051 for (
auto &
C : ModulePipelineParsingCallbacks)
2052 if (
C(Name, MPM, InnerPipeline))
2055 formatv(
"unknown module pass '{}'", Name).str(),
2060 const PipelineElement &
E) {
2061 auto &
Name =
E.Name;
2062 auto &InnerPipeline =
E.InnerPipeline;
2065 if (!InnerPipeline.empty()) {
2066 if (Name ==
"cgscc") {
2068 if (
auto Err = parseCGSCCPassPipeline(NestedCGPM, InnerPipeline))
2071 CGPM.
addPass(std::move(NestedCGPM));
2076 if (
auto Err = parseFunctionPassPipeline(FPM, InnerPipeline))
2080 std::move(FPM), Params->first, Params->second));
2085 if (
auto Err = parseCGSCCPassPipeline(NestedCGPM, InnerPipeline))
2092 for (
auto &
C : CGSCCPipelineParsingCallbacks)
2093 if (
C(Name, CGPM, InnerPipeline))
2098 formatv(
"invalid use of '{}' pass as cgscc pipeline", Name).str(),
2103#define CGSCC_PASS(NAME, CREATE_PASS) \
2104 if (Name == NAME) { \
2105 CGPM.addPass(CREATE_PASS); \
2106 return Error::success(); \
2108#define CGSCC_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
2109 if (checkParametrizedPassName(Name, NAME)) { \
2110 auto Params = parsePassParameters(PARSER, Name, NAME); \
2112 return Params.takeError(); \
2113 CGPM.addPass(CREATE_PASS(Params.get())); \
2114 return Error::success(); \
2116#define CGSCC_ANALYSIS(NAME, CREATE_PASS) \
2117 if (Name == "require<" NAME ">") { \
2118 CGPM.addPass(RequireAnalysisPass< \
2119 std::remove_reference_t<decltype(CREATE_PASS)>, \
2120 LazyCallGraph::SCC, CGSCCAnalysisManager, LazyCallGraph &, \
2121 CGSCCUpdateResult &>()); \
2122 return Error::success(); \
2124 if (Name == "invalidate<" NAME ">") { \
2125 CGPM.addPass(InvalidateAnalysisPass< \
2126 std::remove_reference_t<decltype(CREATE_PASS)>>()); \
2127 return Error::success(); \
2129#define FUNCTION_PASS(NAME, CREATE_PASS) \
2130 if (Name == NAME) { \
2131 CGPM.addPass(createCGSCCToFunctionPassAdaptor(CREATE_PASS)); \
2132 return Error::success(); \
2134#define FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
2135 if (checkParametrizedPassName(Name, NAME)) { \
2136 auto Params = parsePassParameters(PARSER, Name, NAME); \
2138 return Params.takeError(); \
2139 CGPM.addPass(createCGSCCToFunctionPassAdaptor(CREATE_PASS(Params.get()))); \
2140 return Error::success(); \
2142#define LOOPNEST_PASS(NAME, CREATE_PASS) \
2143 if (Name == NAME) { \
2144 CGPM.addPass(createCGSCCToFunctionPassAdaptor( \
2145 createFunctionToLoopPassAdaptor(CREATE_PASS, false, false))); \
2146 return Error::success(); \
2148#define LOOP_PASS(NAME, CREATE_PASS) \
2149 if (Name == NAME) { \
2150 CGPM.addPass(createCGSCCToFunctionPassAdaptor( \
2151 createFunctionToLoopPassAdaptor(CREATE_PASS, false, false))); \
2152 return Error::success(); \
2154#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
2155 if (checkParametrizedPassName(Name, NAME)) { \
2156 auto Params = parsePassParameters(PARSER, Name, NAME); \
2158 return Params.takeError(); \
2160 createCGSCCToFunctionPassAdaptor(createFunctionToLoopPassAdaptor( \
2161 CREATE_PASS(Params.get()), false, false))); \
2162 return Error::success(); \
2164#include "PassRegistry.def"
2166 for (
auto &
C : CGSCCPipelineParsingCallbacks)
2167 if (
C(Name, CGPM, InnerPipeline))
2174 const PipelineElement &
E) {
2175 auto &
Name =
E.Name;
2176 auto &InnerPipeline =
E.InnerPipeline;
2179 if (!InnerPipeline.empty()) {
2180 if (Name ==
"function") {
2182 if (
auto Err = parseFunctionPassPipeline(NestedFPM, InnerPipeline))
2185 FPM.
addPass(std::move(NestedFPM));
2188 if (Name ==
"loop" || Name ==
"loop-mssa") {
2190 if (
auto Err = parseLoopPassPipeline(LPM, InnerPipeline))
2193 bool UseMemorySSA = (
Name ==
"loop-mssa");
2195 return Pipeline.Name.contains(
"simple-loop-unswitch");
2201 if (Name ==
"machine-function") {
2203 if (
auto Err = parseMachinePassPipeline(MFPM, InnerPipeline))
2209 for (
auto &
C : FunctionPipelineParsingCallbacks)
2210 if (
C(Name, FPM, InnerPipeline))
2215 formatv(
"invalid use of '{}' pass as function pipeline", Name).str(),
2220#define FUNCTION_PASS(NAME, CREATE_PASS) \
2221 if (Name == NAME) { \
2222 FPM.addPass(CREATE_PASS); \
2223 return Error::success(); \
2225#define FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
2226 if (checkParametrizedPassName(Name, NAME)) { \
2227 auto Params = parsePassParameters(PARSER, Name, NAME); \
2229 return Params.takeError(); \
2230 FPM.addPass(CREATE_PASS(Params.get())); \
2231 return Error::success(); \
2233#define FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
2234 if (Name == "require<" NAME ">") { \
2236 RequireAnalysisPass< \
2237 std::remove_reference_t<decltype(CREATE_PASS)>, Function>()); \
2238 return Error::success(); \
2240 if (Name == "invalidate<" NAME ">") { \
2241 FPM.addPass(InvalidateAnalysisPass< \
2242 std::remove_reference_t<decltype(CREATE_PASS)>>()); \
2243 return Error::success(); \
2249#define LOOPNEST_PASS(NAME, CREATE_PASS) \
2250 if (Name == NAME) { \
2251 FPM.addPass(createFunctionToLoopPassAdaptor(CREATE_PASS, false, false)); \
2252 return Error::success(); \
2254#define LOOP_PASS(NAME, CREATE_PASS) \
2255 if (Name == NAME) { \
2256 FPM.addPass(createFunctionToLoopPassAdaptor(CREATE_PASS, false, false)); \
2257 return Error::success(); \
2259#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
2260 if (checkParametrizedPassName(Name, NAME)) { \
2261 auto Params = parsePassParameters(PARSER, Name, NAME); \
2263 return Params.takeError(); \
2264 FPM.addPass(createFunctionToLoopPassAdaptor(CREATE_PASS(Params.get()), \
2266 return Error::success(); \
2268#include "PassRegistry.def"
2270 for (
auto &
C : FunctionPipelineParsingCallbacks)
2271 if (
C(Name, FPM, InnerPipeline))
2274 formatv(
"unknown function pass '{}'", Name).str(),
2279 const PipelineElement &
E) {
2280 StringRef
Name =
E.Name;
2281 auto &InnerPipeline =
E.InnerPipeline;
2284 if (!InnerPipeline.empty()) {
2285 if (Name ==
"loop") {
2287 if (
auto Err = parseLoopPassPipeline(NestedLPM, InnerPipeline))
2290 LPM.addPass(std::move(NestedLPM));
2294 for (
auto &
C : LoopPipelineParsingCallbacks)
2295 if (
C(Name, LPM, InnerPipeline))
2300 formatv(
"invalid use of '{}' pass as loop pipeline", Name).str(),
2305#define LOOPNEST_PASS(NAME, CREATE_PASS) \
2306 if (Name == NAME) { \
2307 LPM.addPass(CREATE_PASS); \
2308 return Error::success(); \
2310#define LOOP_PASS(NAME, CREATE_PASS) \
2311 if (Name == NAME) { \
2312 LPM.addPass(CREATE_PASS); \
2313 return Error::success(); \
2315#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
2316 if (checkParametrizedPassName(Name, NAME)) { \
2317 auto Params = parsePassParameters(PARSER, Name, NAME); \
2319 return Params.takeError(); \
2320 LPM.addPass(CREATE_PASS(Params.get())); \
2321 return Error::success(); \
2323#define LOOP_ANALYSIS(NAME, CREATE_PASS) \
2324 if (Name == "require<" NAME ">") { \
2325 LPM.addPass(RequireAnalysisPass< \
2326 std::remove_reference_t<decltype(CREATE_PASS)>, Loop, \
2327 LoopAnalysisManager, LoopStandardAnalysisResults &, \
2329 return Error::success(); \
2331 if (Name == "invalidate<" NAME ">") { \
2332 LPM.addPass(InvalidateAnalysisPass< \
2333 std::remove_reference_t<decltype(CREATE_PASS)>>()); \
2334 return Error::success(); \
2336#include "PassRegistry.def"
2338 for (
auto &
C : LoopPipelineParsingCallbacks)
2339 if (
C(Name, LPM, InnerPipeline))
2346 const PipelineElement &
E) {
2347 StringRef
Name =
E.Name;
2349 if (!
E.InnerPipeline.empty()) {
2350 if (
E.Name ==
"machine-function") {
2352 if (
auto Err = parseMachinePassPipeline(NestedPM,
E.InnerPipeline))
2354 MFPM.
addPass(std::move(NestedPM));
2361#define MACHINE_MODULE_PASS(NAME, CREATE_PASS) \
2362 if (Name == NAME) { \
2363 MFPM.addPass(CREATE_PASS); \
2364 return Error::success(); \
2366#define MACHINE_FUNCTION_PASS(NAME, CREATE_PASS) \
2367 if (Name == NAME) { \
2368 MFPM.addPass(CREATE_PASS); \
2369 return Error::success(); \
2371#define MACHINE_FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, \
2373 if (checkParametrizedPassName(Name, NAME)) { \
2374 auto Params = parsePassParameters(PARSER, Name, NAME); \
2376 return Params.takeError(); \
2377 MFPM.addPass(CREATE_PASS(Params.get())); \
2378 return Error::success(); \
2380#define MACHINE_FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
2381 if (Name == "require<" NAME ">") { \
2383 RequireAnalysisPass<std::remove_reference_t<decltype(CREATE_PASS)>, \
2384 MachineFunction>()); \
2385 return Error::success(); \
2387 if (Name == "invalidate<" NAME ">") { \
2388 MFPM.addPass(InvalidateAnalysisPass< \
2389 std::remove_reference_t<decltype(CREATE_PASS)>>()); \
2390 return Error::success(); \
2392#include "llvm/Passes/MachinePassRegistry.def"
2394 for (
auto &
C : MachineFunctionPipelineParsingCallbacks)
2395 if (
C(Name, MFPM,
E.InnerPipeline))
2398 formatv(
"unknown machine pass '{}'", Name).str(),
2403#define MODULE_ALIAS_ANALYSIS(NAME, CREATE_PASS) \
2404 if (Name == NAME) { \
2405 AA.registerModuleAnalysis< \
2406 std::remove_reference_t<decltype(CREATE_PASS)>>(); \
2409#define FUNCTION_ALIAS_ANALYSIS(NAME, CREATE_PASS) \
2410 if (Name == NAME) { \
2411 AA.registerFunctionAnalysis< \
2412 std::remove_reference_t<decltype(CREATE_PASS)>>(); \
2415#include "PassRegistry.def"
2417 for (
auto &
C : AAParsingCallbacks)
2423Error PassBuilder::parseMachinePassPipeline(
2425 for (
const auto &Element : Pipeline) {
2426 if (
auto Err = parseMachinePass(MFPM, Element))
2434 for (
const auto &Element : Pipeline) {
2435 if (
auto Err = parseLoopPass(LPM, Element))
2441Error PassBuilder::parseFunctionPassPipeline(
2443 for (
const auto &Element : Pipeline) {
2444 if (
auto Err = parseFunctionPass(FPM, Element))
2452 for (
const auto &Element : Pipeline) {
2453 if (
auto Err = parseCGSCCPass(CGPM, Element))
2485 for (
const auto &Element : Pipeline) {
2486 if (
auto Err = parseModulePass(MPM, Element))
2497 auto Pipeline = parsePipelineText(PipelineText);
2498 if (!Pipeline || Pipeline->empty())
2500 formatv(
"invalid pipeline '{}'", PipelineText).str(),
2510 Pipeline = {{
"cgscc", std::move(*Pipeline)}};
2512 FunctionPipelineParsingCallbacks)) {
2513 Pipeline = {{
"function", std::move(*Pipeline)}};
2516 Pipeline = {{
"function", {{UseMemorySSA ?
"loop-mssa" :
"loop",
2517 std::move(*Pipeline)}}}};
2518 }
else if (
isLoopPassName(FirstName, LoopPipelineParsingCallbacks,
2520 Pipeline = {{
"function", {{UseMemorySSA ?
"loop-mssa" :
"loop",
2521 std::move(*Pipeline)}}}};
2523 FirstName, MachineFunctionPipelineParsingCallbacks)) {
2524 Pipeline = {{
"function", {{
"machine-function", std::move(*Pipeline)}}}};
2526 for (
auto &
C : TopLevelPipelineParsingCallbacks)
2527 if (
C(MPM, *Pipeline))
2531 auto &InnerPipeline = Pipeline->front().InnerPipeline;
2533 formatv(
"unknown {} name '{}'",
2534 (InnerPipeline.empty() ?
"pass" :
"pipeline"), FirstName)
2540 if (
auto Err = parseModulePassPipeline(MPM, *Pipeline))
2548 auto Pipeline = parsePipelineText(PipelineText);
2549 if (!Pipeline || Pipeline->empty())
2551 formatv(
"invalid pipeline '{}'", PipelineText).str(),
2557 formatv(
"unknown cgscc pass '{}' in pipeline '{}'", FirstName,
2562 if (
auto Err = parseCGSCCPassPipeline(CGPM, *Pipeline))
2571 auto Pipeline = parsePipelineText(PipelineText);
2572 if (!Pipeline || Pipeline->empty())
2574 formatv(
"invalid pipeline '{}'", PipelineText).str(),
2580 formatv(
"unknown function pass '{}' in pipeline '{}'", FirstName,
2585 if (
auto Err = parseFunctionPassPipeline(FPM, *Pipeline))
2593 auto Pipeline = parsePipelineText(PipelineText);
2594 if (!Pipeline || Pipeline->empty())
2596 formatv(
"invalid pipeline '{}'", PipelineText).str(),
2599 if (
auto Err = parseLoopPassPipeline(CGPM, *Pipeline))
2607 auto Pipeline = parsePipelineText(PipelineText);
2608 if (!Pipeline || Pipeline->empty())
2610 formatv(
"invalid machine pass pipeline '{}'", PipelineText).str(),
2613 if (
auto Err = parseMachinePassPipeline(MFPM, *Pipeline))
2622 if (PipelineText ==
"default") {
2627 while (!PipelineText.
empty()) {
2629 std::tie(Name, PipelineText) = PipelineText.
split(
',');
2630 if (!parseAAPassName(
AA, Name))
2632 formatv(
"unknown alias analysis name '{}'", Name).str(),
2639std::optional<RegAllocFilterFunc>
2641 if (FilterName ==
"all")
2643 for (
auto &
C : RegClassFilterParsingCallbacks)
2644 if (
auto F =
C(FilterName))
2646 return std::nullopt;
2654 OS <<
" " <<
PassName <<
"<" << Params <<
">\n";
2660 OS <<
"Module passes:\n";
2661#define MODULE_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2662#include "PassRegistry.def"
2664 OS <<
"Module passes with params:\n";
2665#define MODULE_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
2666 printPassName(NAME, PARAMS, OS);
2667#include "PassRegistry.def"
2669 OS <<
"Module analyses:\n";
2670#define MODULE_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2671#include "PassRegistry.def"
2673 OS <<
"Module alias analyses:\n";
2674#define MODULE_ALIAS_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2675#include "PassRegistry.def"
2677 OS <<
"CGSCC passes:\n";
2678#define CGSCC_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2679#include "PassRegistry.def"
2681 OS <<
"CGSCC passes with params:\n";
2682#define CGSCC_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
2683 printPassName(NAME, PARAMS, OS);
2684#include "PassRegistry.def"
2686 OS <<
"CGSCC analyses:\n";
2687#define CGSCC_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2688#include "PassRegistry.def"
2690 OS <<
"Function passes:\n";
2691#define FUNCTION_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2692#include "PassRegistry.def"
2694 OS <<
"Function passes with params:\n";
2695#define FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
2696 printPassName(NAME, PARAMS, OS);
2697#include "PassRegistry.def"
2699 OS <<
"Function analyses:\n";
2700#define FUNCTION_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2701#include "PassRegistry.def"
2703 OS <<
"Function alias analyses:\n";
2704#define FUNCTION_ALIAS_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2705#include "PassRegistry.def"
2707 OS <<
"LoopNest passes:\n";
2708#define LOOPNEST_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2709#include "PassRegistry.def"
2711 OS <<
"Loop passes:\n";
2712#define LOOP_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2713#include "PassRegistry.def"
2715 OS <<
"Loop passes with params:\n";
2716#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
2717 printPassName(NAME, PARAMS, OS);
2718#include "PassRegistry.def"
2720 OS <<
"Loop analyses:\n";
2721#define LOOP_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2722#include "PassRegistry.def"
2724 OS <<
"Machine module passes (WIP):\n";
2725#define MACHINE_MODULE_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2726#include "llvm/Passes/MachinePassRegistry.def"
2728 OS <<
"Machine function passes (WIP):\n";
2729#define MACHINE_FUNCTION_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2730#include "llvm/Passes/MachinePassRegistry.def"
2732 OS <<
"Machine function analyses (WIP):\n";
2733#define MACHINE_FUNCTION_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2734#include "llvm/Passes/MachinePassRegistry.def"
2740 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