351 "^(default|thinlto-pre-link|thinlto|lto-pre-link|lto)<(O[0123sz])>$");
355 "print-pipeline-passes",
356 cl::desc(
"Print a '-passes' compatible string describing the pipeline "
357 "(best-effort only)."));
369class TriggerCrashModulePass :
public PassInfoMixin<TriggerCrashModulePass> {
378class TriggerCrashFunctionPass
385 static StringRef name() {
return "TriggerCrashFunctionPass"; }
390class TriggerVerifierErrorPass
398 GlobalValue::LinkageTypes::InternalLinkage,
399 "__bad_alias",
nullptr, &M);
419 static StringRef name() {
return "TriggerVerifierErrorPass"; }
424class RequireAllMachineFunctionPropertiesPass
425 :
public PassInfoMixin<RequireAllMachineFunctionPropertiesPass> {
434 MFProps.
set(MachineFunctionProperties::Property::FailedISel);
435 MFProps.
set(MachineFunctionProperties::Property::FailsVerification);
436 MFProps.
set(MachineFunctionProperties::Property::IsSSA);
437 MFProps.
set(MachineFunctionProperties::Property::Legalized);
438 MFProps.
set(MachineFunctionProperties::Property::NoPHIs);
439 MFProps.
set(MachineFunctionProperties::Property::NoVRegs);
440 MFProps.
set(MachineFunctionProperties::Property::RegBankSelected);
441 MFProps.
set(MachineFunctionProperties::Property::Selected);
442 MFProps.
set(MachineFunctionProperties::Property::TiedOpsRewritten);
443 MFProps.
set(MachineFunctionProperties::Property::TracksDebugUserValues);
444 MFProps.
set(MachineFunctionProperties::Property::TracksLiveness);
447 static StringRef name() {
return "RequireAllMachineFunctionPropertiesPass"; }
453 std::optional<PGOOptions> PGOOpt,
455 : TM(TM), PTO(PTO), PGOOpt(PGOOpt),
PIC(
PIC) {
457 TM->registerPassBuilderCallbacks(*
this);
463#define MODULE_PASS(NAME, CREATE_PASS) \
464 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
465#define MODULE_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
466 PIC->addClassToPassName(CLASS, NAME);
467#define MODULE_ANALYSIS(NAME, CREATE_PASS) \
468 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
469#define FUNCTION_PASS(NAME, CREATE_PASS) \
470 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
471#define FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
472 PIC->addClassToPassName(CLASS, NAME);
473#define FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
474 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
475#define LOOPNEST_PASS(NAME, CREATE_PASS) \
476 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
477#define LOOP_PASS(NAME, CREATE_PASS) \
478 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
479#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
480 PIC->addClassToPassName(CLASS, NAME);
481#define LOOP_ANALYSIS(NAME, CREATE_PASS) \
482 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
483#define CGSCC_PASS(NAME, CREATE_PASS) \
484 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
485#define CGSCC_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
486 PIC->addClassToPassName(CLASS, NAME);
487#define CGSCC_ANALYSIS(NAME, CREATE_PASS) \
488 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
489#include "PassRegistry.def"
491#define MACHINE_FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
492 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
493#define MACHINE_FUNCTION_PASS(NAME, CREATE_PASS) \
494 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
495#include "llvm/Passes/MachinePassRegistry.def"
501#define MODULE_ANALYSIS(NAME, CREATE_PASS) \
502 MAM.registerPass([&] { return CREATE_PASS; });
503#include "PassRegistry.def"
505 for (
auto &
C : ModuleAnalysisRegistrationCallbacks)
510#define CGSCC_ANALYSIS(NAME, CREATE_PASS) \
511 CGAM.registerPass([&] { return CREATE_PASS; });
512#include "PassRegistry.def"
514 for (
auto &
C : CGSCCAnalysisRegistrationCallbacks)
524#define FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
525 FAM.registerPass([&] { return CREATE_PASS; });
526#include "PassRegistry.def"
528 for (
auto &
C : FunctionAnalysisRegistrationCallbacks)
535#define MACHINE_FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
536 MFAM.registerPass([&] { return CREATE_PASS; });
537#include "llvm/Passes/MachinePassRegistry.def"
539 for (
auto &
C : MachineFunctionAnalysisRegistrationCallbacks)
544#define LOOP_ANALYSIS(NAME, CREATE_PASS) \
545 LAM.registerPass([&] { return CREATE_PASS; });
546#include "PassRegistry.def"
548 for (
auto &
C : LoopAnalysisRegistrationCallbacks)
552static std::optional<std::pair<bool, bool>>
554 std::pair<bool, bool> Params;
555 if (!
Name.consume_front(
"function"))
559 if (!
Name.consume_front(
"<") || !
Name.consume_back(
">"))
561 while (!
Name.empty()) {
562 auto [Front, Back] =
Name.split(
';');
564 if (Front ==
"eager-inv")
566 else if (Front ==
"no-rerun")
567 Params.second =
true;
575 if (!
Name.consume_front(
"devirt<") || !
Name.consume_back(
">"))
578 if (
Name.getAsInteger(0, Count) || Count < 0)
598 while (!Params.
empty()) {
600 std::tie(ParamName, Params) = Params.
split(
';');
602 if (ParamName == OptionName) {
605 return make_error<StringError>(
620 while (!Params.
empty()) {
622 std::tie(ParamName, Params) = Params.
split(
';');
626 return make_error<StringError>(
627 formatv(
"invalid HardwareLoopPass parameter '{0}' ", ParamName).str(),
632 if (ParamName.
consume_front(
"hardware-loop-counter-bitwidth=")) {
635 return make_error<StringError>(
636 formatv(
"invalid HardwareLoopPass parameter '{0}' ", ParamName).str(),
641 if (ParamName ==
"force-hardware-loops") {
643 }
else if (ParamName ==
"force-hardware-loop-phi") {
645 }
else if (ParamName ==
"force-nested-hardware-loop") {
647 }
else if (ParamName ==
"force-hardware-loop-guard") {
650 return make_error<StringError>(
651 formatv(
"invalid HardwarePass parameter '{0}' ", ParamName).str(),
655 return HardwareLoopOpts;
661 while (!Params.
empty()) {
663 std::tie(ParamName, Params) = Params.
split(
';');
664 std::optional<OptimizationLevel> OptLevel =
parseOptLevel(ParamName);
666 if (OptLevel && !OptLevel->isOptimizingForSize()) {
667 UnrollOpts.
setOptLevel(OptLevel->getSpeedupLevel());
673 return make_error<StringError>(
674 formatv(
"invalid LoopUnrollPass parameter '{0}' ", ParamName).str(),
681 if (ParamName ==
"partial") {
683 }
else if (ParamName ==
"peeling") {
685 }
else if (ParamName ==
"profile-peeling") {
687 }
else if (ParamName ==
"runtime") {
689 }
else if (ParamName ==
"upperbound") {
692 return make_error<StringError>(
693 formatv(
"invalid LoopUnrollPass parameter '{0}' ", ParamName).str(),
702 Params,
"vfe-linkage-unit-visibility",
"GlobalDCE");
722 Params,
"skip-non-recursive-function-attrs",
"PostOrderFunctionAttrs");
731 return make_error<StringError>(
732 formatv(
"too many CFGuardPass parameters '{0}' ", Params).str(),
735 if (Param ==
"check")
737 if (Param ==
"dispatch")
740 return make_error<StringError>(
741 formatv(
"invalid CFGuardPass mechanism: '{0}' ", Param).str(),
751 "EntryExitInstrumenter");
760 "LowerMatrixIntrinsics");
765 while (!Params.
empty()) {
767 std::tie(ParamName, Params) = Params.
split(
';');
769 if (ParamName ==
"kernel") {
770 Result.CompileKernel =
true;
772 return make_error<StringError>(
773 formatv(
"invalid AddressSanitizer pass parameter '{0}' ", ParamName)
783 while (!Params.
empty()) {
785 std::tie(ParamName, Params) = Params.
split(
';');
787 if (ParamName ==
"recover") {
789 }
else if (ParamName ==
"kernel") {
790 Result.CompileKernel =
true;
792 return make_error<StringError>(
793 formatv(
"invalid HWAddressSanitizer pass parameter '{0}' ", ParamName)
803 while (!Params.
empty()) {
805 std::tie(ParamName, Params) = Params.
split(
';');
807 if (ParamName ==
"thinlto") {
809 }
else if (ParamName ==
"emit-summary") {
810 Result.EmitLTOSummary =
true;
812 return make_error<StringError>(
813 formatv(
"invalid EmbedBitcode pass parameter '{0}' ", ParamName)
823 while (!Params.
empty()) {
825 std::tie(ParamName, Params) = Params.
split(
';');
827 if (ParamName ==
"recover") {
829 }
else if (ParamName ==
"kernel") {
833 return make_error<StringError>(
834 formatv(
"invalid argument to MemorySanitizer pass track-origins "
839 }
else if (ParamName ==
"eager-checks") {
840 Result.EagerChecks =
true;
842 return make_error<StringError>(
843 formatv(
"invalid MemorySanitizer pass parameter '{0}' ", ParamName)
854 while (!Params.
empty()) {
856 std::tie(ParamName, Params) = Params.
split(
';');
859 if (ParamName ==
"speculate-blocks") {
861 }
else if (ParamName ==
"simplify-cond-branch") {
863 }
else if (ParamName ==
"forward-switch-cond") {
865 }
else if (ParamName ==
"switch-range-to-icmp") {
867 }
else if (ParamName ==
"switch-to-lookup") {
869 }
else if (ParamName ==
"keep-loops") {
871 }
else if (ParamName ==
"hoist-common-insts") {
873 }
else if (ParamName ==
"hoist-loads-stores-with-cond-faulting") {
875 }
else if (ParamName ==
"sink-common-insts") {
877 }
else if (ParamName ==
"speculate-unpredictables") {
880 APInt BonusInstThreshold;
882 return make_error<StringError>(
883 formatv(
"invalid argument to SimplifyCFG pass bonus-threshold "
889 return make_error<StringError>(
890 formatv(
"invalid SimplifyCFG pass parameter '{0}' ", ParamName).str(),
901 Result.setVerifyFixpoint(
true);
902 while (!Params.
empty()) {
904 std::tie(ParamName, Params) = Params.
split(
';');
907 if (ParamName ==
"verify-fixpoint") {
912 return make_error<StringError>(
913 formatv(
"invalid argument to InstCombine pass max-iterations "
919 return make_error<StringError>(
920 formatv(
"invalid InstCombine pass parameter '{0}' ", ParamName).str(),
930 while (!Params.
empty()) {
932 std::tie(ParamName, Params) = Params.
split(
';');
935 if (ParamName ==
"interleave-forced-only") {
937 }
else if (ParamName ==
"vectorize-forced-only") {
940 return make_error<StringError>(
941 formatv(
"invalid LoopVectorize parameter '{0}' ", ParamName).str(),
949 std::pair<bool, bool>
Result = {
false,
true};
950 while (!Params.
empty()) {
952 std::tie(ParamName, Params) = Params.
split(
';');
955 if (ParamName ==
"nontrivial") {
957 }
else if (ParamName ==
"trivial") {
960 return make_error<StringError>(
961 formatv(
"invalid LoopUnswitch pass parameter '{0}' ", ParamName)
971 while (!Params.
empty()) {
973 std::tie(ParamName, Params) = Params.
split(
';');
976 if (ParamName ==
"allowspeculation") {
979 return make_error<StringError>(
980 formatv(
"invalid LICM pass parameter '{0}' ", ParamName).str(),
988 std::pair<bool, bool>
Result = {
true,
false};
989 while (!Params.
empty()) {
991 std::tie(ParamName, Params) = Params.
split(
';');
994 if (ParamName ==
"header-duplication") {
996 }
else if (ParamName ==
"prepare-for-lto") {
999 return make_error<StringError>(
1000 formatv(
"invalid LoopRotate pass parameter '{0}' ", ParamName).str(),
1009 while (!Params.
empty()) {
1011 std::tie(ParamName, Params) = Params.
split(
';');
1014 if (ParamName ==
"split-footer-bb") {
1017 return make_error<StringError>(
1018 formatv(
"invalid MergedLoadStoreMotion pass parameter '{0}' ",
1029 while (!Params.
empty()) {
1031 std::tie(ParamName, Params) = Params.
split(
';');
1034 if (ParamName ==
"pre") {
1036 }
else if (ParamName ==
"load-pre") {
1038 }
else if (ParamName ==
"split-backedge-load-pre") {
1040 }
else if (ParamName ==
"memdep") {
1043 return make_error<StringError>(
1044 formatv(
"invalid GVN pass parameter '{0}' ", ParamName).str(),
1053 while (!Params.
empty()) {
1055 std::tie(ParamName, Params) = Params.
split(
';');
1058 if (ParamName ==
"func-spec")
1061 return make_error<StringError>(
1062 formatv(
"invalid IPSCCP pass parameter '{0}' ", ParamName).str(),
1070 while (!Params.
empty()) {
1072 std::tie(ParamName, Params) = Params.
split(
';');
1076 return make_error<StringError>(
1077 formatv(
"invalid argument to Scalarizer pass min-bits "
1078 "parameter: '{0}' ",
1088 if (ParamName ==
"load-store")
1090 else if (ParamName ==
"variable-insert-extract")
1093 return make_error<StringError>(
1094 formatv(
"invalid Scalarizer pass parameter '{0}' ", ParamName).str(),
1103 if (Params.
empty() || Params ==
"modify-cfg")
1105 if (Params ==
"preserve-cfg")
1107 return make_error<StringError>(
1108 formatv(
"invalid SROA pass parameter '{0}' (either preserve-cfg or "
1109 "modify-cfg can be specified)",
1116parseStackLifetimeOptions(
StringRef Params) {
1118 while (!Params.
empty()) {
1120 std::tie(ParamName, Params) = Params.
split(
';');
1122 if (ParamName ==
"may") {
1124 }
else if (ParamName ==
"must") {
1127 return make_error<StringError>(
1128 formatv(
"invalid StackLifetime parameter '{0}' ", ParamName).str(),
1137 "DependenceAnalysisPrinter");
1142 "SeparateConstOffsetFromGEP");
1151parseFunctionSimplificationPipelineOptions(
StringRef Params) {
1154 return make_error<StringError>(
1155 formatv(
"invalid function-simplification parameter '{0}' ", Params)
1164 "MemorySSAPrinterPass");
1169 "SpeculativeExecutionPass");
1174 while (!Params.
empty()) {
1176 std::tie(ParamName, Params) = Params.
split(
';');
1181 return make_error<StringError>(
1182 formatv(
"invalid MemProfUse pass parameter '{0}' ", ParamName).str(),
1190parseStructuralHashPrinterPassOptions(
StringRef Params) {
1193 if (Params ==
"detailed")
1195 if (Params ==
"call-target-ignored")
1197 return make_error<StringError>(
1198 formatv(
"invalid structural hash printer parameter '{0}' ", Params).str(),
1204 "WinEHPreparePass");
1209 while (!Params.
empty()) {
1211 std::tie(ParamName, Params) = Params.
split(
';');
1214 if (ParamName ==
"group-by-use")
1216 else if (ParamName ==
"ignore-single-use")
1218 else if (ParamName ==
"merge-const")
1220 else if (ParamName ==
"merge-external")
1224 return make_error<StringError>(
1225 formatv(
"invalid GlobalMergePass parameter '{0}' ", ParamName)
1235 while (!Params.
empty()) {
1237 std::tie(ParamName, Params) = Params.
split(
';');
1242 return make_error<StringError>(
1243 formatv(
"invalid Internalize pass parameter '{0}' ", ParamName).str(),
1254 while (!Params.
empty()) {
1256 std::tie(ParamName, Params) = Params.
split(
';');
1259 std::optional<RegAllocFilterFunc>
Filter =
1262 return make_error<StringError>(
1263 formatv(
"invalid regallocfast register filter '{0}' ", ParamName)
1272 if (ParamName ==
"no-clear-vregs") {
1277 return make_error<StringError>(
1278 formatv(
"invalid regallocfast pass parameter '{0}' ", ParamName).str(),
1285parseBoundsCheckingOptions(
StringRef Params) {
1288 while (!Params.
empty()) {
1290 std::tie(ParamName, Params) = Params.
split(
';');
1291 if (ParamName ==
"trap") {
1293 }
else if (ParamName ==
"rt") {
1295 }
else if (ParamName ==
"rt-abort") {
1297 }
else if (ParamName ==
"min-rt") {
1299 }
else if (ParamName ==
"min-rt-abort") {
1302 return make_error<StringError>(
1303 formatv(
"invalid BoundsChecking pass parameter '{0}' ", ParamName)
1316 return Name.starts_with(
"default") ||
Name.starts_with(
"thinlto") ||
1317 Name.starts_with(
"lto");
1328template <
typename PassManagerT,
typename CallbacksT>
1330 if (!Callbacks.empty()) {
1331 PassManagerT DummyPM;
1332 for (
auto &CB : Callbacks)
1333 if (CB(
Name, DummyPM, {}))
1339template <
typename CallbacksT>
1345 StringRef NameNoBracket =
Name.take_until([](
char C) {
return C ==
'<'; });
1348 if (
Name ==
"module")
1350 if (
Name ==
"cgscc")
1352 if (NameNoBracket ==
"function")
1354 if (
Name ==
"coro-cond")
1357#define MODULE_PASS(NAME, CREATE_PASS) \
1360#define MODULE_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1361 if (PassBuilder::checkParametrizedPassName(Name, NAME)) \
1363#define MODULE_ANALYSIS(NAME, CREATE_PASS) \
1364 if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
1366#include "PassRegistry.def"
1368 return callbacksAcceptPassName<ModulePassManager>(
Name, Callbacks);
1371template <
typename CallbacksT>
1374 StringRef NameNoBracket =
Name.take_until([](
char C) {
return C ==
'<'; });
1375 if (
Name ==
"cgscc")
1377 if (NameNoBracket ==
"function")
1384#define CGSCC_PASS(NAME, CREATE_PASS) \
1387#define CGSCC_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1388 if (PassBuilder::checkParametrizedPassName(Name, NAME)) \
1390#define CGSCC_ANALYSIS(NAME, CREATE_PASS) \
1391 if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
1393#include "PassRegistry.def"
1395 return callbacksAcceptPassName<CGSCCPassManager>(
Name, Callbacks);
1398template <
typename CallbacksT>
1401 StringRef NameNoBracket =
Name.take_until([](
char C) {
return C ==
'<'; });
1402 if (NameNoBracket ==
"function")
1404 if (
Name ==
"loop" ||
Name ==
"loop-mssa" ||
Name ==
"machine-function")
1407#define FUNCTION_PASS(NAME, CREATE_PASS) \
1410#define FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1411 if (PassBuilder::checkParametrizedPassName(Name, NAME)) \
1413#define FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
1414 if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
1416#include "PassRegistry.def"
1418 return callbacksAcceptPassName<FunctionPassManager>(
Name, Callbacks);
1421template <
typename CallbacksT>
1424 if (
Name ==
"machine-function")
1427#define MACHINE_FUNCTION_PASS(NAME, CREATE_PASS) \
1430#define MACHINE_FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, \
1432 if (PassBuilder::checkParametrizedPassName(Name, NAME)) \
1435#define MACHINE_FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
1436 if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
1439#include "llvm/Passes/MachinePassRegistry.def"
1441 return callbacksAcceptPassName<MachineFunctionPassManager>(
Name, Callbacks);
1444template <
typename CallbacksT>
1446 bool &UseMemorySSA) {
1447 UseMemorySSA =
false;
1450 UseMemorySSA =
true;
1454#define LOOPNEST_PASS(NAME, CREATE_PASS) \
1457#include "PassRegistry.def"
1459 return callbacksAcceptPassName<LoopPassManager>(
Name, Callbacks);
1462template <
typename CallbacksT>
1464 bool &UseMemorySSA) {
1465 UseMemorySSA =
false;
1468 UseMemorySSA =
true;
1472#define LOOP_PASS(NAME, CREATE_PASS) \
1475#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1476 if (PassBuilder::checkParametrizedPassName(Name, NAME)) \
1478#define LOOP_ANALYSIS(NAME, CREATE_PASS) \
1479 if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
1481#include "PassRegistry.def"
1483 return callbacksAcceptPassName<LoopPassManager>(
Name, Callbacks);
1486std::optional<std::vector<PassBuilder::PipelineElement>>
1487PassBuilder::parsePipelineText(
StringRef Text) {
1488 std::vector<PipelineElement> ResultPipeline;
1493 std::vector<PipelineElement> &Pipeline = *PipelineStack.
back();
1494 size_t Pos =
Text.find_first_of(
",()");
1495 Pipeline.push_back({
Text.substr(0, Pos), {}});
1498 if (Pos ==
Text.npos)
1501 char Sep =
Text[Pos];
1509 PipelineStack.
push_back(&Pipeline.back().InnerPipeline);
1513 assert(Sep ==
')' &&
"Bogus separator!");
1518 if (PipelineStack.
size() == 1)
1519 return std::nullopt;
1522 }
while (
Text.consume_front(
")"));
1530 if (!
Text.consume_front(
","))
1531 return std::nullopt;
1534 if (PipelineStack.
size() > 1)
1536 return std::nullopt;
1538 assert(PipelineStack.
back() == &ResultPipeline &&
1539 "Wrong pipeline at the bottom of the stack!");
1540 return {std::move(ResultPipeline)};
1544 const PipelineElement &E) {
1545 auto &
Name = E.Name;
1546 auto &InnerPipeline = E.InnerPipeline;
1549 if (!InnerPipeline.empty()) {
1550 if (
Name ==
"module") {
1552 if (
auto Err = parseModulePassPipeline(NestedMPM, InnerPipeline))
1554 MPM.
addPass(std::move(NestedMPM));
1557 if (
Name ==
"coro-cond") {
1559 if (
auto Err = parseModulePassPipeline(NestedMPM, InnerPipeline))
1564 if (
Name ==
"cgscc") {
1566 if (
auto Err = parseCGSCCPassPipeline(CGPM, InnerPipeline))
1573 return make_error<StringError>(
1574 "cannot have a no-rerun module to function adaptor",
1577 if (
auto Err = parseFunctionPassPipeline(FPM, InnerPipeline))
1584 for (
auto &
C : ModulePipelineParsingCallbacks)
1585 if (
C(
Name, MPM, InnerPipeline))
1589 return make_error<StringError>(
1590 formatv(
"invalid use of '{0}' pass as module pipeline",
Name).str(),
1599 return make_error<StringError>(
1600 formatv(
"unknown default pipeline alias '{0}'",
Name).str(),
1603 assert(Matches.
size() == 3 &&
"Must capture two matched strings!");
1615 if (Matches[1] ==
"default") {
1617 }
else if (Matches[1] ==
"thinlto-pre-link") {
1619 }
else if (Matches[1] ==
"thinlto") {
1621 }
else if (Matches[1] ==
"lto-pre-link") {
1630 assert(Matches[1] ==
"lto" &&
"Not one of the matched options!");
1637#define MODULE_PASS(NAME, CREATE_PASS) \
1638 if (Name == NAME) { \
1639 MPM.addPass(CREATE_PASS); \
1640 return Error::success(); \
1642#define MODULE_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1643 if (checkParametrizedPassName(Name, NAME)) { \
1644 auto Params = parsePassParameters(PARSER, Name, NAME); \
1646 return Params.takeError(); \
1647 MPM.addPass(CREATE_PASS(Params.get())); \
1648 return Error::success(); \
1650#define MODULE_ANALYSIS(NAME, CREATE_PASS) \
1651 if (Name == "require<" NAME ">") { \
1653 RequireAnalysisPass< \
1654 std::remove_reference_t<decltype(CREATE_PASS)>, Module>()); \
1655 return Error::success(); \
1657 if (Name == "invalidate<" NAME ">") { \
1658 MPM.addPass(InvalidateAnalysisPass< \
1659 std::remove_reference_t<decltype(CREATE_PASS)>>()); \
1660 return Error::success(); \
1662#define CGSCC_PASS(NAME, CREATE_PASS) \
1663 if (Name == NAME) { \
1664 MPM.addPass(createModuleToPostOrderCGSCCPassAdaptor(CREATE_PASS)); \
1665 return Error::success(); \
1667#define CGSCC_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1668 if (checkParametrizedPassName(Name, NAME)) { \
1669 auto Params = parsePassParameters(PARSER, Name, NAME); \
1671 return Params.takeError(); \
1673 createModuleToPostOrderCGSCCPassAdaptor(CREATE_PASS(Params.get()))); \
1674 return Error::success(); \
1676#define FUNCTION_PASS(NAME, CREATE_PASS) \
1677 if (Name == NAME) { \
1678 MPM.addPass(createModuleToFunctionPassAdaptor(CREATE_PASS)); \
1679 return Error::success(); \
1681#define FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1682 if (checkParametrizedPassName(Name, NAME)) { \
1683 auto Params = parsePassParameters(PARSER, Name, NAME); \
1685 return Params.takeError(); \
1686 MPM.addPass(createModuleToFunctionPassAdaptor(CREATE_PASS(Params.get()))); \
1687 return Error::success(); \
1689#define LOOPNEST_PASS(NAME, CREATE_PASS) \
1690 if (Name == NAME) { \
1691 MPM.addPass(createModuleToFunctionPassAdaptor( \
1692 createFunctionToLoopPassAdaptor(CREATE_PASS, false, false))); \
1693 return Error::success(); \
1695#define LOOP_PASS(NAME, CREATE_PASS) \
1696 if (Name == NAME) { \
1697 MPM.addPass(createModuleToFunctionPassAdaptor( \
1698 createFunctionToLoopPassAdaptor(CREATE_PASS, false, false))); \
1699 return Error::success(); \
1701#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1702 if (checkParametrizedPassName(Name, NAME)) { \
1703 auto Params = parsePassParameters(PARSER, Name, NAME); \
1705 return Params.takeError(); \
1707 createModuleToFunctionPassAdaptor(createFunctionToLoopPassAdaptor( \
1708 CREATE_PASS(Params.get()), false, false))); \
1709 return Error::success(); \
1711#include "PassRegistry.def"
1713 for (
auto &
C : ModulePipelineParsingCallbacks)
1714 if (
C(
Name, MPM, InnerPipeline))
1716 return make_error<StringError>(
1722 const PipelineElement &E) {
1723 auto &
Name = E.Name;
1724 auto &InnerPipeline = E.InnerPipeline;
1727 if (!InnerPipeline.empty()) {
1728 if (
Name ==
"cgscc") {
1730 if (
auto Err = parseCGSCCPassPipeline(NestedCGPM, InnerPipeline))
1733 CGPM.
addPass(std::move(NestedCGPM));
1738 if (
auto Err = parseFunctionPassPipeline(FPM, InnerPipeline))
1742 std::move(FPM), Params->first, Params->second));
1747 if (
auto Err = parseCGSCCPassPipeline(NestedCGPM, InnerPipeline))
1754 for (
auto &
C : CGSCCPipelineParsingCallbacks)
1755 if (
C(
Name, CGPM, InnerPipeline))
1759 return make_error<StringError>(
1760 formatv(
"invalid use of '{0}' pass as cgscc pipeline",
Name).str(),
1765#define CGSCC_PASS(NAME, CREATE_PASS) \
1766 if (Name == NAME) { \
1767 CGPM.addPass(CREATE_PASS); \
1768 return Error::success(); \
1770#define CGSCC_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1771 if (checkParametrizedPassName(Name, NAME)) { \
1772 auto Params = parsePassParameters(PARSER, Name, NAME); \
1774 return Params.takeError(); \
1775 CGPM.addPass(CREATE_PASS(Params.get())); \
1776 return Error::success(); \
1778#define CGSCC_ANALYSIS(NAME, CREATE_PASS) \
1779 if (Name == "require<" NAME ">") { \
1780 CGPM.addPass(RequireAnalysisPass< \
1781 std::remove_reference_t<decltype(CREATE_PASS)>, \
1782 LazyCallGraph::SCC, CGSCCAnalysisManager, LazyCallGraph &, \
1783 CGSCCUpdateResult &>()); \
1784 return Error::success(); \
1786 if (Name == "invalidate<" NAME ">") { \
1787 CGPM.addPass(InvalidateAnalysisPass< \
1788 std::remove_reference_t<decltype(CREATE_PASS)>>()); \
1789 return Error::success(); \
1791#define FUNCTION_PASS(NAME, CREATE_PASS) \
1792 if (Name == NAME) { \
1793 CGPM.addPass(createCGSCCToFunctionPassAdaptor(CREATE_PASS)); \
1794 return Error::success(); \
1796#define FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1797 if (checkParametrizedPassName(Name, NAME)) { \
1798 auto Params = parsePassParameters(PARSER, Name, NAME); \
1800 return Params.takeError(); \
1801 CGPM.addPass(createCGSCCToFunctionPassAdaptor(CREATE_PASS(Params.get()))); \
1802 return Error::success(); \
1804#define LOOPNEST_PASS(NAME, CREATE_PASS) \
1805 if (Name == NAME) { \
1806 CGPM.addPass(createCGSCCToFunctionPassAdaptor( \
1807 createFunctionToLoopPassAdaptor(CREATE_PASS, false, false))); \
1808 return Error::success(); \
1810#define LOOP_PASS(NAME, CREATE_PASS) \
1811 if (Name == NAME) { \
1812 CGPM.addPass(createCGSCCToFunctionPassAdaptor( \
1813 createFunctionToLoopPassAdaptor(CREATE_PASS, false, false))); \
1814 return Error::success(); \
1816#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1817 if (checkParametrizedPassName(Name, NAME)) { \
1818 auto Params = parsePassParameters(PARSER, Name, NAME); \
1820 return Params.takeError(); \
1822 createCGSCCToFunctionPassAdaptor(createFunctionToLoopPassAdaptor( \
1823 CREATE_PASS(Params.get()), false, false))); \
1824 return Error::success(); \
1826#include "PassRegistry.def"
1828 for (
auto &
C : CGSCCPipelineParsingCallbacks)
1829 if (
C(
Name, CGPM, InnerPipeline))
1831 return make_error<StringError>(
1837 const PipelineElement &E) {
1838 auto &
Name = E.Name;
1839 auto &InnerPipeline = E.InnerPipeline;
1842 if (!InnerPipeline.empty()) {
1843 if (
Name ==
"function") {
1845 if (
auto Err = parseFunctionPassPipeline(NestedFPM, InnerPipeline))
1848 FPM.
addPass(std::move(NestedFPM));
1851 if (
Name ==
"loop" ||
Name ==
"loop-mssa") {
1853 if (
auto Err = parseLoopPassPipeline(LPM, InnerPipeline))
1856 bool UseMemorySSA = (
Name ==
"loop-mssa");
1858 return Pipeline.Name.contains(
"simple-loop-unswitch");
1860 bool UseBPI =
llvm::any_of(InnerPipeline, [](
auto Pipeline) {
1861 return Pipeline.Name ==
"loop-predication";
1867 if (
Name ==
"machine-function") {
1869 if (
auto Err = parseMachinePassPipeline(MFPM, InnerPipeline))
1875 for (
auto &
C : FunctionPipelineParsingCallbacks)
1876 if (
C(
Name, FPM, InnerPipeline))
1880 return make_error<StringError>(
1881 formatv(
"invalid use of '{0}' pass as function pipeline",
Name).str(),
1886#define FUNCTION_PASS(NAME, CREATE_PASS) \
1887 if (Name == NAME) { \
1888 FPM.addPass(CREATE_PASS); \
1889 return Error::success(); \
1891#define FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1892 if (checkParametrizedPassName(Name, NAME)) { \
1893 auto Params = parsePassParameters(PARSER, Name, NAME); \
1895 return Params.takeError(); \
1896 FPM.addPass(CREATE_PASS(Params.get())); \
1897 return Error::success(); \
1899#define FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
1900 if (Name == "require<" NAME ">") { \
1902 RequireAnalysisPass< \
1903 std::remove_reference_t<decltype(CREATE_PASS)>, Function>()); \
1904 return Error::success(); \
1906 if (Name == "invalidate<" NAME ">") { \
1907 FPM.addPass(InvalidateAnalysisPass< \
1908 std::remove_reference_t<decltype(CREATE_PASS)>>()); \
1909 return Error::success(); \
1915#define LOOPNEST_PASS(NAME, CREATE_PASS) \
1916 if (Name == NAME) { \
1917 FPM.addPass(createFunctionToLoopPassAdaptor(CREATE_PASS, false, false)); \
1918 return Error::success(); \
1920#define LOOP_PASS(NAME, CREATE_PASS) \
1921 if (Name == NAME) { \
1922 FPM.addPass(createFunctionToLoopPassAdaptor(CREATE_PASS, false, false)); \
1923 return Error::success(); \
1925#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1926 if (checkParametrizedPassName(Name, NAME)) { \
1927 auto Params = parsePassParameters(PARSER, Name, NAME); \
1929 return Params.takeError(); \
1930 FPM.addPass(createFunctionToLoopPassAdaptor(CREATE_PASS(Params.get()), \
1932 return Error::success(); \
1934#include "PassRegistry.def"
1936 for (
auto &
C : FunctionPipelineParsingCallbacks)
1937 if (
C(
Name, FPM, InnerPipeline))
1939 return make_error<StringError>(
1940 formatv(
"unknown function pass '{0}'",
Name).str(),
1945 const PipelineElement &E) {
1947 auto &InnerPipeline = E.InnerPipeline;
1950 if (!InnerPipeline.empty()) {
1951 if (
Name ==
"loop") {
1953 if (
auto Err = parseLoopPassPipeline(NestedLPM, InnerPipeline))
1956 LPM.
addPass(std::move(NestedLPM));
1960 for (
auto &
C : LoopPipelineParsingCallbacks)
1961 if (
C(
Name, LPM, InnerPipeline))
1965 return make_error<StringError>(
1966 formatv(
"invalid use of '{0}' pass as loop pipeline",
Name).str(),
1971#define LOOPNEST_PASS(NAME, CREATE_PASS) \
1972 if (Name == NAME) { \
1973 LPM.addPass(CREATE_PASS); \
1974 return Error::success(); \
1976#define LOOP_PASS(NAME, CREATE_PASS) \
1977 if (Name == NAME) { \
1978 LPM.addPass(CREATE_PASS); \
1979 return Error::success(); \
1981#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1982 if (checkParametrizedPassName(Name, NAME)) { \
1983 auto Params = parsePassParameters(PARSER, Name, NAME); \
1985 return Params.takeError(); \
1986 LPM.addPass(CREATE_PASS(Params.get())); \
1987 return Error::success(); \
1989#define LOOP_ANALYSIS(NAME, CREATE_PASS) \
1990 if (Name == "require<" NAME ">") { \
1991 LPM.addPass(RequireAnalysisPass< \
1992 std::remove_reference_t<decltype(CREATE_PASS)>, Loop, \
1993 LoopAnalysisManager, LoopStandardAnalysisResults &, \
1995 return Error::success(); \
1997 if (Name == "invalidate<" NAME ">") { \
1998 LPM.addPass(InvalidateAnalysisPass< \
1999 std::remove_reference_t<decltype(CREATE_PASS)>>()); \
2000 return Error::success(); \
2002#include "PassRegistry.def"
2004 for (
auto &
C : LoopPipelineParsingCallbacks)
2005 if (
C(
Name, LPM, InnerPipeline))
2007 return make_error<StringError>(
formatv(
"unknown loop pass '{0}'",
Name).str(),
2012 const PipelineElement &E) {
2014 if (!E.InnerPipeline.empty())
2015 return make_error<StringError>(
"invalid pipeline",
2018#define MACHINE_MODULE_PASS(NAME, CREATE_PASS) \
2019 if (Name == NAME) { \
2020 MFPM.addPass(CREATE_PASS); \
2021 return Error::success(); \
2023#define MACHINE_FUNCTION_PASS(NAME, CREATE_PASS) \
2024 if (Name == NAME) { \
2025 MFPM.addPass(CREATE_PASS); \
2026 return Error::success(); \
2028#define MACHINE_FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, \
2030 if (checkParametrizedPassName(Name, NAME)) { \
2031 auto Params = parsePassParameters(PARSER, Name, NAME); \
2033 return Params.takeError(); \
2034 MFPM.addPass(CREATE_PASS(Params.get())); \
2035 return Error::success(); \
2037#define MACHINE_FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
2038 if (Name == "require<" NAME ">") { \
2040 RequireAnalysisPass<std::remove_reference_t<decltype(CREATE_PASS)>, \
2041 MachineFunction>()); \
2042 return Error::success(); \
2044 if (Name == "invalidate<" NAME ">") { \
2045 MFPM.addPass(InvalidateAnalysisPass< \
2046 std::remove_reference_t<decltype(CREATE_PASS)>>()); \
2047 return Error::success(); \
2049#include "llvm/Passes/MachinePassRegistry.def"
2051 for (
auto &
C : MachineFunctionPipelineParsingCallbacks)
2052 if (
C(
Name, MFPM, E.InnerPipeline))
2054 return make_error<StringError>(
2055 formatv(
"unknown machine pass '{0}'",
Name).str(),
2060#define MODULE_ALIAS_ANALYSIS(NAME, CREATE_PASS) \
2061 if (Name == NAME) { \
2062 AA.registerModuleAnalysis< \
2063 std::remove_reference_t<decltype(CREATE_PASS)>>(); \
2066#define FUNCTION_ALIAS_ANALYSIS(NAME, CREATE_PASS) \
2067 if (Name == NAME) { \
2068 AA.registerFunctionAnalysis< \
2069 std::remove_reference_t<decltype(CREATE_PASS)>>(); \
2072#include "PassRegistry.def"
2074 for (
auto &
C : AAParsingCallbacks)
2080Error PassBuilder::parseMachinePassPipeline(
2082 for (
const auto &Element : Pipeline) {
2083 if (
auto Err = parseMachinePass(MFPM, Element))
2091 for (
const auto &Element : Pipeline) {
2092 if (
auto Err = parseLoopPass(LPM, Element))
2098Error PassBuilder::parseFunctionPassPipeline(
2100 for (
const auto &Element : Pipeline) {
2101 if (
auto Err = parseFunctionPass(FPM, Element))
2109 for (
const auto &Element : Pipeline) {
2110 if (
auto Err = parseCGSCCPass(CGPM, Element))
2142 for (
const auto &Element : Pipeline) {
2143 if (
auto Err = parseModulePass(MPM, Element))
2154 auto Pipeline = parsePipelineText(PipelineText);
2155 if (!Pipeline || Pipeline->empty())
2156 return make_error<StringError>(
2157 formatv(
"invalid pipeline '{0}'", PipelineText).str(),
2167 Pipeline = {{
"cgscc", std::move(*Pipeline)}};
2169 FunctionPipelineParsingCallbacks)) {
2170 Pipeline = {{
"function", std::move(*Pipeline)}};
2173 Pipeline = {{
"function", {{UseMemorySSA ?
"loop-mssa" :
"loop",
2174 std::move(*Pipeline)}}}};
2175 }
else if (
isLoopPassName(FirstName, LoopPipelineParsingCallbacks,
2177 Pipeline = {{
"function", {{UseMemorySSA ?
"loop-mssa" :
"loop",
2178 std::move(*Pipeline)}}}};
2180 FirstName, MachineFunctionPipelineParsingCallbacks)) {
2181 Pipeline = {{
"function", {{
"machine-function", std::move(*Pipeline)}}}};
2183 for (
auto &
C : TopLevelPipelineParsingCallbacks)
2184 if (
C(MPM, *Pipeline))
2188 auto &InnerPipeline = Pipeline->front().InnerPipeline;
2189 return make_error<StringError>(
2190 formatv(
"unknown {0} name '{1}'",
2191 (InnerPipeline.empty() ?
"pass" :
"pipeline"), FirstName)
2197 if (
auto Err = parseModulePassPipeline(MPM, *Pipeline))
2205 auto Pipeline = parsePipelineText(PipelineText);
2206 if (!Pipeline || Pipeline->empty())
2207 return make_error<StringError>(
2208 formatv(
"invalid pipeline '{0}'", PipelineText).str(),
2213 return make_error<StringError>(
2214 formatv(
"unknown cgscc pass '{0}' in pipeline '{1}'", FirstName,
2219 if (
auto Err = parseCGSCCPassPipeline(CGPM, *Pipeline))
2228 auto Pipeline = parsePipelineText(PipelineText);
2229 if (!Pipeline || Pipeline->empty())
2230 return make_error<StringError>(
2231 formatv(
"invalid pipeline '{0}'", PipelineText).str(),
2236 return make_error<StringError>(
2237 formatv(
"unknown function pass '{0}' in pipeline '{1}'", FirstName,
2242 if (
auto Err = parseFunctionPassPipeline(FPM, *Pipeline))
2250 auto Pipeline = parsePipelineText(PipelineText);
2251 if (!Pipeline || Pipeline->empty())
2252 return make_error<StringError>(
2253 formatv(
"invalid pipeline '{0}'", PipelineText).str(),
2256 if (
auto Err = parseLoopPassPipeline(CGPM, *Pipeline))
2264 auto Pipeline = parsePipelineText(PipelineText);
2265 if (!Pipeline || Pipeline->empty())
2266 return make_error<StringError>(
2267 formatv(
"invalid machine pass pipeline '{0}'", PipelineText).str(),
2270 if (
auto Err = parseMachinePassPipeline(MFPM, *Pipeline))
2279 if (PipelineText ==
"default") {
2284 while (!PipelineText.
empty()) {
2286 std::tie(
Name, PipelineText) = PipelineText.
split(
',');
2287 if (!parseAAPassName(AA,
Name))
2288 return make_error<StringError>(
2289 formatv(
"unknown alias analysis name '{0}'",
Name).str(),
2296std::optional<RegAllocFilterFunc>
2298 if (FilterName ==
"all")
2300 for (
auto &
C : RegClassFilterParsingCallbacks)
2301 if (
auto F =
C(FilterName))
2303 return std::nullopt;
2311 OS <<
" " <<
PassName <<
"<" << Params <<
">\n";
2317 OS <<
"Module passes:\n";
2318#define MODULE_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2319#include "PassRegistry.def"
2321 OS <<
"Module passes with params:\n";
2322#define MODULE_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
2323 printPassName(NAME, PARAMS, OS);
2324#include "PassRegistry.def"
2326 OS <<
"Module analyses:\n";
2327#define MODULE_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2328#include "PassRegistry.def"
2330 OS <<
"Module alias analyses:\n";
2331#define MODULE_ALIAS_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2332#include "PassRegistry.def"
2334 OS <<
"CGSCC passes:\n";
2335#define CGSCC_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2336#include "PassRegistry.def"
2338 OS <<
"CGSCC passes with params:\n";
2339#define CGSCC_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
2340 printPassName(NAME, PARAMS, OS);
2341#include "PassRegistry.def"
2343 OS <<
"CGSCC analyses:\n";
2344#define CGSCC_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2345#include "PassRegistry.def"
2347 OS <<
"Function passes:\n";
2348#define FUNCTION_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2349#include "PassRegistry.def"
2351 OS <<
"Function passes with params:\n";
2352#define FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
2353 printPassName(NAME, PARAMS, OS);
2354#include "PassRegistry.def"
2356 OS <<
"Function analyses:\n";
2357#define FUNCTION_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2358#include "PassRegistry.def"
2360 OS <<
"Function alias analyses:\n";
2361#define FUNCTION_ALIAS_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2362#include "PassRegistry.def"
2364 OS <<
"LoopNest passes:\n";
2365#define LOOPNEST_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2366#include "PassRegistry.def"
2368 OS <<
"Loop passes:\n";
2369#define LOOP_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2370#include "PassRegistry.def"
2372 OS <<
"Loop passes with params:\n";
2373#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
2374 printPassName(NAME, PARAMS, OS);
2375#include "PassRegistry.def"
2377 OS <<
"Loop analyses:\n";
2378#define LOOP_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2379#include "PassRegistry.def"
2381 OS <<
"Machine module passes (WIP):\n";
2382#define MACHINE_MODULE_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2383#include "llvm/Passes/MachinePassRegistry.def"
2385 OS <<
"Machine function passes (WIP):\n";
2386#define MACHINE_FUNCTION_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2387#include "llvm/Passes/MachinePassRegistry.def"
2389 OS <<
"Machine function analyses (WIP):\n";
2390#define MACHINE_FUNCTION_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2391#include "llvm/Passes/MachinePassRegistry.def"
2397 TopLevelPipelineParsingCallbacks.push_back(
C);
unsigned const MachineRegisterInfo * MRI
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.
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...
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.
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 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.
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
PassInstrumentationCallbacks PIC
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 startsWithDefaultPipelineAliasPrefix(StringRef Name)
Tests whether a pass name starts with a valid prefix for a default pipeline alias.
static bool isLoopNestPassName(StringRef Name, CallbacksT &Callbacks, bool &UseMemorySSA)
static bool isMachineFunctionPassName(StringRef Name, CallbacksT &Callbacks)
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 const Regex DefaultAliasRegex("^(default|thinlto-pre-link|thinlto|lto-pre-link|lto)<(O[0123sz])>$")
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...
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
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.
A container for analyses that lazily runs them and caches their results.
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),...
LLVM Basic Block Representation.
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 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...
An analysis over an "outer" IR unit that provides access to an analysis manager over an "inner" IR un...
static constexpr LLT scalar(unsigned SizeInBits)
Get a low-level scalar or aggregate "bag of bits".
An RAII based helper class to modify MachineFunctionProperties when running pass.
Properties which a MachineFunction may have at a given point in time.
MachineFunctionProperties & set(Property P)
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
const MachineFunctionProperties & getProperties() const
Get the function properties.
A Module instance is used to store all the information related to an LLVM module.
static const OptimizationLevel O3
Optimize for fast execution as much as possible.
static const OptimizationLevel Oz
A very specialized mode that will optimize for code size at any and all costs.
static const OptimizationLevel O0
Disable as many optimizations as possible.
static const OptimizationLevel Os
Similar to O2 but tries to optimize for small code size instead of fast execution without triggering ...
static const OptimizationLevel O2
Optimize for fast execution as much as possible without triggering significant incremental compile ti...
static const OptimizationLevel O1
Optimize quickly without destroying debuggability.
This class provides access to building LLVM's passes.
void printPassNames(raw_ostream &OS)
Print pass names.
static bool checkParametrizedPassName(StringRef Name, StringRef PassName)
AAManager buildDefaultAAPipeline()
Build the default AAManager with the default alias analysis pipeline registered.
Error parseAAPipeline(AAManager &AA, StringRef PipelineText)
Parse a textual alias analysis pipeline into the provided AA manager.
ModulePassManager buildThinLTOPreLinkDefaultPipeline(OptimizationLevel Level)
Build a pre-link, ThinLTO-targeting default optimization pipeline to a pass manager.
PassBuilder(TargetMachine *TM=nullptr, PipelineTuningOptions PTO=PipelineTuningOptions(), std::optional< PGOOptions > PGOOpt=std::nullopt, PassInstrumentationCallbacks *PIC=nullptr)
void registerLoopAnalyses(LoopAnalysisManager &LAM)
Registers all available loop analysis passes.
std::optional< RegAllocFilterFunc > parseRegAllocFilter(StringRef RegAllocFilterName)
Parse RegAllocFilterName to get RegAllocFilterFunc.
void crossRegisterProxies(LoopAnalysisManager &LAM, FunctionAnalysisManager &FAM, CGSCCAnalysisManager &CGAM, ModuleAnalysisManager &MAM, MachineFunctionAnalysisManager *MFAM=nullptr)
Cross register the analysis managers through their proxies.
ModulePassManager buildPerModuleDefaultPipeline(OptimizationLevel Level, ThinOrFullLTOPhase Phase=ThinOrFullLTOPhase::None)
Build a per-module default optimization pipeline.
Error parsePassPipeline(ModulePassManager &MPM, StringRef PipelineText)
Parse a textual pass pipeline description into a ModulePassManager.
ModulePassManager buildLTODefaultPipeline(OptimizationLevel Level, ModuleSummaryIndex *ExportSummary)
Build an LTO default optimization pipeline to a pass manager.
ModulePassManager buildThinLTODefaultPipeline(OptimizationLevel Level, const ModuleSummaryIndex *ImportSummary)
Build a ThinLTO default optimization pipeline to a pass manager.
void registerModuleAnalyses(ModuleAnalysisManager &MAM)
Registers all available module analysis passes.
void registerCGSCCAnalyses(CGSCCAnalysisManager &CGAM)
Registers all available CGSCC analysis passes.
static Expected< bool > parseSinglePassOption(StringRef Params, StringRef OptionName, StringRef PassName)
Handle passes only accept one bool-valued parameter.
void registerMachineFunctionAnalyses(MachineFunctionAnalysisManager &MFAM)
Registers all available machine function analysis passes.
void registerParseTopLevelPipelineCallback(const std::function< bool(ModulePassManager &, ArrayRef< PipelineElement >)> &C)
Register a callback for a top-level pipeline entry.
ModulePassManager buildLTOPreLinkDefaultPipeline(OptimizationLevel Level)
Build a pre-link, LTO-targeting default optimization pipeline to a pass manager.
void registerFunctionAnalyses(FunctionAnalysisManager &FAM)
Registers all available function analysis passes.
LLVM_ATTRIBUTE_MINSIZE std::enable_if_t< is_detected< HasRunOnLoopT, PassT >::value > addPass(PassT &&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 PointerType * getUnqual(Type *ElementType)
This constructs a pointer to an object of the specified type in the default address space (address sp...
A set of analyses that are preserved following a run of a transformation pass.
static PreservedAnalyses none()
Convenience factory function for the empty preserved set.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
bool match(StringRef String, SmallVectorImpl< StringRef > *Matches=nullptr, std::string *Error=nullptr) const
matches - Match the regex against a given String.
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.
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.
This function has undefined behavior.
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,...
@ C
The default llvm calling convention, compatible with C.
PointerTypeMap run(const Module &M)
Compute the PointerTypeMap for the module M.
This is an optimization pass for GlobalISel generic memory operations.
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.
std::error_code inconvertibleErrorCode()
The value returned by this function can be returned from convertToErrorCode for Error values where no...
OuterAnalysisManagerProxy< ModuleAnalysisManager, MachineFunction > ModuleAnalysisManagerMachineFunctionProxy
Provide the ModuleAnalysisManager to Function proxy.
OuterAnalysisManagerProxy< ModuleAnalysisManager, Function > ModuleAnalysisManagerFunctionProxy
Provide the ModuleAnalysisManager to Function proxy.
InnerAnalysisManagerProxy< MachineFunctionAnalysisManager, Module > MachineFunctionAnalysisManagerModuleProxy
OuterAnalysisManagerProxy< ModuleAnalysisManager, LazyCallGraph::SCC, LazyCallGraph & > ModuleAnalysisManagerCGSCCProxy
A proxy from a ModuleAnalysisManager to an SCC.
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.
auto formatv(bool Validate, const char *Fmt, Ts &&...Vals)
CGSCCToFunctionPassAdaptor createCGSCCToFunctionPassAdaptor(FunctionPassT &&Pass, bool EagerlyInvalidate=false, bool NoRerun=false)
A function to deduce a function pass type and wrap it in the templated adaptor.
InnerAnalysisManagerProxy< FunctionAnalysisManager, Module > FunctionAnalysisManagerModuleProxy
Provide the FunctionAnalysisManager to Module proxy.
FunctionToMachineFunctionPassAdaptor createFunctionToMachineFunctionPassAdaptor(MachineFunctionPassT &&Pass)
InnerAnalysisManagerProxy< MachineFunctionAnalysisManager, Function > MachineFunctionAnalysisManagerFunctionProxy
OuterAnalysisManagerProxy< FunctionAnalysisManager, Loop, LoopStandardAnalysisResults & > FunctionAnalysisManagerLoopProxy
A proxy from a FunctionAnalysisManager to a Loop.
cl::opt< bool > PrintPipelinePasses
Common option used by multiple tools to print pipeline passes.
OuterAnalysisManagerProxy< CGSCCAnalysisManager, Function > CGSCCAnalysisManagerFunctionProxy
A proxy from a CGSCCAnalysisManager to a Function.
std::enable_if_t< is_detected< HasRunOnLoopT, LoopPassT >::value, FunctionToLoopPassAdaptor > createFunctionToLoopPassAdaptor(LoopPassT &&Pass, bool UseMemorySSA=false, bool UseBlockFrequencyInfo=false, bool UseBranchProbabilityInfo=false)
A function to deduce a loop pass type and wrap it in the templated adaptor.
@ Detailed
Hash with opcode only.
@ CallTargetIgnored
Hash with opcode and operands.
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.
static StringRef name()
Gets the name of the pass we are mixed into.
This class manages callbacks registration, as well as provides a way for PassInstrumentation to pass ...
void registerClassToPassNameCallback(CallableT C)
RegAllocFilterFunc Filter