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#define MACHINE_FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, \
497 PIC->addClassToPassName(CLASS, NAME);
498#include "llvm/Passes/MachinePassRegistry.def"
504#define MODULE_ANALYSIS(NAME, CREATE_PASS) \
505 MAM.registerPass([&] { return CREATE_PASS; });
506#include "PassRegistry.def"
508 for (
auto &
C : ModuleAnalysisRegistrationCallbacks)
513#define CGSCC_ANALYSIS(NAME, CREATE_PASS) \
514 CGAM.registerPass([&] { return CREATE_PASS; });
515#include "PassRegistry.def"
517 for (
auto &
C : CGSCCAnalysisRegistrationCallbacks)
527#define FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
528 FAM.registerPass([&] { return CREATE_PASS; });
529#include "PassRegistry.def"
531 for (
auto &
C : FunctionAnalysisRegistrationCallbacks)
538#define MACHINE_FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
539 MFAM.registerPass([&] { return CREATE_PASS; });
540#include "llvm/Passes/MachinePassRegistry.def"
542 for (
auto &
C : MachineFunctionAnalysisRegistrationCallbacks)
547#define LOOP_ANALYSIS(NAME, CREATE_PASS) \
548 LAM.registerPass([&] { return CREATE_PASS; });
549#include "PassRegistry.def"
551 for (
auto &
C : LoopAnalysisRegistrationCallbacks)
555static std::optional<std::pair<bool, bool>>
557 std::pair<bool, bool> Params;
558 if (!
Name.consume_front(
"function"))
562 if (!
Name.consume_front(
"<") || !
Name.consume_back(
">"))
564 while (!
Name.empty()) {
565 auto [Front, Back] =
Name.split(
';');
567 if (Front ==
"eager-inv")
569 else if (Front ==
"no-rerun")
570 Params.second =
true;
578 if (!
Name.consume_front(
"devirt<") || !
Name.consume_back(
">"))
581 if (
Name.getAsInteger(0, Count) || Count < 0)
601 while (!Params.
empty()) {
603 std::tie(ParamName, Params) = Params.
split(
';');
605 if (ParamName == OptionName) {
608 return make_error<StringError>(
623 while (!Params.
empty()) {
625 std::tie(ParamName, Params) = Params.
split(
';');
629 return make_error<StringError>(
630 formatv(
"invalid HardwareLoopPass parameter '{0}' ", ParamName).str(),
635 if (ParamName.
consume_front(
"hardware-loop-counter-bitwidth=")) {
638 return make_error<StringError>(
639 formatv(
"invalid HardwareLoopPass parameter '{0}' ", ParamName).str(),
644 if (ParamName ==
"force-hardware-loops") {
646 }
else if (ParamName ==
"force-hardware-loop-phi") {
648 }
else if (ParamName ==
"force-nested-hardware-loop") {
650 }
else if (ParamName ==
"force-hardware-loop-guard") {
653 return make_error<StringError>(
654 formatv(
"invalid HardwarePass parameter '{0}' ", ParamName).str(),
658 return HardwareLoopOpts;
664 while (!Params.
empty()) {
666 std::tie(ParamName, Params) = Params.
split(
';');
667 std::optional<OptimizationLevel> OptLevel =
parseOptLevel(ParamName);
669 if (OptLevel && !OptLevel->isOptimizingForSize()) {
670 UnrollOpts.
setOptLevel(OptLevel->getSpeedupLevel());
676 return make_error<StringError>(
677 formatv(
"invalid LoopUnrollPass parameter '{0}' ", ParamName).str(),
684 if (ParamName ==
"partial") {
686 }
else if (ParamName ==
"peeling") {
688 }
else if (ParamName ==
"profile-peeling") {
690 }
else if (ParamName ==
"runtime") {
692 }
else if (ParamName ==
"upperbound") {
695 return make_error<StringError>(
696 formatv(
"invalid LoopUnrollPass parameter '{0}' ", ParamName).str(),
705 Params,
"vfe-linkage-unit-visibility",
"GlobalDCE");
725 Params,
"skip-non-recursive-function-attrs",
"PostOrderFunctionAttrs");
734 return make_error<StringError>(
735 formatv(
"too many CFGuardPass parameters '{0}' ", Params).str(),
738 if (Param ==
"check")
740 if (Param ==
"dispatch")
743 return make_error<StringError>(
744 formatv(
"invalid CFGuardPass mechanism: '{0}' ", Param).str(),
754 "EntryExitInstrumenter");
763 "LowerMatrixIntrinsics");
768 while (!Params.
empty()) {
770 std::tie(ParamName, Params) = Params.
split(
';');
772 if (ParamName ==
"kernel") {
773 Result.CompileKernel =
true;
775 return make_error<StringError>(
776 formatv(
"invalid AddressSanitizer pass parameter '{0}' ", ParamName)
786 while (!Params.
empty()) {
788 std::tie(ParamName, Params) = Params.
split(
';');
790 if (ParamName ==
"recover") {
792 }
else if (ParamName ==
"kernel") {
793 Result.CompileKernel =
true;
795 return make_error<StringError>(
796 formatv(
"invalid HWAddressSanitizer pass parameter '{0}' ", ParamName)
806 while (!Params.
empty()) {
808 std::tie(ParamName, Params) = Params.
split(
';');
810 if (ParamName ==
"thinlto") {
812 }
else if (ParamName ==
"emit-summary") {
813 Result.EmitLTOSummary =
true;
815 return make_error<StringError>(
816 formatv(
"invalid EmbedBitcode pass parameter '{0}' ", ParamName)
826 while (!Params.
empty()) {
828 std::tie(ParamName, Params) = Params.
split(
';');
830 if (ParamName ==
"recover") {
832 }
else if (ParamName ==
"kernel") {
836 return make_error<StringError>(
837 formatv(
"invalid argument to MemorySanitizer pass track-origins "
842 }
else if (ParamName ==
"eager-checks") {
843 Result.EagerChecks =
true;
845 return make_error<StringError>(
846 formatv(
"invalid MemorySanitizer pass parameter '{0}' ", ParamName)
857 while (!Params.
empty()) {
859 std::tie(ParamName, Params) = Params.
split(
';');
862 if (ParamName ==
"speculate-blocks") {
864 }
else if (ParamName ==
"simplify-cond-branch") {
866 }
else if (ParamName ==
"forward-switch-cond") {
868 }
else if (ParamName ==
"switch-range-to-icmp") {
870 }
else if (ParamName ==
"switch-to-lookup") {
872 }
else if (ParamName ==
"keep-loops") {
874 }
else if (ParamName ==
"hoist-common-insts") {
876 }
else if (ParamName ==
"hoist-loads-stores-with-cond-faulting") {
878 }
else if (ParamName ==
"sink-common-insts") {
880 }
else if (ParamName ==
"speculate-unpredictables") {
883 APInt BonusInstThreshold;
885 return make_error<StringError>(
886 formatv(
"invalid argument to SimplifyCFG pass bonus-threshold "
892 return make_error<StringError>(
893 formatv(
"invalid SimplifyCFG pass parameter '{0}' ", ParamName).str(),
904 Result.setVerifyFixpoint(
true);
905 while (!Params.
empty()) {
907 std::tie(ParamName, Params) = Params.
split(
';');
910 if (ParamName ==
"verify-fixpoint") {
915 return make_error<StringError>(
916 formatv(
"invalid argument to InstCombine pass max-iterations "
922 return make_error<StringError>(
923 formatv(
"invalid InstCombine pass parameter '{0}' ", ParamName).str(),
933 while (!Params.
empty()) {
935 std::tie(ParamName, Params) = Params.
split(
';');
938 if (ParamName ==
"interleave-forced-only") {
940 }
else if (ParamName ==
"vectorize-forced-only") {
943 return make_error<StringError>(
944 formatv(
"invalid LoopVectorize parameter '{0}' ", ParamName).str(),
952 std::pair<bool, bool>
Result = {
false,
true};
953 while (!Params.
empty()) {
955 std::tie(ParamName, Params) = Params.
split(
';');
958 if (ParamName ==
"nontrivial") {
960 }
else if (ParamName ==
"trivial") {
963 return make_error<StringError>(
964 formatv(
"invalid LoopUnswitch pass parameter '{0}' ", ParamName)
974 while (!Params.
empty()) {
976 std::tie(ParamName, Params) = Params.
split(
';');
979 if (ParamName ==
"allowspeculation") {
982 return make_error<StringError>(
983 formatv(
"invalid LICM pass parameter '{0}' ", ParamName).str(),
991 std::pair<bool, bool>
Result = {
true,
false};
992 while (!Params.
empty()) {
994 std::tie(ParamName, Params) = Params.
split(
';');
997 if (ParamName ==
"header-duplication") {
999 }
else if (ParamName ==
"prepare-for-lto") {
1002 return make_error<StringError>(
1003 formatv(
"invalid LoopRotate pass parameter '{0}' ", ParamName).str(),
1012 while (!Params.
empty()) {
1014 std::tie(ParamName, Params) = Params.
split(
';');
1017 if (ParamName ==
"split-footer-bb") {
1020 return make_error<StringError>(
1021 formatv(
"invalid MergedLoadStoreMotion pass parameter '{0}' ",
1032 while (!Params.
empty()) {
1034 std::tie(ParamName, Params) = Params.
split(
';');
1037 if (ParamName ==
"pre") {
1039 }
else if (ParamName ==
"load-pre") {
1041 }
else if (ParamName ==
"split-backedge-load-pre") {
1043 }
else if (ParamName ==
"memdep") {
1045 }
else if (ParamName ==
"memoryssa") {
1048 return make_error<StringError>(
1049 formatv(
"invalid GVN pass parameter '{0}' ", ParamName).str(),
1058 while (!Params.
empty()) {
1060 std::tie(ParamName, Params) = Params.
split(
';');
1063 if (ParamName ==
"func-spec")
1066 return make_error<StringError>(
1067 formatv(
"invalid IPSCCP pass parameter '{0}' ", ParamName).str(),
1075 while (!Params.
empty()) {
1077 std::tie(ParamName, Params) = Params.
split(
';');
1081 return make_error<StringError>(
1082 formatv(
"invalid argument to Scalarizer pass min-bits "
1083 "parameter: '{0}' ",
1093 if (ParamName ==
"load-store")
1095 else if (ParamName ==
"variable-insert-extract")
1098 return make_error<StringError>(
1099 formatv(
"invalid Scalarizer pass parameter '{0}' ", ParamName).str(),
1108 if (Params.
empty() || Params ==
"modify-cfg")
1110 if (Params ==
"preserve-cfg")
1112 return make_error<StringError>(
1113 formatv(
"invalid SROA pass parameter '{0}' (either preserve-cfg or "
1114 "modify-cfg can be specified)",
1121parseStackLifetimeOptions(
StringRef Params) {
1123 while (!Params.
empty()) {
1125 std::tie(ParamName, Params) = Params.
split(
';');
1127 if (ParamName ==
"may") {
1129 }
else if (ParamName ==
"must") {
1132 return make_error<StringError>(
1133 formatv(
"invalid StackLifetime parameter '{0}' ", ParamName).str(),
1142 "DependenceAnalysisPrinter");
1147 "SeparateConstOffsetFromGEP");
1156parseFunctionSimplificationPipelineOptions(
StringRef Params) {
1159 return make_error<StringError>(
1160 formatv(
"invalid function-simplification parameter '{0}' ", Params)
1169 "MemorySSAPrinterPass");
1174 "SpeculativeExecutionPass");
1179 while (!Params.
empty()) {
1181 std::tie(ParamName, Params) = Params.
split(
';');
1186 return make_error<StringError>(
1187 formatv(
"invalid MemProfUse pass parameter '{0}' ", ParamName).str(),
1195parseStructuralHashPrinterPassOptions(
StringRef Params) {
1198 if (Params ==
"detailed")
1200 if (Params ==
"call-target-ignored")
1202 return make_error<StringError>(
1203 formatv(
"invalid structural hash printer parameter '{0}' ", Params).str(),
1209 "WinEHPreparePass");
1214 while (!Params.
empty()) {
1216 std::tie(ParamName, Params) = Params.
split(
';');
1219 if (ParamName ==
"group-by-use")
1221 else if (ParamName ==
"ignore-single-use")
1223 else if (ParamName ==
"merge-const")
1225 else if (ParamName ==
"merge-external")
1229 return make_error<StringError>(
1230 formatv(
"invalid GlobalMergePass parameter '{0}' ", ParamName)
1240 while (!Params.
empty()) {
1242 std::tie(ParamName, Params) = Params.
split(
';');
1247 return make_error<StringError>(
1248 formatv(
"invalid Internalize pass parameter '{0}' ", ParamName).str(),
1259 while (!Params.
empty()) {
1261 std::tie(ParamName, Params) = Params.
split(
';');
1264 std::optional<RegAllocFilterFunc>
Filter =
1267 return make_error<StringError>(
1268 formatv(
"invalid regallocfast register filter '{0}' ", ParamName)
1277 if (ParamName ==
"no-clear-vregs") {
1282 return make_error<StringError>(
1283 formatv(
"invalid regallocfast pass parameter '{0}' ", ParamName).str(),
1290parseBoundsCheckingOptions(
StringRef Params) {
1292 while (!Params.
empty()) {
1294 std::tie(ParamName, Params) = Params.
split(
';');
1295 if (ParamName ==
"trap") {
1297 }
else if (ParamName ==
"rt") {
1302 }
else if (ParamName ==
"rt-abort") {
1307 }
else if (ParamName ==
"min-rt") {
1312 }
else if (ParamName ==
"min-rt-abort") {
1317 }
else if (ParamName ==
"merge") {
1322 std::tie(ParamEQ, Val) = ParamName.
split(
'=');
1327 return make_error<StringError>(
1328 formatv(
"invalid BoundsChecking pass parameter '{0}' ", ParamName)
1342 return Name.starts_with(
"default") ||
Name.starts_with(
"thinlto") ||
1343 Name.starts_with(
"lto");
1354template <
typename PassManagerT,
typename CallbacksT>
1356 if (!Callbacks.empty()) {
1357 PassManagerT DummyPM;
1358 for (
auto &CB : Callbacks)
1359 if (CB(
Name, DummyPM, {}))
1365template <
typename CallbacksT>
1371 StringRef NameNoBracket =
Name.take_until([](
char C) {
return C ==
'<'; });
1374 if (
Name ==
"module")
1376 if (
Name ==
"cgscc")
1378 if (NameNoBracket ==
"function")
1380 if (
Name ==
"coro-cond")
1383#define MODULE_PASS(NAME, CREATE_PASS) \
1386#define MODULE_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1387 if (PassBuilder::checkParametrizedPassName(Name, NAME)) \
1389#define MODULE_ANALYSIS(NAME, CREATE_PASS) \
1390 if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
1392#include "PassRegistry.def"
1394 return callbacksAcceptPassName<ModulePassManager>(
Name, Callbacks);
1397template <
typename CallbacksT>
1400 StringRef NameNoBracket =
Name.take_until([](
char C) {
return C ==
'<'; });
1401 if (
Name ==
"cgscc")
1403 if (NameNoBracket ==
"function")
1410#define CGSCC_PASS(NAME, CREATE_PASS) \
1413#define CGSCC_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1414 if (PassBuilder::checkParametrizedPassName(Name, NAME)) \
1416#define CGSCC_ANALYSIS(NAME, CREATE_PASS) \
1417 if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
1419#include "PassRegistry.def"
1421 return callbacksAcceptPassName<CGSCCPassManager>(
Name, Callbacks);
1424template <
typename CallbacksT>
1427 StringRef NameNoBracket =
Name.take_until([](
char C) {
return C ==
'<'; });
1428 if (NameNoBracket ==
"function")
1430 if (
Name ==
"loop" ||
Name ==
"loop-mssa" ||
Name ==
"machine-function")
1433#define FUNCTION_PASS(NAME, CREATE_PASS) \
1436#define FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1437 if (PassBuilder::checkParametrizedPassName(Name, NAME)) \
1439#define FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
1440 if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
1442#include "PassRegistry.def"
1444 return callbacksAcceptPassName<FunctionPassManager>(
Name, Callbacks);
1447template <
typename CallbacksT>
1450 if (
Name ==
"machine-function")
1453#define MACHINE_FUNCTION_PASS(NAME, CREATE_PASS) \
1456#define MACHINE_FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, \
1458 if (PassBuilder::checkParametrizedPassName(Name, NAME)) \
1461#define MACHINE_FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
1462 if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
1465#include "llvm/Passes/MachinePassRegistry.def"
1467 return callbacksAcceptPassName<MachineFunctionPassManager>(
Name, Callbacks);
1470template <
typename CallbacksT>
1472 bool &UseMemorySSA) {
1473 UseMemorySSA =
false;
1476 UseMemorySSA =
true;
1480#define LOOPNEST_PASS(NAME, CREATE_PASS) \
1483#include "PassRegistry.def"
1485 return callbacksAcceptPassName<LoopPassManager>(
Name, Callbacks);
1488template <
typename CallbacksT>
1490 bool &UseMemorySSA) {
1491 UseMemorySSA =
false;
1494 UseMemorySSA =
true;
1498#define LOOP_PASS(NAME, CREATE_PASS) \
1501#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1502 if (PassBuilder::checkParametrizedPassName(Name, NAME)) \
1504#define LOOP_ANALYSIS(NAME, CREATE_PASS) \
1505 if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
1507#include "PassRegistry.def"
1509 return callbacksAcceptPassName<LoopPassManager>(
Name, Callbacks);
1512std::optional<std::vector<PassBuilder::PipelineElement>>
1513PassBuilder::parsePipelineText(
StringRef Text) {
1514 std::vector<PipelineElement> ResultPipeline;
1519 std::vector<PipelineElement> &Pipeline = *PipelineStack.
back();
1520 size_t Pos =
Text.find_first_of(
",()");
1521 Pipeline.push_back({
Text.substr(0, Pos), {}});
1524 if (Pos ==
Text.npos)
1527 char Sep =
Text[Pos];
1535 PipelineStack.
push_back(&Pipeline.back().InnerPipeline);
1539 assert(Sep ==
')' &&
"Bogus separator!");
1544 if (PipelineStack.
size() == 1)
1545 return std::nullopt;
1548 }
while (
Text.consume_front(
")"));
1556 if (!
Text.consume_front(
","))
1557 return std::nullopt;
1560 if (PipelineStack.
size() > 1)
1562 return std::nullopt;
1564 assert(PipelineStack.
back() == &ResultPipeline &&
1565 "Wrong pipeline at the bottom of the stack!");
1566 return {std::move(ResultPipeline)};
1570 const PipelineElement &E) {
1571 auto &
Name = E.Name;
1572 auto &InnerPipeline = E.InnerPipeline;
1575 if (!InnerPipeline.empty()) {
1576 if (
Name ==
"module") {
1578 if (
auto Err = parseModulePassPipeline(NestedMPM, InnerPipeline))
1580 MPM.
addPass(std::move(NestedMPM));
1583 if (
Name ==
"coro-cond") {
1585 if (
auto Err = parseModulePassPipeline(NestedMPM, InnerPipeline))
1590 if (
Name ==
"cgscc") {
1592 if (
auto Err = parseCGSCCPassPipeline(CGPM, InnerPipeline))
1599 return make_error<StringError>(
1600 "cannot have a no-rerun module to function adaptor",
1603 if (
auto Err = parseFunctionPassPipeline(FPM, InnerPipeline))
1610 for (
auto &
C : ModulePipelineParsingCallbacks)
1611 if (
C(
Name, MPM, InnerPipeline))
1615 return make_error<StringError>(
1616 formatv(
"invalid use of '{0}' pass as module pipeline",
Name).str(),
1625 return make_error<StringError>(
1626 formatv(
"unknown default pipeline alias '{0}'",
Name).str(),
1629 assert(Matches.
size() == 3 &&
"Must capture two matched strings!");
1641 if (Matches[1] ==
"default") {
1643 }
else if (Matches[1] ==
"thinlto-pre-link") {
1645 }
else if (Matches[1] ==
"thinlto") {
1647 }
else if (Matches[1] ==
"lto-pre-link") {
1656 assert(Matches[1] ==
"lto" &&
"Not one of the matched options!");
1663#define MODULE_PASS(NAME, CREATE_PASS) \
1664 if (Name == NAME) { \
1665 MPM.addPass(CREATE_PASS); \
1666 return Error::success(); \
1668#define MODULE_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1669 if (checkParametrizedPassName(Name, NAME)) { \
1670 auto Params = parsePassParameters(PARSER, Name, NAME); \
1672 return Params.takeError(); \
1673 MPM.addPass(CREATE_PASS(Params.get())); \
1674 return Error::success(); \
1676#define MODULE_ANALYSIS(NAME, CREATE_PASS) \
1677 if (Name == "require<" NAME ">") { \
1679 RequireAnalysisPass< \
1680 std::remove_reference_t<decltype(CREATE_PASS)>, Module>()); \
1681 return Error::success(); \
1683 if (Name == "invalidate<" NAME ">") { \
1684 MPM.addPass(InvalidateAnalysisPass< \
1685 std::remove_reference_t<decltype(CREATE_PASS)>>()); \
1686 return Error::success(); \
1688#define CGSCC_PASS(NAME, CREATE_PASS) \
1689 if (Name == NAME) { \
1690 MPM.addPass(createModuleToPostOrderCGSCCPassAdaptor(CREATE_PASS)); \
1691 return Error::success(); \
1693#define CGSCC_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1694 if (checkParametrizedPassName(Name, NAME)) { \
1695 auto Params = parsePassParameters(PARSER, Name, NAME); \
1697 return Params.takeError(); \
1699 createModuleToPostOrderCGSCCPassAdaptor(CREATE_PASS(Params.get()))); \
1700 return Error::success(); \
1702#define FUNCTION_PASS(NAME, CREATE_PASS) \
1703 if (Name == NAME) { \
1704 MPM.addPass(createModuleToFunctionPassAdaptor(CREATE_PASS)); \
1705 return Error::success(); \
1707#define FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1708 if (checkParametrizedPassName(Name, NAME)) { \
1709 auto Params = parsePassParameters(PARSER, Name, NAME); \
1711 return Params.takeError(); \
1712 MPM.addPass(createModuleToFunctionPassAdaptor(CREATE_PASS(Params.get()))); \
1713 return Error::success(); \
1715#define LOOPNEST_PASS(NAME, CREATE_PASS) \
1716 if (Name == NAME) { \
1717 MPM.addPass(createModuleToFunctionPassAdaptor( \
1718 createFunctionToLoopPassAdaptor(CREATE_PASS, false, false))); \
1719 return Error::success(); \
1721#define LOOP_PASS(NAME, CREATE_PASS) \
1722 if (Name == NAME) { \
1723 MPM.addPass(createModuleToFunctionPassAdaptor( \
1724 createFunctionToLoopPassAdaptor(CREATE_PASS, false, false))); \
1725 return Error::success(); \
1727#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1728 if (checkParametrizedPassName(Name, NAME)) { \
1729 auto Params = parsePassParameters(PARSER, Name, NAME); \
1731 return Params.takeError(); \
1733 createModuleToFunctionPassAdaptor(createFunctionToLoopPassAdaptor( \
1734 CREATE_PASS(Params.get()), false, false))); \
1735 return Error::success(); \
1737#include "PassRegistry.def"
1739 for (
auto &
C : ModulePipelineParsingCallbacks)
1740 if (
C(
Name, MPM, InnerPipeline))
1742 return make_error<StringError>(
1748 const PipelineElement &E) {
1749 auto &
Name = E.Name;
1750 auto &InnerPipeline = E.InnerPipeline;
1753 if (!InnerPipeline.empty()) {
1754 if (
Name ==
"cgscc") {
1756 if (
auto Err = parseCGSCCPassPipeline(NestedCGPM, InnerPipeline))
1759 CGPM.
addPass(std::move(NestedCGPM));
1764 if (
auto Err = parseFunctionPassPipeline(FPM, InnerPipeline))
1768 std::move(FPM), Params->first, Params->second));
1773 if (
auto Err = parseCGSCCPassPipeline(NestedCGPM, InnerPipeline))
1780 for (
auto &
C : CGSCCPipelineParsingCallbacks)
1781 if (
C(
Name, CGPM, InnerPipeline))
1785 return make_error<StringError>(
1786 formatv(
"invalid use of '{0}' pass as cgscc pipeline",
Name).str(),
1791#define CGSCC_PASS(NAME, CREATE_PASS) \
1792 if (Name == NAME) { \
1793 CGPM.addPass(CREATE_PASS); \
1794 return Error::success(); \
1796#define CGSCC_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(CREATE_PASS(Params.get())); \
1802 return Error::success(); \
1804#define CGSCC_ANALYSIS(NAME, CREATE_PASS) \
1805 if (Name == "require<" NAME ">") { \
1806 CGPM.addPass(RequireAnalysisPass< \
1807 std::remove_reference_t<decltype(CREATE_PASS)>, \
1808 LazyCallGraph::SCC, CGSCCAnalysisManager, LazyCallGraph &, \
1809 CGSCCUpdateResult &>()); \
1810 return Error::success(); \
1812 if (Name == "invalidate<" NAME ">") { \
1813 CGPM.addPass(InvalidateAnalysisPass< \
1814 std::remove_reference_t<decltype(CREATE_PASS)>>()); \
1815 return Error::success(); \
1817#define FUNCTION_PASS(NAME, CREATE_PASS) \
1818 if (Name == NAME) { \
1819 CGPM.addPass(createCGSCCToFunctionPassAdaptor(CREATE_PASS)); \
1820 return Error::success(); \
1822#define FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1823 if (checkParametrizedPassName(Name, NAME)) { \
1824 auto Params = parsePassParameters(PARSER, Name, NAME); \
1826 return Params.takeError(); \
1827 CGPM.addPass(createCGSCCToFunctionPassAdaptor(CREATE_PASS(Params.get()))); \
1828 return Error::success(); \
1830#define LOOPNEST_PASS(NAME, CREATE_PASS) \
1831 if (Name == NAME) { \
1832 CGPM.addPass(createCGSCCToFunctionPassAdaptor( \
1833 createFunctionToLoopPassAdaptor(CREATE_PASS, false, false))); \
1834 return Error::success(); \
1836#define LOOP_PASS(NAME, CREATE_PASS) \
1837 if (Name == NAME) { \
1838 CGPM.addPass(createCGSCCToFunctionPassAdaptor( \
1839 createFunctionToLoopPassAdaptor(CREATE_PASS, false, false))); \
1840 return Error::success(); \
1842#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1843 if (checkParametrizedPassName(Name, NAME)) { \
1844 auto Params = parsePassParameters(PARSER, Name, NAME); \
1846 return Params.takeError(); \
1848 createCGSCCToFunctionPassAdaptor(createFunctionToLoopPassAdaptor( \
1849 CREATE_PASS(Params.get()), false, false))); \
1850 return Error::success(); \
1852#include "PassRegistry.def"
1854 for (
auto &
C : CGSCCPipelineParsingCallbacks)
1855 if (
C(
Name, CGPM, InnerPipeline))
1857 return make_error<StringError>(
1863 const PipelineElement &E) {
1864 auto &
Name = E.Name;
1865 auto &InnerPipeline = E.InnerPipeline;
1868 if (!InnerPipeline.empty()) {
1869 if (
Name ==
"function") {
1871 if (
auto Err = parseFunctionPassPipeline(NestedFPM, InnerPipeline))
1874 FPM.
addPass(std::move(NestedFPM));
1877 if (
Name ==
"loop" ||
Name ==
"loop-mssa") {
1879 if (
auto Err = parseLoopPassPipeline(LPM, InnerPipeline))
1882 bool UseMemorySSA = (
Name ==
"loop-mssa");
1884 return Pipeline.Name.contains(
"simple-loop-unswitch");
1886 bool UseBPI =
llvm::any_of(InnerPipeline, [](
auto Pipeline) {
1887 return Pipeline.Name ==
"loop-predication";
1893 if (
Name ==
"machine-function") {
1895 if (
auto Err = parseMachinePassPipeline(MFPM, InnerPipeline))
1901 for (
auto &
C : FunctionPipelineParsingCallbacks)
1902 if (
C(
Name, FPM, InnerPipeline))
1906 return make_error<StringError>(
1907 formatv(
"invalid use of '{0}' pass as function pipeline",
Name).str(),
1912#define FUNCTION_PASS(NAME, CREATE_PASS) \
1913 if (Name == NAME) { \
1914 FPM.addPass(CREATE_PASS); \
1915 return Error::success(); \
1917#define FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1918 if (checkParametrizedPassName(Name, NAME)) { \
1919 auto Params = parsePassParameters(PARSER, Name, NAME); \
1921 return Params.takeError(); \
1922 FPM.addPass(CREATE_PASS(Params.get())); \
1923 return Error::success(); \
1925#define FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
1926 if (Name == "require<" NAME ">") { \
1928 RequireAnalysisPass< \
1929 std::remove_reference_t<decltype(CREATE_PASS)>, Function>()); \
1930 return Error::success(); \
1932 if (Name == "invalidate<" NAME ">") { \
1933 FPM.addPass(InvalidateAnalysisPass< \
1934 std::remove_reference_t<decltype(CREATE_PASS)>>()); \
1935 return Error::success(); \
1941#define LOOPNEST_PASS(NAME, CREATE_PASS) \
1942 if (Name == NAME) { \
1943 FPM.addPass(createFunctionToLoopPassAdaptor(CREATE_PASS, false, false)); \
1944 return Error::success(); \
1946#define LOOP_PASS(NAME, CREATE_PASS) \
1947 if (Name == NAME) { \
1948 FPM.addPass(createFunctionToLoopPassAdaptor(CREATE_PASS, false, false)); \
1949 return Error::success(); \
1951#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1952 if (checkParametrizedPassName(Name, NAME)) { \
1953 auto Params = parsePassParameters(PARSER, Name, NAME); \
1955 return Params.takeError(); \
1956 FPM.addPass(createFunctionToLoopPassAdaptor(CREATE_PASS(Params.get()), \
1958 return Error::success(); \
1960#include "PassRegistry.def"
1962 for (
auto &
C : FunctionPipelineParsingCallbacks)
1963 if (
C(
Name, FPM, InnerPipeline))
1965 return make_error<StringError>(
1966 formatv(
"unknown function pass '{0}'",
Name).str(),
1971 const PipelineElement &E) {
1973 auto &InnerPipeline = E.InnerPipeline;
1976 if (!InnerPipeline.empty()) {
1977 if (
Name ==
"loop") {
1979 if (
auto Err = parseLoopPassPipeline(NestedLPM, InnerPipeline))
1982 LPM.
addPass(std::move(NestedLPM));
1986 for (
auto &
C : LoopPipelineParsingCallbacks)
1987 if (
C(
Name, LPM, InnerPipeline))
1991 return make_error<StringError>(
1992 formatv(
"invalid use of '{0}' pass as loop pipeline",
Name).str(),
1997#define LOOPNEST_PASS(NAME, CREATE_PASS) \
1998 if (Name == NAME) { \
1999 LPM.addPass(CREATE_PASS); \
2000 return Error::success(); \
2002#define LOOP_PASS(NAME, CREATE_PASS) \
2003 if (Name == NAME) { \
2004 LPM.addPass(CREATE_PASS); \
2005 return Error::success(); \
2007#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
2008 if (checkParametrizedPassName(Name, NAME)) { \
2009 auto Params = parsePassParameters(PARSER, Name, NAME); \
2011 return Params.takeError(); \
2012 LPM.addPass(CREATE_PASS(Params.get())); \
2013 return Error::success(); \
2015#define LOOP_ANALYSIS(NAME, CREATE_PASS) \
2016 if (Name == "require<" NAME ">") { \
2017 LPM.addPass(RequireAnalysisPass< \
2018 std::remove_reference_t<decltype(CREATE_PASS)>, Loop, \
2019 LoopAnalysisManager, LoopStandardAnalysisResults &, \
2021 return Error::success(); \
2023 if (Name == "invalidate<" NAME ">") { \
2024 LPM.addPass(InvalidateAnalysisPass< \
2025 std::remove_reference_t<decltype(CREATE_PASS)>>()); \
2026 return Error::success(); \
2028#include "PassRegistry.def"
2030 for (
auto &
C : LoopPipelineParsingCallbacks)
2031 if (
C(
Name, LPM, InnerPipeline))
2033 return make_error<StringError>(
formatv(
"unknown loop pass '{0}'",
Name).str(),
2038 const PipelineElement &E) {
2040 if (!E.InnerPipeline.empty())
2041 return make_error<StringError>(
"invalid pipeline",
2044#define MACHINE_MODULE_PASS(NAME, CREATE_PASS) \
2045 if (Name == NAME) { \
2046 MFPM.addPass(CREATE_PASS); \
2047 return Error::success(); \
2049#define MACHINE_FUNCTION_PASS(NAME, CREATE_PASS) \
2050 if (Name == NAME) { \
2051 MFPM.addPass(CREATE_PASS); \
2052 return Error::success(); \
2054#define MACHINE_FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, \
2056 if (checkParametrizedPassName(Name, NAME)) { \
2057 auto Params = parsePassParameters(PARSER, Name, NAME); \
2059 return Params.takeError(); \
2060 MFPM.addPass(CREATE_PASS(Params.get())); \
2061 return Error::success(); \
2063#define MACHINE_FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
2064 if (Name == "require<" NAME ">") { \
2066 RequireAnalysisPass<std::remove_reference_t<decltype(CREATE_PASS)>, \
2067 MachineFunction>()); \
2068 return Error::success(); \
2070 if (Name == "invalidate<" NAME ">") { \
2071 MFPM.addPass(InvalidateAnalysisPass< \
2072 std::remove_reference_t<decltype(CREATE_PASS)>>()); \
2073 return Error::success(); \
2075#include "llvm/Passes/MachinePassRegistry.def"
2077 for (
auto &
C : MachineFunctionPipelineParsingCallbacks)
2078 if (
C(
Name, MFPM, E.InnerPipeline))
2080 return make_error<StringError>(
2081 formatv(
"unknown machine pass '{0}'",
Name).str(),
2086#define MODULE_ALIAS_ANALYSIS(NAME, CREATE_PASS) \
2087 if (Name == NAME) { \
2088 AA.registerModuleAnalysis< \
2089 std::remove_reference_t<decltype(CREATE_PASS)>>(); \
2092#define FUNCTION_ALIAS_ANALYSIS(NAME, CREATE_PASS) \
2093 if (Name == NAME) { \
2094 AA.registerFunctionAnalysis< \
2095 std::remove_reference_t<decltype(CREATE_PASS)>>(); \
2098#include "PassRegistry.def"
2100 for (
auto &
C : AAParsingCallbacks)
2106Error PassBuilder::parseMachinePassPipeline(
2108 for (
const auto &Element : Pipeline) {
2109 if (
auto Err = parseMachinePass(MFPM, Element))
2117 for (
const auto &Element : Pipeline) {
2118 if (
auto Err = parseLoopPass(LPM, Element))
2124Error PassBuilder::parseFunctionPassPipeline(
2126 for (
const auto &Element : Pipeline) {
2127 if (
auto Err = parseFunctionPass(FPM, Element))
2135 for (
const auto &Element : Pipeline) {
2136 if (
auto Err = parseCGSCCPass(CGPM, Element))
2168 for (
const auto &Element : Pipeline) {
2169 if (
auto Err = parseModulePass(MPM, Element))
2180 auto Pipeline = parsePipelineText(PipelineText);
2181 if (!Pipeline || Pipeline->empty())
2182 return make_error<StringError>(
2183 formatv(
"invalid pipeline '{0}'", PipelineText).str(),
2193 Pipeline = {{
"cgscc", std::move(*Pipeline)}};
2195 FunctionPipelineParsingCallbacks)) {
2196 Pipeline = {{
"function", std::move(*Pipeline)}};
2199 Pipeline = {{
"function", {{UseMemorySSA ?
"loop-mssa" :
"loop",
2200 std::move(*Pipeline)}}}};
2201 }
else if (
isLoopPassName(FirstName, LoopPipelineParsingCallbacks,
2203 Pipeline = {{
"function", {{UseMemorySSA ?
"loop-mssa" :
"loop",
2204 std::move(*Pipeline)}}}};
2206 FirstName, MachineFunctionPipelineParsingCallbacks)) {
2207 Pipeline = {{
"function", {{
"machine-function", std::move(*Pipeline)}}}};
2209 for (
auto &
C : TopLevelPipelineParsingCallbacks)
2210 if (
C(MPM, *Pipeline))
2214 auto &InnerPipeline = Pipeline->front().InnerPipeline;
2215 return make_error<StringError>(
2216 formatv(
"unknown {0} name '{1}'",
2217 (InnerPipeline.empty() ?
"pass" :
"pipeline"), FirstName)
2223 if (
auto Err = parseModulePassPipeline(MPM, *Pipeline))
2231 auto Pipeline = parsePipelineText(PipelineText);
2232 if (!Pipeline || Pipeline->empty())
2233 return make_error<StringError>(
2234 formatv(
"invalid pipeline '{0}'", PipelineText).str(),
2239 return make_error<StringError>(
2240 formatv(
"unknown cgscc pass '{0}' in pipeline '{1}'", FirstName,
2245 if (
auto Err = parseCGSCCPassPipeline(CGPM, *Pipeline))
2254 auto Pipeline = parsePipelineText(PipelineText);
2255 if (!Pipeline || Pipeline->empty())
2256 return make_error<StringError>(
2257 formatv(
"invalid pipeline '{0}'", PipelineText).str(),
2262 return make_error<StringError>(
2263 formatv(
"unknown function pass '{0}' in pipeline '{1}'", FirstName,
2268 if (
auto Err = parseFunctionPassPipeline(FPM, *Pipeline))
2276 auto Pipeline = parsePipelineText(PipelineText);
2277 if (!Pipeline || Pipeline->empty())
2278 return make_error<StringError>(
2279 formatv(
"invalid pipeline '{0}'", PipelineText).str(),
2282 if (
auto Err = parseLoopPassPipeline(CGPM, *Pipeline))
2290 auto Pipeline = parsePipelineText(PipelineText);
2291 if (!Pipeline || Pipeline->empty())
2292 return make_error<StringError>(
2293 formatv(
"invalid machine pass pipeline '{0}'", PipelineText).str(),
2296 if (
auto Err = parseMachinePassPipeline(MFPM, *Pipeline))
2305 if (PipelineText ==
"default") {
2310 while (!PipelineText.
empty()) {
2312 std::tie(
Name, PipelineText) = PipelineText.
split(
',');
2313 if (!parseAAPassName(AA,
Name))
2314 return make_error<StringError>(
2315 formatv(
"unknown alias analysis name '{0}'",
Name).str(),
2322std::optional<RegAllocFilterFunc>
2324 if (FilterName ==
"all")
2326 for (
auto &
C : RegClassFilterParsingCallbacks)
2327 if (
auto F =
C(FilterName))
2329 return std::nullopt;
2337 OS <<
" " <<
PassName <<
"<" << Params <<
">\n";
2343 OS <<
"Module passes:\n";
2344#define MODULE_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2345#include "PassRegistry.def"
2347 OS <<
"Module passes with params:\n";
2348#define MODULE_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
2349 printPassName(NAME, PARAMS, OS);
2350#include "PassRegistry.def"
2352 OS <<
"Module analyses:\n";
2353#define MODULE_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2354#include "PassRegistry.def"
2356 OS <<
"Module alias analyses:\n";
2357#define MODULE_ALIAS_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2358#include "PassRegistry.def"
2360 OS <<
"CGSCC passes:\n";
2361#define CGSCC_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2362#include "PassRegistry.def"
2364 OS <<
"CGSCC passes with params:\n";
2365#define CGSCC_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
2366 printPassName(NAME, PARAMS, OS);
2367#include "PassRegistry.def"
2369 OS <<
"CGSCC analyses:\n";
2370#define CGSCC_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2371#include "PassRegistry.def"
2373 OS <<
"Function passes:\n";
2374#define FUNCTION_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2375#include "PassRegistry.def"
2377 OS <<
"Function passes with params:\n";
2378#define FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
2379 printPassName(NAME, PARAMS, OS);
2380#include "PassRegistry.def"
2382 OS <<
"Function analyses:\n";
2383#define FUNCTION_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2384#include "PassRegistry.def"
2386 OS <<
"Function alias analyses:\n";
2387#define FUNCTION_ALIAS_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2388#include "PassRegistry.def"
2390 OS <<
"LoopNest passes:\n";
2391#define LOOPNEST_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2392#include "PassRegistry.def"
2394 OS <<
"Loop passes:\n";
2395#define LOOP_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2396#include "PassRegistry.def"
2398 OS <<
"Loop passes with params:\n";
2399#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
2400 printPassName(NAME, PARAMS, OS);
2401#include "PassRegistry.def"
2403 OS <<
"Loop analyses:\n";
2404#define LOOP_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2405#include "PassRegistry.def"
2407 OS <<
"Machine module passes (WIP):\n";
2408#define MACHINE_MODULE_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2409#include "llvm/Passes/MachinePassRegistry.def"
2411 OS <<
"Machine function passes (WIP):\n";
2412#define MACHINE_FUNCTION_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2413#include "llvm/Passes/MachinePassRegistry.def"
2415 OS <<
"Machine function analyses (WIP):\n";
2416#define MACHINE_FUNCTION_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2417#include "llvm/Passes/MachinePassRegistry.def"
2423 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