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,
508 : TM(TM), PTO(PTO), PGOOpt(PGOOpt), PIC(PIC) {
510 TM->registerPassBuilderCallbacks(*
this);
512 PIC->registerClassToPassNameCallback([
this, PIC]() {
516#define MODULE_PASS(NAME, CREATE_PASS) \
517 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
518#define MODULE_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
519 PIC->addClassToPassName(CLASS, NAME);
520#define MODULE_ANALYSIS(NAME, CREATE_PASS) \
521 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
522#define FUNCTION_PASS(NAME, CREATE_PASS) \
523 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
524#define FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
525 PIC->addClassToPassName(CLASS, NAME);
526#define FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
527 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
528#define LOOPNEST_PASS(NAME, CREATE_PASS) \
529 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
530#define LOOP_PASS(NAME, CREATE_PASS) \
531 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
532#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
533 PIC->addClassToPassName(CLASS, NAME);
534#define LOOP_ANALYSIS(NAME, CREATE_PASS) \
535 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
536#define CGSCC_PASS(NAME, CREATE_PASS) \
537 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
538#define CGSCC_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
539 PIC->addClassToPassName(CLASS, NAME);
540#define CGSCC_ANALYSIS(NAME, CREATE_PASS) \
541 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
542#include "PassRegistry.def"
544#define MACHINE_FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
545 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
546#define MACHINE_FUNCTION_PASS(NAME, CREATE_PASS) \
547 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
548#define MACHINE_FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, \
550 PIC->addClassToPassName(CLASS, NAME);
551#include "llvm/Passes/MachinePassRegistry.def"
559#define MODULE_CALLBACK(NAME, INVOKE) \
560 if (PassBuilder::checkParametrizedPassName(Name, NAME)) { \
561 auto L = PassBuilder::parsePassParameters(parseOptLevelParam, Name, NAME); \
563 errs() << NAME ": " << toString(L.takeError()) << '\n'; \
566 INVOKE(PM, L.get()); \
569#include "PassRegistry.def"
577#define MODULE_LTO_CALLBACK(NAME, INVOKE) \
578 if (PassBuilder::checkParametrizedPassName(Name, NAME)) { \
579 auto L = PassBuilder::parsePassParameters(parseOptLevelParam, Name, NAME); \
581 errs() << NAME ": " << toString(L.takeError()) << '\n'; \
584 INVOKE(PM, L.get(), ThinOrFullLTOPhase::None); \
587#include "PassRegistry.def"
595#define FUNCTION_CALLBACK(NAME, INVOKE) \
596 if (PassBuilder::checkParametrizedPassName(Name, NAME)) { \
597 auto L = PassBuilder::parsePassParameters(parseOptLevelParam, Name, NAME); \
599 errs() << NAME ": " << toString(L.takeError()) << '\n'; \
602 INVOKE(PM, L.get()); \
605#include "PassRegistry.def"
613#define CGSCC_CALLBACK(NAME, INVOKE) \
614 if (PassBuilder::checkParametrizedPassName(Name, NAME)) { \
615 auto L = PassBuilder::parsePassParameters(parseOptLevelParam, Name, NAME); \
617 errs() << NAME ": " << toString(L.takeError()) << '\n'; \
620 INVOKE(PM, L.get()); \
623#include "PassRegistry.def"
631#define LOOP_CALLBACK(NAME, INVOKE) \
632 if (PassBuilder::checkParametrizedPassName(Name, NAME)) { \
633 auto L = PassBuilder::parsePassParameters(parseOptLevelParam, Name, NAME); \
635 errs() << NAME ": " << toString(L.takeError()) << '\n'; \
638 INVOKE(PM, L.get()); \
641#include "PassRegistry.def"
647#define MODULE_ANALYSIS(NAME, CREATE_PASS) \
648 MAM.registerPass([&] { return CREATE_PASS; });
649#include "PassRegistry.def"
651 for (
auto &
C : ModuleAnalysisRegistrationCallbacks)
656#define CGSCC_ANALYSIS(NAME, CREATE_PASS) \
657 CGAM.registerPass([&] { return CREATE_PASS; });
658#include "PassRegistry.def"
660 for (
auto &
C : CGSCCAnalysisRegistrationCallbacks)
670#define FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
671 FAM.registerPass([&] { return CREATE_PASS; });
672#include "PassRegistry.def"
674 for (
auto &
C : FunctionAnalysisRegistrationCallbacks)
681#define MACHINE_FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
682 MFAM.registerPass([&] { return CREATE_PASS; });
683#include "llvm/Passes/MachinePassRegistry.def"
685 for (
auto &
C : MachineFunctionAnalysisRegistrationCallbacks)
690#define LOOP_ANALYSIS(NAME, CREATE_PASS) \
691 LAM.registerPass([&] { return CREATE_PASS; });
692#include "PassRegistry.def"
694 for (
auto &
C : LoopAnalysisRegistrationCallbacks)
698static std::optional<std::pair<bool, bool>>
700 std::pair<bool, bool> Params;
701 if (!Name.consume_front(
"function"))
705 if (!Name.consume_front(
"<") || !Name.consume_back(
">"))
707 while (!Name.empty()) {
708 auto [Front, Back] = Name.split(
';');
710 if (Front ==
"eager-inv")
712 else if (Front ==
"no-rerun")
713 Params.second =
true;
721 if (!Name.consume_front(
"devirt<") || !Name.consume_back(
">"))
733 while (!Params.
empty()) {
735 std::tie(ParamName, Params) = Params.
split(
';');
737 if (ParamName == OptionName) {
754 while (!Params.
empty()) {
756 std::tie(ParamName, Params) = Params.
split(
';');
761 formatv(
"invalid HardwareLoopPass parameter '{}'", ParamName).str(),
766 if (ParamName.
consume_front(
"hardware-loop-counter-bitwidth=")) {
770 formatv(
"invalid HardwareLoopPass parameter '{}'", ParamName).str(),
775 if (ParamName ==
"force-hardware-loops") {
777 }
else if (ParamName ==
"force-hardware-loop-phi") {
779 }
else if (ParamName ==
"force-nested-hardware-loop") {
781 }
else if (ParamName ==
"force-hardware-loop-guard") {
785 formatv(
"invalid HardwarePass parameter '{}'", ParamName).str(),
789 return HardwareLoopOpts;
801 while (!Params.
empty()) {
803 std::tie(ParamName, Params) = Params.
split(
';');
804 std::optional<OptimizationLevel> OptLevel =
parseOptLevel(ParamName);
806 if (OptLevel && !OptLevel->isOptimizingForSize()) {
807 UnrollOpts.
setOptLevel(OptLevel->getSpeedupLevel());
814 formatv(
"invalid LoopUnrollPass parameter '{}'", ParamName).str(),
821 if (ParamName ==
"partial") {
823 }
else if (ParamName ==
"peeling") {
825 }
else if (ParamName ==
"profile-peeling") {
827 }
else if (ParamName ==
"runtime") {
829 }
else if (ParamName ==
"upperbound") {
833 formatv(
"invalid LoopUnrollPass parameter '{}'", ParamName).str(),
842 Params,
"vfe-linkage-unit-visibility",
"GlobalDCE");
862 Params,
"skip-non-recursive-function-attrs",
"PostOrderFunctionAttrs");
872 formatv(
"too many CFGuardPass parameters '{}'", Params).str(),
875 if (Param ==
"check")
877 if (Param ==
"dispatch")
881 formatv(
"invalid CFGuardPass mechanism: '{}'", Param).str(),
891 "EntryExitInstrumenter");
900 "LowerMatrixIntrinsics");
905 while (!Params.
empty()) {
907 std::tie(ParamName, Params) = Params.
split(
';');
910 if (ParamName ==
"preserve-order")
912 else if (ParamName ==
"rename-all")
914 else if (ParamName ==
"fold-all")
916 else if (ParamName ==
"reorder-operands")
920 formatv(
"invalid normalize pass parameter '{}'", ParamName).str(),
930 while (!Params.
empty()) {
932 std::tie(ParamName, Params) = Params.
split(
';');
934 if (ParamName ==
"kernel") {
935 Result.CompileKernel =
true;
936 }
else if (ParamName ==
"use-after-scope") {
937 Result.UseAfterScope =
true;
940 formatv(
"invalid AddressSanitizer pass parameter '{}'", ParamName)
950 while (!Params.
empty()) {
952 std::tie(ParamName, Params) = Params.
split(
';');
954 if (ParamName ==
"recover") {
956 }
else if (ParamName ==
"kernel") {
957 Result.CompileKernel =
true;
960 formatv(
"invalid HWAddressSanitizer pass parameter '{}'", ParamName)
970 while (!Params.
empty()) {
972 std::tie(ParamName, Params) = Params.
split(
';');
974 if (ParamName ==
"thinlto") {
976 }
else if (ParamName ==
"emit-summary") {
977 Result.EmitLTOSummary =
true;
980 formatv(
"invalid EmbedBitcode pass parameter '{}'", ParamName).str(),
988parseLowerAllowCheckPassOptions(
StringRef Params) {
990 while (!Params.
empty()) {
992 std::tie(ParamName, Params) = Params.
split(
';');
1003 std::tie(IndicesStr, CutoffStr) = ParamName.
split(
"]=");
1010 formatv(
"invalid LowerAllowCheck pass cutoffs parameter '{}' ({})",
1015 if (!IndicesStr.
consume_front(
"cutoffs[") || IndicesStr ==
"")
1017 formatv(
"invalid LowerAllowCheck pass index parameter '{}' ({})",
1018 IndicesStr, CutoffStr)
1022 while (IndicesStr !=
"") {
1024 std::tie(firstIndexStr, IndicesStr) = IndicesStr.
split(
'|');
1030 "invalid LowerAllowCheck pass index parameter '{}' ({}) {}",
1031 firstIndexStr, IndicesStr)
1038 if (index >=
Result.cutoffs.size())
1039 Result.cutoffs.resize(index + 1, 0);
1041 Result.cutoffs[index] = cutoff;
1043 }
else if (ParamName.
starts_with(
"runtime_check")) {
1045 std::tie(std::ignore, ValueString) = ParamName.
split(
"=");
1049 formatv(
"invalid LowerAllowCheck pass runtime_check parameter '{}' "
1051 ValueString, Params)
1055 Result.runtime_check = runtime_check;
1058 formatv(
"invalid LowerAllowCheck pass parameter '{}'", ParamName)
1069 while (!Params.
empty()) {
1071 std::tie(ParamName, Params) = Params.
split(
';');
1073 if (ParamName ==
"recover") {
1075 }
else if (ParamName ==
"kernel") {
1080 formatv(
"invalid argument to MemorySanitizer pass track-origins "
1085 }
else if (ParamName ==
"eager-checks") {
1086 Result.EagerChecks =
true;
1089 formatv(
"invalid MemorySanitizer pass parameter '{}'", ParamName)
1100 while (!Params.
empty()) {
1102 std::tie(ParamName, Params) = Params.
split(
';');
1105 if (ParamName ==
"speculate-blocks") {
1107 }
else if (ParamName ==
"simplify-cond-branch") {
1109 }
else if (ParamName ==
"forward-switch-cond") {
1111 }
else if (ParamName ==
"switch-range-to-icmp") {
1113 }
else if (ParamName ==
"switch-to-lookup") {
1115 }
else if (ParamName ==
"keep-loops") {
1117 }
else if (ParamName ==
"hoist-common-insts") {
1119 }
else if (ParamName ==
"hoist-loads-stores-with-cond-faulting") {
1121 }
else if (ParamName ==
"sink-common-insts") {
1123 }
else if (ParamName ==
"speculate-unpredictables") {
1126 APInt BonusInstThreshold;
1129 formatv(
"invalid argument to SimplifyCFG pass bonus-threshold "
1137 formatv(
"invalid SimplifyCFG pass parameter '{}'", ParamName).str(),
1148 Result.setVerifyFixpoint(
true);
1149 while (!Params.
empty()) {
1151 std::tie(ParamName, Params) = Params.
split(
';');
1154 if (ParamName ==
"verify-fixpoint") {
1157 APInt MaxIterations;
1160 formatv(
"invalid argument to InstCombine pass max-iterations "
1168 formatv(
"invalid InstCombine pass parameter '{}'", ParamName).str(),
1178 while (!Params.
empty()) {
1180 std::tie(ParamName, Params) = Params.
split(
';');
1183 if (ParamName ==
"interleave-forced-only") {
1185 }
else if (ParamName ==
"vectorize-forced-only") {
1189 formatv(
"invalid LoopVectorize parameter '{}'", ParamName).str(),
1197 std::pair<bool, bool>
Result = {
false,
true};
1198 while (!Params.
empty()) {
1200 std::tie(ParamName, Params) = Params.
split(
';');
1203 if (ParamName ==
"nontrivial") {
1205 }
else if (ParamName ==
"trivial") {
1209 formatv(
"invalid LoopUnswitch pass parameter '{}'", ParamName).str(),
1218 while (!Params.
empty()) {
1220 std::tie(ParamName, Params) = Params.
split(
';');
1223 if (ParamName ==
"allowspeculation") {
1227 formatv(
"invalid LICM pass parameter '{}'", ParamName).str(),
1235 std::pair<bool, bool>
Result = {
true,
false};
1236 while (!Params.
empty()) {
1238 std::tie(ParamName, Params) = Params.
split(
';');
1241 if (ParamName ==
"header-duplication") {
1243 }
else if (ParamName ==
"prepare-for-lto") {
1247 formatv(
"invalid LoopRotate pass parameter '{}'", ParamName).str(),
1256 while (!Params.
empty()) {
1258 std::tie(ParamName, Params) = Params.
split(
';');
1261 if (ParamName ==
"split-footer-bb") {
1265 formatv(
"invalid MergedLoadStoreMotion pass parameter '{}'",
1276 while (!Params.
empty()) {
1278 std::tie(ParamName, Params) = Params.
split(
';');
1281 if (ParamName ==
"pre") {
1283 }
else if (ParamName ==
"load-pre") {
1285 }
else if (ParamName ==
"split-backedge-load-pre") {
1287 }
else if (ParamName ==
"memdep") {
1291 }
else if (ParamName ==
"memoryssa") {
1297 formatv(
"invalid GVN pass parameter '{}'", ParamName).str(),
1306 while (!Params.
empty()) {
1308 std::tie(ParamName, Params) = Params.
split(
';');
1311 if (ParamName ==
"func-spec")
1315 formatv(
"invalid IPSCCP pass parameter '{}'", ParamName).str(),
1323 while (!Params.
empty()) {
1325 std::tie(ParamName, Params) = Params.
split(
';');
1330 formatv(
"invalid argument to Scalarizer pass min-bits "
1341 if (ParamName ==
"load-store")
1343 else if (ParamName ==
"variable-insert-extract")
1347 formatv(
"invalid Scalarizer pass parameter '{}'", ParamName).str(),
1356 if (Params.
empty() || Params ==
"modify-cfg")
1358 if (Params ==
"preserve-cfg")
1361 formatv(
"invalid SROA pass parameter '{}' (either preserve-cfg or "
1362 "modify-cfg can be specified)",
1369parseStackLifetimeOptions(
StringRef Params) {
1371 while (!Params.
empty()) {
1373 std::tie(ParamName, Params) = Params.
split(
';');
1375 if (ParamName ==
"may") {
1377 }
else if (ParamName ==
"must") {
1381 formatv(
"invalid StackLifetime parameter '{}'", ParamName).str(),
1390 "DependenceAnalysisPrinter");
1395 "SeparateConstOffsetFromGEP");
1404parseFunctionSimplificationPipelineOptions(
StringRef Params) {
1408 formatv(
"invalid function-simplification parameter '{}'", Params).str(),
1416 "MemorySSAPrinterPass");
1421 "SpeculativeExecutionPass");
1426 while (!Params.
empty()) {
1428 std::tie(ParamName, Params) = Params.
split(
';');
1434 formatv(
"invalid MemProfUse pass parameter '{}'", ParamName).str(),
1442parseStructuralHashPrinterPassOptions(
StringRef Params) {
1445 if (Params ==
"detailed")
1447 if (Params ==
"call-target-ignored")
1450 formatv(
"invalid structural hash printer parameter '{}'", Params).str(),
1456 "WinEHPreparePass");
1461 while (!Params.
empty()) {
1463 std::tie(ParamName, Params) = Params.
split(
';');
1466 if (ParamName ==
"group-by-use")
1468 else if (ParamName ==
"ignore-single-use")
1470 else if (ParamName ==
"merge-const")
1472 else if (ParamName ==
"merge-const-aggressive")
1474 else if (ParamName ==
"merge-external")
1479 formatv(
"invalid GlobalMergePass parameter '{}'", ParamName).str(),
1483 formatv(
"invalid global-merge pass parameter '{}'", Params).str(),
1492 while (!Params.
empty()) {
1494 std::tie(ParamName, Params) = Params.
split(
';');
1500 formatv(
"invalid Internalize pass parameter '{}'", ParamName).str(),
1511 while (!Params.
empty()) {
1513 std::tie(ParamName, Params) = Params.
split(
';');
1516 std::optional<RegAllocFilterFunc>
Filter =
1520 formatv(
"invalid regallocfast register filter '{}'", ParamName)
1529 if (ParamName ==
"no-clear-vregs") {
1535 formatv(
"invalid regallocfast pass parameter '{}'", ParamName).str(),
1542parseBoundsCheckingOptions(
StringRef Params) {
1544 while (!Params.
empty()) {
1546 std::tie(ParamName, Params) = Params.
split(
';');
1547 if (ParamName ==
"trap") {
1549 }
else if (ParamName ==
"rt") {
1554 }
else if (ParamName ==
"rt-abort") {
1559 }
else if (ParamName ==
"min-rt") {
1564 }
else if (ParamName ==
"min-rt-abort") {
1569 }
else if (ParamName ==
"merge") {
1574 std::tie(ParamEQ, Val) = ParamName.
split(
'=');
1580 formatv(
"invalid BoundsChecking pass parameter '{}'", ParamName)
1597 if (!
Prefix.empty() || Digit.getAsInteger(10,
N))
1599 Param.str().c_str());
1602 if (!
Level.has_value())
1604 "invalid optimization level for expand-fp pass: %s",
1605 Digit.str().c_str());
1612 if (Params.
empty() || Params ==
"all")
1613 return RAGreedyPass::Options();
1617 return RAGreedyPass::Options{*
Filter, Params};
1620 formatv(
"invalid regallocgreedy register filter '{}'", Params).str(),
1626 "MachineSinkingPass");
1630 bool AllowTailMerge =
true;
1631 if (!Params.
empty()) {
1633 if (Params !=
"tail-merge")
1635 formatv(
"invalid MachineBlockPlacementPass parameter '{}'", Params)
1639 return AllowTailMerge;
1643 bool ClearVirtRegs =
true;
1644 if (!Params.
empty()) {
1646 if (Params !=
"clear-vregs")
1648 formatv(
"invalid VirtRegRewriter pass parameter '{}'", Params).str(),
1651 return ClearVirtRegs;
1654struct FatLTOOptions {
1655 OptimizationLevel OptLevel;
1656 bool ThinLTO =
false;
1657 bool EmitSummary =
false;
1662 bool HaveOptLevel =
false;
1663 while (!Params.
empty()) {
1665 std::tie(ParamName, Params) = Params.
split(
';');
1667 if (ParamName ==
"thinlto") {
1669 }
else if (ParamName ==
"emit-summary") {
1670 Result.EmitSummary =
true;
1671 }
else if (std::optional<OptimizationLevel> OptLevel =
1673 Result.OptLevel = *OptLevel;
1674 HaveOptLevel =
true;
1677 formatv(
"invalid fatlto-pre-link pass parameter '{}'", ParamName)
1684 "missing optimization level for fatlto-pre-link pipeline",
1699template <
typename PassManagerT,
typename CallbacksT>
1701 if (!Callbacks.empty()) {
1702 PassManagerT DummyPM;
1703 for (
auto &CB : Callbacks)
1704 if (CB(Name, DummyPM, {}))
1710template <
typename CallbacksT>
1712 StringRef NameNoBracket = Name.take_until([](
char C) {
return C ==
'<'; });
1715 if (Name ==
"module")
1717 if (Name ==
"cgscc")
1719 if (NameNoBracket ==
"function")
1721 if (Name ==
"coro-cond")
1724#define MODULE_PASS(NAME, CREATE_PASS) \
1727#define MODULE_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1728 if (PassBuilder::checkParametrizedPassName(Name, NAME)) \
1730#define MODULE_ANALYSIS(NAME, CREATE_PASS) \
1731 if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
1733#include "PassRegistry.def"
1738template <
typename CallbacksT>
1741 StringRef NameNoBracket = Name.take_until([](
char C) {
return C ==
'<'; });
1742 if (Name ==
"cgscc")
1744 if (NameNoBracket ==
"function")
1751#define CGSCC_PASS(NAME, CREATE_PASS) \
1754#define CGSCC_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1755 if (PassBuilder::checkParametrizedPassName(Name, NAME)) \
1757#define CGSCC_ANALYSIS(NAME, CREATE_PASS) \
1758 if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
1760#include "PassRegistry.def"
1765template <
typename CallbacksT>
1768 StringRef NameNoBracket = Name.take_until([](
char C) {
return C ==
'<'; });
1769 if (NameNoBracket ==
"function")
1771 if (Name ==
"loop" || Name ==
"loop-mssa" || Name ==
"machine-function")
1774#define FUNCTION_PASS(NAME, CREATE_PASS) \
1777#define FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1778 if (PassBuilder::checkParametrizedPassName(Name, NAME)) \
1780#define FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
1781 if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
1783#include "PassRegistry.def"
1788template <
typename CallbacksT>
1791 if (Name ==
"machine-function")
1794#define MACHINE_FUNCTION_PASS(NAME, CREATE_PASS) \
1797#define MACHINE_FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, \
1799 if (PassBuilder::checkParametrizedPassName(Name, NAME)) \
1802#define MACHINE_FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
1803 if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
1806#include "llvm/Passes/MachinePassRegistry.def"
1811template <
typename CallbacksT>
1813 bool &UseMemorySSA) {
1814 UseMemorySSA =
false;
1817 UseMemorySSA =
true;
1821#define LOOPNEST_PASS(NAME, CREATE_PASS) \
1824#include "PassRegistry.def"
1829template <
typename CallbacksT>
1831 bool &UseMemorySSA) {
1832 UseMemorySSA =
false;
1835 UseMemorySSA =
true;
1839#define LOOP_PASS(NAME, CREATE_PASS) \
1842#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1843 if (PassBuilder::checkParametrizedPassName(Name, NAME)) \
1845#define LOOP_ANALYSIS(NAME, CREATE_PASS) \
1846 if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
1848#include "PassRegistry.def"
1853std::optional<std::vector<PassBuilder::PipelineElement>>
1854PassBuilder::parsePipelineText(
StringRef Text) {
1855 std::vector<PipelineElement> ResultPipeline;
1860 std::vector<PipelineElement> &Pipeline = *PipelineStack.
back();
1861 size_t Pos =
Text.find_first_of(
",()");
1862 Pipeline.push_back({
Text.substr(0, Pos), {}});
1865 if (Pos ==
Text.npos)
1868 char Sep =
Text[Pos];
1876 PipelineStack.
push_back(&Pipeline.back().InnerPipeline);
1880 assert(Sep ==
')' &&
"Bogus separator!");
1885 if (PipelineStack.
size() == 1)
1886 return std::nullopt;
1889 }
while (
Text.consume_front(
")"));
1897 if (!
Text.consume_front(
","))
1898 return std::nullopt;
1901 if (PipelineStack.
size() > 1)
1903 return std::nullopt;
1905 assert(PipelineStack.
back() == &ResultPipeline &&
1906 "Wrong pipeline at the bottom of the stack!");
1907 return {std::move(ResultPipeline)};
1920 const PipelineElement &
E) {
1921 auto &
Name =
E.Name;
1922 auto &InnerPipeline =
E.InnerPipeline;
1925 if (!InnerPipeline.empty()) {
1926 if (Name ==
"module") {
1928 if (
auto Err = parseModulePassPipeline(NestedMPM, InnerPipeline))
1930 MPM.
addPass(std::move(NestedMPM));
1933 if (Name ==
"coro-cond") {
1935 if (
auto Err = parseModulePassPipeline(NestedMPM, InnerPipeline))
1937 MPM.
addPass(CoroConditionalWrapper(std::move(NestedMPM)));
1940 if (Name ==
"cgscc") {
1942 if (
auto Err = parseCGSCCPassPipeline(CGPM, InnerPipeline))
1950 "cannot have a no-rerun module to function adaptor",
1953 if (
auto Err = parseFunctionPassPipeline(FPM, InnerPipeline))
1960 for (
auto &
C : ModulePipelineParsingCallbacks)
1961 if (
C(Name, MPM, InnerPipeline))
1966 formatv(
"invalid use of '{}' pass as module pipeline", Name).str(),
1972#define MODULE_PASS(NAME, CREATE_PASS) \
1973 if (Name == NAME) { \
1974 MPM.addPass(CREATE_PASS); \
1975 return Error::success(); \
1977#define MODULE_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1978 if (checkParametrizedPassName(Name, NAME)) { \
1979 auto Params = parsePassParameters(PARSER, Name, NAME); \
1981 return Params.takeError(); \
1982 MPM.addPass(CREATE_PASS(Params.get())); \
1983 return Error::success(); \
1985#define MODULE_ANALYSIS(NAME, CREATE_PASS) \
1986 if (Name == "require<" NAME ">") { \
1988 RequireAnalysisPass< \
1989 std::remove_reference_t<decltype(CREATE_PASS)>, Module>()); \
1990 return Error::success(); \
1992 if (Name == "invalidate<" NAME ">") { \
1993 MPM.addPass(InvalidateAnalysisPass< \
1994 std::remove_reference_t<decltype(CREATE_PASS)>>()); \
1995 return Error::success(); \
1997#define CGSCC_PASS(NAME, CREATE_PASS) \
1998 if (Name == NAME) { \
1999 MPM.addPass(createModuleToPostOrderCGSCCPassAdaptor(CREATE_PASS)); \
2000 return Error::success(); \
2002#define CGSCC_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
2003 if (checkParametrizedPassName(Name, NAME)) { \
2004 auto Params = parsePassParameters(PARSER, Name, NAME); \
2006 return Params.takeError(); \
2008 createModuleToPostOrderCGSCCPassAdaptor(CREATE_PASS(Params.get()))); \
2009 return Error::success(); \
2011#define FUNCTION_PASS(NAME, CREATE_PASS) \
2012 if (Name == NAME) { \
2013 MPM.addPass(createModuleToFunctionPassAdaptor(CREATE_PASS)); \
2014 return Error::success(); \
2016#define FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
2017 if (checkParametrizedPassName(Name, NAME)) { \
2018 auto Params = parsePassParameters(PARSER, Name, NAME); \
2020 return Params.takeError(); \
2021 MPM.addPass(createModuleToFunctionPassAdaptor(CREATE_PASS(Params.get()))); \
2022 return Error::success(); \
2024#define LOOPNEST_PASS(NAME, CREATE_PASS) \
2025 if (Name == NAME) { \
2026 MPM.addPass(createModuleToFunctionPassAdaptor( \
2027 createFunctionToLoopPassAdaptor(CREATE_PASS, false, false))); \
2028 return Error::success(); \
2030#define LOOP_PASS(NAME, CREATE_PASS) \
2031 if (Name == NAME) { \
2032 MPM.addPass(createModuleToFunctionPassAdaptor( \
2033 createFunctionToLoopPassAdaptor(CREATE_PASS, false, false))); \
2034 return Error::success(); \
2036#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
2037 if (checkParametrizedPassName(Name, NAME)) { \
2038 auto Params = parsePassParameters(PARSER, Name, NAME); \
2040 return Params.takeError(); \
2042 createModuleToFunctionPassAdaptor(createFunctionToLoopPassAdaptor( \
2043 CREATE_PASS(Params.get()), false, false))); \
2044 return Error::success(); \
2046#include "PassRegistry.def"
2048 for (
auto &
C : ModulePipelineParsingCallbacks)
2049 if (
C(Name, MPM, InnerPipeline))
2052 formatv(
"unknown module pass '{}'", Name).str(),
2057 const PipelineElement &
E) {
2058 auto &
Name =
E.Name;
2059 auto &InnerPipeline =
E.InnerPipeline;
2062 if (!InnerPipeline.empty()) {
2063 if (Name ==
"cgscc") {
2065 if (
auto Err = parseCGSCCPassPipeline(NestedCGPM, InnerPipeline))
2068 CGPM.
addPass(std::move(NestedCGPM));
2073 if (
auto Err = parseFunctionPassPipeline(FPM, InnerPipeline))
2077 std::move(FPM), Params->first, Params->second));
2082 if (
auto Err = parseCGSCCPassPipeline(NestedCGPM, InnerPipeline))
2089 for (
auto &
C : CGSCCPipelineParsingCallbacks)
2090 if (
C(Name, CGPM, InnerPipeline))
2095 formatv(
"invalid use of '{}' pass as cgscc pipeline", Name).str(),
2100#define CGSCC_PASS(NAME, CREATE_PASS) \
2101 if (Name == NAME) { \
2102 CGPM.addPass(CREATE_PASS); \
2103 return Error::success(); \
2105#define CGSCC_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
2106 if (checkParametrizedPassName(Name, NAME)) { \
2107 auto Params = parsePassParameters(PARSER, Name, NAME); \
2109 return Params.takeError(); \
2110 CGPM.addPass(CREATE_PASS(Params.get())); \
2111 return Error::success(); \
2113#define CGSCC_ANALYSIS(NAME, CREATE_PASS) \
2114 if (Name == "require<" NAME ">") { \
2115 CGPM.addPass(RequireAnalysisPass< \
2116 std::remove_reference_t<decltype(CREATE_PASS)>, \
2117 LazyCallGraph::SCC, CGSCCAnalysisManager, LazyCallGraph &, \
2118 CGSCCUpdateResult &>()); \
2119 return Error::success(); \
2121 if (Name == "invalidate<" NAME ">") { \
2122 CGPM.addPass(InvalidateAnalysisPass< \
2123 std::remove_reference_t<decltype(CREATE_PASS)>>()); \
2124 return Error::success(); \
2126#define FUNCTION_PASS(NAME, CREATE_PASS) \
2127 if (Name == NAME) { \
2128 CGPM.addPass(createCGSCCToFunctionPassAdaptor(CREATE_PASS)); \
2129 return Error::success(); \
2131#define FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
2132 if (checkParametrizedPassName(Name, NAME)) { \
2133 auto Params = parsePassParameters(PARSER, Name, NAME); \
2135 return Params.takeError(); \
2136 CGPM.addPass(createCGSCCToFunctionPassAdaptor(CREATE_PASS(Params.get()))); \
2137 return Error::success(); \
2139#define LOOPNEST_PASS(NAME, CREATE_PASS) \
2140 if (Name == NAME) { \
2141 CGPM.addPass(createCGSCCToFunctionPassAdaptor( \
2142 createFunctionToLoopPassAdaptor(CREATE_PASS, false, false))); \
2143 return Error::success(); \
2145#define LOOP_PASS(NAME, CREATE_PASS) \
2146 if (Name == NAME) { \
2147 CGPM.addPass(createCGSCCToFunctionPassAdaptor( \
2148 createFunctionToLoopPassAdaptor(CREATE_PASS, false, false))); \
2149 return Error::success(); \
2151#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
2152 if (checkParametrizedPassName(Name, NAME)) { \
2153 auto Params = parsePassParameters(PARSER, Name, NAME); \
2155 return Params.takeError(); \
2157 createCGSCCToFunctionPassAdaptor(createFunctionToLoopPassAdaptor( \
2158 CREATE_PASS(Params.get()), false, false))); \
2159 return Error::success(); \
2161#include "PassRegistry.def"
2163 for (
auto &
C : CGSCCPipelineParsingCallbacks)
2164 if (
C(Name, CGPM, InnerPipeline))
2171 const PipelineElement &
E) {
2172 auto &
Name =
E.Name;
2173 auto &InnerPipeline =
E.InnerPipeline;
2176 if (!InnerPipeline.empty()) {
2177 if (Name ==
"function") {
2179 if (
auto Err = parseFunctionPassPipeline(NestedFPM, InnerPipeline))
2182 FPM.
addPass(std::move(NestedFPM));
2185 if (Name ==
"loop" || Name ==
"loop-mssa") {
2187 if (
auto Err = parseLoopPassPipeline(LPM, InnerPipeline))
2190 bool UseMemorySSA = (
Name ==
"loop-mssa");
2192 return Pipeline.Name.contains(
"simple-loop-unswitch");
2198 if (Name ==
"machine-function") {
2200 if (
auto Err = parseMachinePassPipeline(MFPM, InnerPipeline))
2206 for (
auto &
C : FunctionPipelineParsingCallbacks)
2207 if (
C(Name, FPM, InnerPipeline))
2212 formatv(
"invalid use of '{}' pass as function pipeline", Name).str(),
2217#define FUNCTION_PASS(NAME, CREATE_PASS) \
2218 if (Name == NAME) { \
2219 FPM.addPass(CREATE_PASS); \
2220 return Error::success(); \
2222#define FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
2223 if (checkParametrizedPassName(Name, NAME)) { \
2224 auto Params = parsePassParameters(PARSER, Name, NAME); \
2226 return Params.takeError(); \
2227 FPM.addPass(CREATE_PASS(Params.get())); \
2228 return Error::success(); \
2230#define FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
2231 if (Name == "require<" NAME ">") { \
2233 RequireAnalysisPass< \
2234 std::remove_reference_t<decltype(CREATE_PASS)>, Function>()); \
2235 return Error::success(); \
2237 if (Name == "invalidate<" NAME ">") { \
2238 FPM.addPass(InvalidateAnalysisPass< \
2239 std::remove_reference_t<decltype(CREATE_PASS)>>()); \
2240 return Error::success(); \
2246#define LOOPNEST_PASS(NAME, CREATE_PASS) \
2247 if (Name == NAME) { \
2248 FPM.addPass(createFunctionToLoopPassAdaptor(CREATE_PASS, false, false)); \
2249 return Error::success(); \
2251#define LOOP_PASS(NAME, CREATE_PASS) \
2252 if (Name == NAME) { \
2253 FPM.addPass(createFunctionToLoopPassAdaptor(CREATE_PASS, false, false)); \
2254 return Error::success(); \
2256#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
2257 if (checkParametrizedPassName(Name, NAME)) { \
2258 auto Params = parsePassParameters(PARSER, Name, NAME); \
2260 return Params.takeError(); \
2261 FPM.addPass(createFunctionToLoopPassAdaptor(CREATE_PASS(Params.get()), \
2263 return Error::success(); \
2265#include "PassRegistry.def"
2267 for (
auto &
C : FunctionPipelineParsingCallbacks)
2268 if (
C(Name, FPM, InnerPipeline))
2271 formatv(
"unknown function pass '{}'", Name).str(),
2276 const PipelineElement &
E) {
2277 StringRef
Name =
E.Name;
2278 auto &InnerPipeline =
E.InnerPipeline;
2281 if (!InnerPipeline.empty()) {
2282 if (Name ==
"loop") {
2284 if (
auto Err = parseLoopPassPipeline(NestedLPM, InnerPipeline))
2287 LPM.addPass(std::move(NestedLPM));
2291 for (
auto &
C : LoopPipelineParsingCallbacks)
2292 if (
C(Name, LPM, InnerPipeline))
2297 formatv(
"invalid use of '{}' pass as loop pipeline", Name).str(),
2302#define LOOPNEST_PASS(NAME, CREATE_PASS) \
2303 if (Name == NAME) { \
2304 LPM.addPass(CREATE_PASS); \
2305 return Error::success(); \
2307#define LOOP_PASS(NAME, CREATE_PASS) \
2308 if (Name == NAME) { \
2309 LPM.addPass(CREATE_PASS); \
2310 return Error::success(); \
2312#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
2313 if (checkParametrizedPassName(Name, NAME)) { \
2314 auto Params = parsePassParameters(PARSER, Name, NAME); \
2316 return Params.takeError(); \
2317 LPM.addPass(CREATE_PASS(Params.get())); \
2318 return Error::success(); \
2320#define LOOP_ANALYSIS(NAME, CREATE_PASS) \
2321 if (Name == "require<" NAME ">") { \
2322 LPM.addPass(RequireAnalysisPass< \
2323 std::remove_reference_t<decltype(CREATE_PASS)>, Loop, \
2324 LoopAnalysisManager, LoopStandardAnalysisResults &, \
2326 return Error::success(); \
2328 if (Name == "invalidate<" NAME ">") { \
2329 LPM.addPass(InvalidateAnalysisPass< \
2330 std::remove_reference_t<decltype(CREATE_PASS)>>()); \
2331 return Error::success(); \
2333#include "PassRegistry.def"
2335 for (
auto &
C : LoopPipelineParsingCallbacks)
2336 if (
C(Name, LPM, InnerPipeline))
2343 const PipelineElement &
E) {
2344 StringRef
Name =
E.Name;
2346 if (!
E.InnerPipeline.empty()) {
2347 if (
E.Name ==
"machine-function") {
2349 if (
auto Err = parseMachinePassPipeline(NestedPM,
E.InnerPipeline))
2351 MFPM.
addPass(std::move(NestedPM));
2358#define MACHINE_MODULE_PASS(NAME, CREATE_PASS) \
2359 if (Name == NAME) { \
2360 MFPM.addPass(CREATE_PASS); \
2361 return Error::success(); \
2363#define MACHINE_FUNCTION_PASS(NAME, CREATE_PASS) \
2364 if (Name == NAME) { \
2365 MFPM.addPass(CREATE_PASS); \
2366 return Error::success(); \
2368#define MACHINE_FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, \
2370 if (checkParametrizedPassName(Name, NAME)) { \
2371 auto Params = parsePassParameters(PARSER, Name, NAME); \
2373 return Params.takeError(); \
2374 MFPM.addPass(CREATE_PASS(Params.get())); \
2375 return Error::success(); \
2377#define MACHINE_FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
2378 if (Name == "require<" NAME ">") { \
2380 RequireAnalysisPass<std::remove_reference_t<decltype(CREATE_PASS)>, \
2381 MachineFunction>()); \
2382 return Error::success(); \
2384 if (Name == "invalidate<" NAME ">") { \
2385 MFPM.addPass(InvalidateAnalysisPass< \
2386 std::remove_reference_t<decltype(CREATE_PASS)>>()); \
2387 return Error::success(); \
2389#include "llvm/Passes/MachinePassRegistry.def"
2391 for (
auto &
C : MachineFunctionPipelineParsingCallbacks)
2392 if (
C(Name, MFPM,
E.InnerPipeline))
2395 formatv(
"unknown machine pass '{}'", Name).str(),
2400#define MODULE_ALIAS_ANALYSIS(NAME, CREATE_PASS) \
2401 if (Name == NAME) { \
2402 AA.registerModuleAnalysis< \
2403 std::remove_reference_t<decltype(CREATE_PASS)>>(); \
2406#define FUNCTION_ALIAS_ANALYSIS(NAME, CREATE_PASS) \
2407 if (Name == NAME) { \
2408 AA.registerFunctionAnalysis< \
2409 std::remove_reference_t<decltype(CREATE_PASS)>>(); \
2412#include "PassRegistry.def"
2414 for (
auto &
C : AAParsingCallbacks)
2420Error PassBuilder::parseMachinePassPipeline(
2422 for (
const auto &Element : Pipeline) {
2423 if (
auto Err = parseMachinePass(MFPM, Element))
2431 for (
const auto &Element : Pipeline) {
2432 if (
auto Err = parseLoopPass(LPM, Element))
2438Error PassBuilder::parseFunctionPassPipeline(
2440 for (
const auto &Element : Pipeline) {
2441 if (
auto Err = parseFunctionPass(FPM, Element))
2449 for (
const auto &Element : Pipeline) {
2450 if (
auto Err = parseCGSCCPass(CGPM, Element))
2482 for (
const auto &Element : Pipeline) {
2483 if (
auto Err = parseModulePass(MPM, Element))
2494 auto Pipeline = parsePipelineText(PipelineText);
2495 if (!Pipeline || Pipeline->empty())
2497 formatv(
"invalid pipeline '{}'", PipelineText).str(),
2507 Pipeline = {{
"cgscc", std::move(*Pipeline)}};
2509 FunctionPipelineParsingCallbacks)) {
2510 Pipeline = {{
"function", std::move(*Pipeline)}};
2513 Pipeline = {{
"function", {{UseMemorySSA ?
"loop-mssa" :
"loop",
2514 std::move(*Pipeline)}}}};
2515 }
else if (
isLoopPassName(FirstName, LoopPipelineParsingCallbacks,
2517 Pipeline = {{
"function", {{UseMemorySSA ?
"loop-mssa" :
"loop",
2518 std::move(*Pipeline)}}}};
2520 FirstName, MachineFunctionPipelineParsingCallbacks)) {
2521 Pipeline = {{
"function", {{
"machine-function", std::move(*Pipeline)}}}};
2523 for (
auto &
C : TopLevelPipelineParsingCallbacks)
2524 if (
C(MPM, *Pipeline))
2528 auto &InnerPipeline = Pipeline->front().InnerPipeline;
2530 formatv(
"unknown {} name '{}'",
2531 (InnerPipeline.empty() ?
"pass" :
"pipeline"), FirstName)
2537 if (
auto Err = parseModulePassPipeline(MPM, *Pipeline))
2545 auto Pipeline = parsePipelineText(PipelineText);
2546 if (!Pipeline || Pipeline->empty())
2548 formatv(
"invalid pipeline '{}'", PipelineText).str(),
2554 formatv(
"unknown cgscc pass '{}' in pipeline '{}'", FirstName,
2559 if (
auto Err = parseCGSCCPassPipeline(CGPM, *Pipeline))
2568 auto Pipeline = parsePipelineText(PipelineText);
2569 if (!Pipeline || Pipeline->empty())
2571 formatv(
"invalid pipeline '{}'", PipelineText).str(),
2577 formatv(
"unknown function pass '{}' in pipeline '{}'", FirstName,
2582 if (
auto Err = parseFunctionPassPipeline(FPM, *Pipeline))
2590 auto Pipeline = parsePipelineText(PipelineText);
2591 if (!Pipeline || Pipeline->empty())
2593 formatv(
"invalid pipeline '{}'", PipelineText).str(),
2596 if (
auto Err = parseLoopPassPipeline(CGPM, *Pipeline))
2604 auto Pipeline = parsePipelineText(PipelineText);
2605 if (!Pipeline || Pipeline->empty())
2607 formatv(
"invalid machine pass pipeline '{}'", PipelineText).str(),
2610 if (
auto Err = parseMachinePassPipeline(MFPM, *Pipeline))
2619 if (PipelineText ==
"default") {
2624 while (!PipelineText.
empty()) {
2626 std::tie(Name, PipelineText) = PipelineText.
split(
',');
2627 if (!parseAAPassName(
AA, Name))
2629 formatv(
"unknown alias analysis name '{}'", Name).str(),
2636std::optional<RegAllocFilterFunc>
2638 if (FilterName ==
"all")
2640 for (
auto &
C : RegClassFilterParsingCallbacks)
2641 if (
auto F =
C(FilterName))
2643 return std::nullopt;
2651 OS <<
" " <<
PassName <<
"<" << Params <<
">\n";
2657 OS <<
"Module passes:\n";
2658#define MODULE_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2659#include "PassRegistry.def"
2661 OS <<
"Module passes with params:\n";
2662#define MODULE_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
2663 printPassName(NAME, PARAMS, OS);
2664#include "PassRegistry.def"
2666 OS <<
"Module analyses:\n";
2667#define MODULE_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2668#include "PassRegistry.def"
2670 OS <<
"Module alias analyses:\n";
2671#define MODULE_ALIAS_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2672#include "PassRegistry.def"
2674 OS <<
"CGSCC passes:\n";
2675#define CGSCC_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2676#include "PassRegistry.def"
2678 OS <<
"CGSCC passes with params:\n";
2679#define CGSCC_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
2680 printPassName(NAME, PARAMS, OS);
2681#include "PassRegistry.def"
2683 OS <<
"CGSCC analyses:\n";
2684#define CGSCC_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2685#include "PassRegistry.def"
2687 OS <<
"Function passes:\n";
2688#define FUNCTION_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2689#include "PassRegistry.def"
2691 OS <<
"Function passes with params:\n";
2692#define FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
2693 printPassName(NAME, PARAMS, OS);
2694#include "PassRegistry.def"
2696 OS <<
"Function analyses:\n";
2697#define FUNCTION_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2698#include "PassRegistry.def"
2700 OS <<
"Function alias analyses:\n";
2701#define FUNCTION_ALIAS_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2702#include "PassRegistry.def"
2704 OS <<
"LoopNest passes:\n";
2705#define LOOPNEST_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2706#include "PassRegistry.def"
2708 OS <<
"Loop passes:\n";
2709#define LOOP_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2710#include "PassRegistry.def"
2712 OS <<
"Loop passes with params:\n";
2713#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
2714 printPassName(NAME, PARAMS, OS);
2715#include "PassRegistry.def"
2717 OS <<
"Loop analyses:\n";
2718#define LOOP_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2719#include "PassRegistry.def"
2721 OS <<
"Machine module passes (WIP):\n";
2722#define MACHINE_MODULE_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2723#include "llvm/Passes/MachinePassRegistry.def"
2725 OS <<
"Machine function passes (WIP):\n";
2726#define MACHINE_FUNCTION_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2727#include "llvm/Passes/MachinePassRegistry.def"
2729 OS <<
"Machine function analyses (WIP):\n";
2730#define MACHINE_FUNCTION_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2731#include "llvm/Passes/MachinePassRegistry.def"
2737 TopLevelPipelineParsingCallbacks.push_back(
C);
unsigned const MachineRegisterInfo * MRI
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
AggressiveInstCombiner - Combine expression patterns to form expressions with fewer,...
This file implements a simple N^2 alias analysis accuracy evaluator.
Provides passes to inlining "always_inline" functions.
This is the interface for LLVM's primary stateless and local alias analysis.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This file provides the interface for LLVM's Call Graph Profile pass.
This header provides classes for managing passes over SCCs of the call graph.
This file provides interfaces used to build and manipulate a call graph, which is a very useful tool ...
Defines an IR pass for CodeGen Prepare.
This file declares an analysis pass that computes CycleInfo for LLVM IR, specialized from GenericCycl...
Analysis that tracks defined/used subregister lanes across COPY instructions and instructions that ge...
This file provides the interface for a simple, fast CSE pass.
This file provides a pass which clones the current module and runs the provided pass pipeline on the ...
Super simple passes to force specific function attrs from the commandline into the IR for debugging p...
Provides passes for computing function attributes based on interprocedural analyses.
This file provides the interface for the GCOV style profiler pass.
Provides analysis for querying information about KnownBits during GISel passes.
This file provides the interface for LLVM's Global Value Numbering pass which eliminates fully redund...
This is the interface for a simple mod/ref and alias analysis over globals.
Defines an IR pass for the creation of hardware loops.
AcceleratorCodeSelection - Identify all functions reachable from a kernel, removing those that are un...
This file defines the IR2Vec vocabulary analysis(IR2VecVocabAnalysis), the core ir2vec::Embedder inte...
This file defines passes to print out IR in various granularities.
This header defines various interfaces for pass management in LLVM.
Interfaces for passes which infer implicit function attributes from the name and signature of functio...
This file provides the primary interface to the instcombine pass.
Defines passes for running instruction simplification across chunks of IR.
This file provides the interface for LLVM's PGO Instrumentation lowering pass.
This file contains the declaration of the InterleavedAccessPass class, its corresponding pass name is...
See the comments on JumpThreadingPass.
Implements a lazy call graph analysis and related passes for the new pass manager.
This file defines the interface for the loop cache analysis.
This file provides the interface for LLVM's Loop Data Prefetching Pass.
This file implements the Loop Fusion pass.
This header defines the LoopLoadEliminationPass object.
This file defines the interface for the loop nest analysis.
This header provides classes for managing a pipeline of passes over loops in LLVM IR.
This file provides the interface for the pass responsible for removing expensive ubsan checks.
The header file for the LowerConstantIntrinsics pass as used by the new pass manager.
The header file for the LowerExpectIntrinsic pass as used by the new pass manager.
Machine Check Debug Module
This file exposes an interface to building/using memory SSA to walk memory instructions using a use/d...
This pass performs merges of loads and stores on both sides of a.
This is the interface to build a ModuleSummaryIndex for a module.
Contains a collection of routines for determining if a given instruction is guaranteed to execute if ...
This file provides the interface for LLVM's Global Value Numbering pass.
This file declares a simple ARC-aware AliasAnalysis using special knowledge of Objective C to enhance...
This header enumerates the LLVM-provided high-level optimization levels.
This file provides the interface for IR based instrumentation passes ( (profile-gen,...
CGSCCAnalysisManager CGAM
FunctionAnalysisManager FAM
ModuleAnalysisManager MAM
PassBuilder PB(Machine, PassOpts->PTO, std::nullopt, &PIC)
static bool isModulePassName(StringRef Name, CallbacksT &Callbacks)
static bool callbacksAcceptPassName(StringRef Name, CallbacksT &Callbacks)
Tests whether registered callbacks will accept a given pass name.
static std::optional< int > parseDevirtPassName(StringRef Name)
static bool isLoopNestPassName(StringRef Name, CallbacksT &Callbacks, bool &UseMemorySSA)
static bool isMachineFunctionPassName(StringRef Name, CallbacksT &Callbacks)
static Expected< OptimizationLevel > parseOptLevelParam(StringRef S)
static std::optional< OptimizationLevel > parseOptLevel(StringRef S)
static bool isLoopPassName(StringRef Name, CallbacksT &Callbacks, bool &UseMemorySSA)
static std::optional< std::pair< bool, bool > > parseFunctionPipelineName(StringRef Name)
static bool isCGSCCPassName(StringRef Name, CallbacksT &Callbacks)
static void printPassName(StringRef PassName, raw_ostream &OS)
static bool isFunctionPassName(StringRef Name, CallbacksT &Callbacks)
static void setupOptionsForPipelineAlias(PipelineTuningOptions &PTO, OptimizationLevel L)
This file implements the PredicateInfo analysis, which creates an Extended SSA form for operations us...
This pass is required to take advantage of the interprocedural register allocation infrastructure.
This file implements relative lookup table converter that converts lookup tables to relative lookup t...
This file provides the interface for LLVM's Scalar Replacement of Aggregates pass.
This file provides the interface for the pseudo probe implementation for AutoFDO.
This file provides the interface for the sampled PGO loader pass.
This is the interface for a SCEV-based alias analysis.
This pass converts vector operations into scalar operations (or, optionally, operations on smaller ve...
This is the interface for a metadata-based scoped no-alias analysis.
This file contains the declaration of the SelectOptimizePass class, its corresponding pass name is se...
This file provides the interface for the pass responsible for both simplifying and canonicalizing the...
This file implements the StringSwitch template, which mimics a switch() statement whose cases are str...
Target-Independent Code Generator Pass Configuration Options pass.
This is the interface for a metadata-based TBAA.
static const char PassName[]
A manager for alias analyses.
Class for arbitrary precision integers.
uint64_t getZExtValue() const
Get zero extended value.
int64_t getSExtValue() const
Get sign extended value.
bool registerPass(PassBuilderT &&PassBuilder)
Register an analysis pass with the manager.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
const Instruction * getTerminator() const LLVM_READONLY
Returns the terminator instruction if the block is well formed or null if the block is not well forme...
Lightweight error class with error context and mandatory checking.
static ErrorSuccess success()
Create a success value.
Tagged union holding either a T or a Error.
static LLVM_ABI GlobalAlias * create(Type *Ty, unsigned AddressSpace, LinkageTypes Linkage, const Twine &Name, Constant *Aliasee, Module *Parent)
If a parent module is specified, the alias is automatically inserted into the end of the specified mo...
static constexpr LLT scalar(unsigned SizeInBits)
Get a low-level scalar or aggregate "bag of bits".
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
const MachineFunctionProperties & getProperties() const
Get the function properties.
static LLVM_ABI const OptimizationLevel O3
Optimize for fast execution as much as possible.
static LLVM_ABI const OptimizationLevel Oz
A very specialized mode that will optimize for code size at any and all costs.
static LLVM_ABI const OptimizationLevel O0
Disable as many optimizations as possible.
static LLVM_ABI const OptimizationLevel Os
Similar to O2 but tries to optimize for small code size instead of fast execution without triggering ...
static LLVM_ABI const OptimizationLevel O2
Optimize for fast execution as much as possible without triggering significant incremental compile ti...
static LLVM_ABI const OptimizationLevel O1
Optimize quickly without destroying debuggability.
This class provides access to building LLVM's passes.
LLVM_ABI void printPassNames(raw_ostream &OS)
Print pass names.
static bool checkParametrizedPassName(StringRef Name, StringRef PassName)
LLVM_ABI AAManager buildDefaultAAPipeline()
Build the default AAManager with the default alias analysis pipeline registered.
LLVM_ABI Error parseAAPipeline(AAManager &AA, StringRef PipelineText)
Parse a textual alias analysis pipeline into the provided AA manager.
LLVM_ABI PassBuilder(TargetMachine *TM=nullptr, PipelineTuningOptions PTO=PipelineTuningOptions(), std::optional< PGOOptions > PGOOpt=std::nullopt, PassInstrumentationCallbacks *PIC=nullptr)
LLVM_ABI void registerLoopAnalyses(LoopAnalysisManager &LAM)
Registers all available loop analysis passes.
LLVM_ABI std::optional< RegAllocFilterFunc > parseRegAllocFilter(StringRef RegAllocFilterName)
Parse RegAllocFilterName to get RegAllocFilterFunc.
LLVM_ABI void crossRegisterProxies(LoopAnalysisManager &LAM, FunctionAnalysisManager &FAM, CGSCCAnalysisManager &CGAM, ModuleAnalysisManager &MAM, MachineFunctionAnalysisManager *MFAM=nullptr)
Cross register the analysis managers through their proxies.
LLVM_ABI Error parsePassPipeline(ModulePassManager &MPM, StringRef PipelineText)
Parse a textual pass pipeline description into a ModulePassManager.
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 >
PassManager< MachineFunction > MachineFunctionPassManager
Convenience typedef for a pass manager over functions.
AnalysisManager< Function > FunctionAnalysisManager
Convenience typedef for the Function analysis manager.
@ Detailed
Hash with opcode only.
@ CallTargetIgnored
Hash with opcode and operands.
AnalysisManager< Module > ModuleAnalysisManager
Convenience typedef for the Module analysis manager.
A special type used by analysis passes to provide an address that identifies that particular analysis...
A set of parameters to control various transforms performed by GVN pass.
HardwareLoopOptions & setForceNested(bool Force)
HardwareLoopOptions & setDecrement(unsigned Count)
HardwareLoopOptions & setForceGuard(bool Force)
HardwareLoopOptions & setForce(bool Force)
HardwareLoopOptions & setCounterBitwidth(unsigned Width)
HardwareLoopOptions & setForcePhi(bool Force)
A set of parameters to control various transforms performed by IPSCCP pass.
A set of parameters used to control various transforms performed by the LoopUnroll pass.
LoopUnrollOptions & setPeeling(bool Peeling)
Enables or disables loop peeling.
LoopUnrollOptions & setOptLevel(int O)
LoopUnrollOptions & setPartial(bool Partial)
Enables or disables partial unrolling.
LoopUnrollOptions & setFullUnrollMaxCount(unsigned O)
LoopUnrollOptions & setUpperBound(bool UpperBound)
Enables or disables the use of trip count upper bound in loop unrolling.
LoopUnrollOptions & setRuntime(bool Runtime)
Enables or disables unrolling of loops with runtime trip count.
LoopUnrollOptions & setProfileBasedPeeling(int O)
LoopVectorizeOptions & setVectorizeOnlyWhenForced(bool Value)
LoopVectorizeOptions & setInterleaveOnlyWhenForced(bool Value)
A CRTP mix-in to automatically provide informational APIs needed for passes.
RegAllocFilterFunc Filter