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") {
1301 }
else if (ParamName ==
"merge") {
1304 return make_error<StringError>(
1305 formatv(
"invalid BoundsChecking pass parameter '{0}' ", ParamName)
1318 return Name.starts_with(
"default") ||
Name.starts_with(
"thinlto") ||
1319 Name.starts_with(
"lto");
1330template <
typename PassManagerT,
typename CallbacksT>
1332 if (!Callbacks.empty()) {
1333 PassManagerT DummyPM;
1334 for (
auto &CB : Callbacks)
1335 if (CB(
Name, DummyPM, {}))
1341template <
typename CallbacksT>
1347 StringRef NameNoBracket =
Name.take_until([](
char C) {
return C ==
'<'; });
1350 if (
Name ==
"module")
1352 if (
Name ==
"cgscc")
1354 if (NameNoBracket ==
"function")
1356 if (
Name ==
"coro-cond")
1359#define MODULE_PASS(NAME, CREATE_PASS) \
1362#define MODULE_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1363 if (PassBuilder::checkParametrizedPassName(Name, NAME)) \
1365#define MODULE_ANALYSIS(NAME, CREATE_PASS) \
1366 if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
1368#include "PassRegistry.def"
1370 return callbacksAcceptPassName<ModulePassManager>(
Name, Callbacks);
1373template <
typename CallbacksT>
1376 StringRef NameNoBracket =
Name.take_until([](
char C) {
return C ==
'<'; });
1377 if (
Name ==
"cgscc")
1379 if (NameNoBracket ==
"function")
1386#define CGSCC_PASS(NAME, CREATE_PASS) \
1389#define CGSCC_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1390 if (PassBuilder::checkParametrizedPassName(Name, NAME)) \
1392#define CGSCC_ANALYSIS(NAME, CREATE_PASS) \
1393 if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
1395#include "PassRegistry.def"
1397 return callbacksAcceptPassName<CGSCCPassManager>(
Name, Callbacks);
1400template <
typename CallbacksT>
1403 StringRef NameNoBracket =
Name.take_until([](
char C) {
return C ==
'<'; });
1404 if (NameNoBracket ==
"function")
1406 if (
Name ==
"loop" ||
Name ==
"loop-mssa" ||
Name ==
"machine-function")
1409#define FUNCTION_PASS(NAME, CREATE_PASS) \
1412#define FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1413 if (PassBuilder::checkParametrizedPassName(Name, NAME)) \
1415#define FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
1416 if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
1418#include "PassRegistry.def"
1420 return callbacksAcceptPassName<FunctionPassManager>(
Name, Callbacks);
1423template <
typename CallbacksT>
1426 if (
Name ==
"machine-function")
1429#define MACHINE_FUNCTION_PASS(NAME, CREATE_PASS) \
1432#define MACHINE_FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, \
1434 if (PassBuilder::checkParametrizedPassName(Name, NAME)) \
1437#define MACHINE_FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
1438 if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
1441#include "llvm/Passes/MachinePassRegistry.def"
1443 return callbacksAcceptPassName<MachineFunctionPassManager>(
Name, Callbacks);
1446template <
typename CallbacksT>
1448 bool &UseMemorySSA) {
1449 UseMemorySSA =
false;
1452 UseMemorySSA =
true;
1456#define LOOPNEST_PASS(NAME, CREATE_PASS) \
1459#include "PassRegistry.def"
1461 return callbacksAcceptPassName<LoopPassManager>(
Name, Callbacks);
1464template <
typename CallbacksT>
1466 bool &UseMemorySSA) {
1467 UseMemorySSA =
false;
1470 UseMemorySSA =
true;
1474#define LOOP_PASS(NAME, CREATE_PASS) \
1477#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1478 if (PassBuilder::checkParametrizedPassName(Name, NAME)) \
1480#define LOOP_ANALYSIS(NAME, CREATE_PASS) \
1481 if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
1483#include "PassRegistry.def"
1485 return callbacksAcceptPassName<LoopPassManager>(
Name, Callbacks);
1488std::optional<std::vector<PassBuilder::PipelineElement>>
1489PassBuilder::parsePipelineText(
StringRef Text) {
1490 std::vector<PipelineElement> ResultPipeline;
1495 std::vector<PipelineElement> &Pipeline = *PipelineStack.
back();
1496 size_t Pos =
Text.find_first_of(
",()");
1497 Pipeline.push_back({
Text.substr(0, Pos), {}});
1500 if (Pos ==
Text.npos)
1503 char Sep =
Text[Pos];
1511 PipelineStack.
push_back(&Pipeline.back().InnerPipeline);
1515 assert(Sep ==
')' &&
"Bogus separator!");
1520 if (PipelineStack.
size() == 1)
1521 return std::nullopt;
1524 }
while (
Text.consume_front(
")"));
1532 if (!
Text.consume_front(
","))
1533 return std::nullopt;
1536 if (PipelineStack.
size() > 1)
1538 return std::nullopt;
1540 assert(PipelineStack.
back() == &ResultPipeline &&
1541 "Wrong pipeline at the bottom of the stack!");
1542 return {std::move(ResultPipeline)};
1546 const PipelineElement &E) {
1547 auto &
Name = E.Name;
1548 auto &InnerPipeline = E.InnerPipeline;
1551 if (!InnerPipeline.empty()) {
1552 if (
Name ==
"module") {
1554 if (
auto Err = parseModulePassPipeline(NestedMPM, InnerPipeline))
1556 MPM.
addPass(std::move(NestedMPM));
1559 if (
Name ==
"coro-cond") {
1561 if (
auto Err = parseModulePassPipeline(NestedMPM, InnerPipeline))
1566 if (
Name ==
"cgscc") {
1568 if (
auto Err = parseCGSCCPassPipeline(CGPM, InnerPipeline))
1575 return make_error<StringError>(
1576 "cannot have a no-rerun module to function adaptor",
1579 if (
auto Err = parseFunctionPassPipeline(FPM, InnerPipeline))
1586 for (
auto &
C : ModulePipelineParsingCallbacks)
1587 if (
C(
Name, MPM, InnerPipeline))
1591 return make_error<StringError>(
1592 formatv(
"invalid use of '{0}' pass as module pipeline",
Name).str(),
1601 return make_error<StringError>(
1602 formatv(
"unknown default pipeline alias '{0}'",
Name).str(),
1605 assert(Matches.
size() == 3 &&
"Must capture two matched strings!");
1617 if (Matches[1] ==
"default") {
1619 }
else if (Matches[1] ==
"thinlto-pre-link") {
1621 }
else if (Matches[1] ==
"thinlto") {
1623 }
else if (Matches[1] ==
"lto-pre-link") {
1632 assert(Matches[1] ==
"lto" &&
"Not one of the matched options!");
1639#define MODULE_PASS(NAME, CREATE_PASS) \
1640 if (Name == NAME) { \
1641 MPM.addPass(CREATE_PASS); \
1642 return Error::success(); \
1644#define MODULE_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1645 if (checkParametrizedPassName(Name, NAME)) { \
1646 auto Params = parsePassParameters(PARSER, Name, NAME); \
1648 return Params.takeError(); \
1649 MPM.addPass(CREATE_PASS(Params.get())); \
1650 return Error::success(); \
1652#define MODULE_ANALYSIS(NAME, CREATE_PASS) \
1653 if (Name == "require<" NAME ">") { \
1655 RequireAnalysisPass< \
1656 std::remove_reference_t<decltype(CREATE_PASS)>, Module>()); \
1657 return Error::success(); \
1659 if (Name == "invalidate<" NAME ">") { \
1660 MPM.addPass(InvalidateAnalysisPass< \
1661 std::remove_reference_t<decltype(CREATE_PASS)>>()); \
1662 return Error::success(); \
1664#define CGSCC_PASS(NAME, CREATE_PASS) \
1665 if (Name == NAME) { \
1666 MPM.addPass(createModuleToPostOrderCGSCCPassAdaptor(CREATE_PASS)); \
1667 return Error::success(); \
1669#define CGSCC_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1670 if (checkParametrizedPassName(Name, NAME)) { \
1671 auto Params = parsePassParameters(PARSER, Name, NAME); \
1673 return Params.takeError(); \
1675 createModuleToPostOrderCGSCCPassAdaptor(CREATE_PASS(Params.get()))); \
1676 return Error::success(); \
1678#define FUNCTION_PASS(NAME, CREATE_PASS) \
1679 if (Name == NAME) { \
1680 MPM.addPass(createModuleToFunctionPassAdaptor(CREATE_PASS)); \
1681 return Error::success(); \
1683#define FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1684 if (checkParametrizedPassName(Name, NAME)) { \
1685 auto Params = parsePassParameters(PARSER, Name, NAME); \
1687 return Params.takeError(); \
1688 MPM.addPass(createModuleToFunctionPassAdaptor(CREATE_PASS(Params.get()))); \
1689 return Error::success(); \
1691#define LOOPNEST_PASS(NAME, CREATE_PASS) \
1692 if (Name == NAME) { \
1693 MPM.addPass(createModuleToFunctionPassAdaptor( \
1694 createFunctionToLoopPassAdaptor(CREATE_PASS, false, false))); \
1695 return Error::success(); \
1697#define LOOP_PASS(NAME, CREATE_PASS) \
1698 if (Name == NAME) { \
1699 MPM.addPass(createModuleToFunctionPassAdaptor( \
1700 createFunctionToLoopPassAdaptor(CREATE_PASS, false, false))); \
1701 return Error::success(); \
1703#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1704 if (checkParametrizedPassName(Name, NAME)) { \
1705 auto Params = parsePassParameters(PARSER, Name, NAME); \
1707 return Params.takeError(); \
1709 createModuleToFunctionPassAdaptor(createFunctionToLoopPassAdaptor( \
1710 CREATE_PASS(Params.get()), false, false))); \
1711 return Error::success(); \
1713#include "PassRegistry.def"
1715 for (
auto &
C : ModulePipelineParsingCallbacks)
1716 if (
C(
Name, MPM, InnerPipeline))
1718 return make_error<StringError>(
1724 const PipelineElement &E) {
1725 auto &
Name = E.Name;
1726 auto &InnerPipeline = E.InnerPipeline;
1729 if (!InnerPipeline.empty()) {
1730 if (
Name ==
"cgscc") {
1732 if (
auto Err = parseCGSCCPassPipeline(NestedCGPM, InnerPipeline))
1735 CGPM.
addPass(std::move(NestedCGPM));
1740 if (
auto Err = parseFunctionPassPipeline(FPM, InnerPipeline))
1744 std::move(FPM), Params->first, Params->second));
1749 if (
auto Err = parseCGSCCPassPipeline(NestedCGPM, InnerPipeline))
1756 for (
auto &
C : CGSCCPipelineParsingCallbacks)
1757 if (
C(
Name, CGPM, InnerPipeline))
1761 return make_error<StringError>(
1762 formatv(
"invalid use of '{0}' pass as cgscc pipeline",
Name).str(),
1767#define CGSCC_PASS(NAME, CREATE_PASS) \
1768 if (Name == NAME) { \
1769 CGPM.addPass(CREATE_PASS); \
1770 return Error::success(); \
1772#define CGSCC_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1773 if (checkParametrizedPassName(Name, NAME)) { \
1774 auto Params = parsePassParameters(PARSER, Name, NAME); \
1776 return Params.takeError(); \
1777 CGPM.addPass(CREATE_PASS(Params.get())); \
1778 return Error::success(); \
1780#define CGSCC_ANALYSIS(NAME, CREATE_PASS) \
1781 if (Name == "require<" NAME ">") { \
1782 CGPM.addPass(RequireAnalysisPass< \
1783 std::remove_reference_t<decltype(CREATE_PASS)>, \
1784 LazyCallGraph::SCC, CGSCCAnalysisManager, LazyCallGraph &, \
1785 CGSCCUpdateResult &>()); \
1786 return Error::success(); \
1788 if (Name == "invalidate<" NAME ">") { \
1789 CGPM.addPass(InvalidateAnalysisPass< \
1790 std::remove_reference_t<decltype(CREATE_PASS)>>()); \
1791 return Error::success(); \
1793#define FUNCTION_PASS(NAME, CREATE_PASS) \
1794 if (Name == NAME) { \
1795 CGPM.addPass(createCGSCCToFunctionPassAdaptor(CREATE_PASS)); \
1796 return Error::success(); \
1798#define FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1799 if (checkParametrizedPassName(Name, NAME)) { \
1800 auto Params = parsePassParameters(PARSER, Name, NAME); \
1802 return Params.takeError(); \
1803 CGPM.addPass(createCGSCCToFunctionPassAdaptor(CREATE_PASS(Params.get()))); \
1804 return Error::success(); \
1806#define LOOPNEST_PASS(NAME, CREATE_PASS) \
1807 if (Name == NAME) { \
1808 CGPM.addPass(createCGSCCToFunctionPassAdaptor( \
1809 createFunctionToLoopPassAdaptor(CREATE_PASS, false, false))); \
1810 return Error::success(); \
1812#define LOOP_PASS(NAME, CREATE_PASS) \
1813 if (Name == NAME) { \
1814 CGPM.addPass(createCGSCCToFunctionPassAdaptor( \
1815 createFunctionToLoopPassAdaptor(CREATE_PASS, false, false))); \
1816 return Error::success(); \
1818#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1819 if (checkParametrizedPassName(Name, NAME)) { \
1820 auto Params = parsePassParameters(PARSER, Name, NAME); \
1822 return Params.takeError(); \
1824 createCGSCCToFunctionPassAdaptor(createFunctionToLoopPassAdaptor( \
1825 CREATE_PASS(Params.get()), false, false))); \
1826 return Error::success(); \
1828#include "PassRegistry.def"
1830 for (
auto &
C : CGSCCPipelineParsingCallbacks)
1831 if (
C(
Name, CGPM, InnerPipeline))
1833 return make_error<StringError>(
1839 const PipelineElement &E) {
1840 auto &
Name = E.Name;
1841 auto &InnerPipeline = E.InnerPipeline;
1844 if (!InnerPipeline.empty()) {
1845 if (
Name ==
"function") {
1847 if (
auto Err = parseFunctionPassPipeline(NestedFPM, InnerPipeline))
1850 FPM.
addPass(std::move(NestedFPM));
1853 if (
Name ==
"loop" ||
Name ==
"loop-mssa") {
1855 if (
auto Err = parseLoopPassPipeline(LPM, InnerPipeline))
1858 bool UseMemorySSA = (
Name ==
"loop-mssa");
1860 return Pipeline.Name.contains(
"simple-loop-unswitch");
1862 bool UseBPI =
llvm::any_of(InnerPipeline, [](
auto Pipeline) {
1863 return Pipeline.Name ==
"loop-predication";
1869 if (
Name ==
"machine-function") {
1871 if (
auto Err = parseMachinePassPipeline(MFPM, InnerPipeline))
1877 for (
auto &
C : FunctionPipelineParsingCallbacks)
1878 if (
C(
Name, FPM, InnerPipeline))
1882 return make_error<StringError>(
1883 formatv(
"invalid use of '{0}' pass as function pipeline",
Name).str(),
1888#define FUNCTION_PASS(NAME, CREATE_PASS) \
1889 if (Name == NAME) { \
1890 FPM.addPass(CREATE_PASS); \
1891 return Error::success(); \
1893#define FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1894 if (checkParametrizedPassName(Name, NAME)) { \
1895 auto Params = parsePassParameters(PARSER, Name, NAME); \
1897 return Params.takeError(); \
1898 FPM.addPass(CREATE_PASS(Params.get())); \
1899 return Error::success(); \
1901#define FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
1902 if (Name == "require<" NAME ">") { \
1904 RequireAnalysisPass< \
1905 std::remove_reference_t<decltype(CREATE_PASS)>, Function>()); \
1906 return Error::success(); \
1908 if (Name == "invalidate<" NAME ">") { \
1909 FPM.addPass(InvalidateAnalysisPass< \
1910 std::remove_reference_t<decltype(CREATE_PASS)>>()); \
1911 return Error::success(); \
1917#define LOOPNEST_PASS(NAME, CREATE_PASS) \
1918 if (Name == NAME) { \
1919 FPM.addPass(createFunctionToLoopPassAdaptor(CREATE_PASS, false, false)); \
1920 return Error::success(); \
1922#define LOOP_PASS(NAME, CREATE_PASS) \
1923 if (Name == NAME) { \
1924 FPM.addPass(createFunctionToLoopPassAdaptor(CREATE_PASS, false, false)); \
1925 return Error::success(); \
1927#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1928 if (checkParametrizedPassName(Name, NAME)) { \
1929 auto Params = parsePassParameters(PARSER, Name, NAME); \
1931 return Params.takeError(); \
1932 FPM.addPass(createFunctionToLoopPassAdaptor(CREATE_PASS(Params.get()), \
1934 return Error::success(); \
1936#include "PassRegistry.def"
1938 for (
auto &
C : FunctionPipelineParsingCallbacks)
1939 if (
C(
Name, FPM, InnerPipeline))
1941 return make_error<StringError>(
1942 formatv(
"unknown function pass '{0}'",
Name).str(),
1947 const PipelineElement &E) {
1949 auto &InnerPipeline = E.InnerPipeline;
1952 if (!InnerPipeline.empty()) {
1953 if (
Name ==
"loop") {
1955 if (
auto Err = parseLoopPassPipeline(NestedLPM, InnerPipeline))
1958 LPM.
addPass(std::move(NestedLPM));
1962 for (
auto &
C : LoopPipelineParsingCallbacks)
1963 if (
C(
Name, LPM, InnerPipeline))
1967 return make_error<StringError>(
1968 formatv(
"invalid use of '{0}' pass as loop pipeline",
Name).str(),
1973#define LOOPNEST_PASS(NAME, CREATE_PASS) \
1974 if (Name == NAME) { \
1975 LPM.addPass(CREATE_PASS); \
1976 return Error::success(); \
1978#define LOOP_PASS(NAME, CREATE_PASS) \
1979 if (Name == NAME) { \
1980 LPM.addPass(CREATE_PASS); \
1981 return Error::success(); \
1983#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1984 if (checkParametrizedPassName(Name, NAME)) { \
1985 auto Params = parsePassParameters(PARSER, Name, NAME); \
1987 return Params.takeError(); \
1988 LPM.addPass(CREATE_PASS(Params.get())); \
1989 return Error::success(); \
1991#define LOOP_ANALYSIS(NAME, CREATE_PASS) \
1992 if (Name == "require<" NAME ">") { \
1993 LPM.addPass(RequireAnalysisPass< \
1994 std::remove_reference_t<decltype(CREATE_PASS)>, Loop, \
1995 LoopAnalysisManager, LoopStandardAnalysisResults &, \
1997 return Error::success(); \
1999 if (Name == "invalidate<" NAME ">") { \
2000 LPM.addPass(InvalidateAnalysisPass< \
2001 std::remove_reference_t<decltype(CREATE_PASS)>>()); \
2002 return Error::success(); \
2004#include "PassRegistry.def"
2006 for (
auto &
C : LoopPipelineParsingCallbacks)
2007 if (
C(
Name, LPM, InnerPipeline))
2009 return make_error<StringError>(
formatv(
"unknown loop pass '{0}'",
Name).str(),
2014 const PipelineElement &E) {
2016 if (!E.InnerPipeline.empty())
2017 return make_error<StringError>(
"invalid pipeline",
2020#define MACHINE_MODULE_PASS(NAME, CREATE_PASS) \
2021 if (Name == NAME) { \
2022 MFPM.addPass(CREATE_PASS); \
2023 return Error::success(); \
2025#define MACHINE_FUNCTION_PASS(NAME, CREATE_PASS) \
2026 if (Name == NAME) { \
2027 MFPM.addPass(CREATE_PASS); \
2028 return Error::success(); \
2030#define MACHINE_FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, \
2032 if (checkParametrizedPassName(Name, NAME)) { \
2033 auto Params = parsePassParameters(PARSER, Name, NAME); \
2035 return Params.takeError(); \
2036 MFPM.addPass(CREATE_PASS(Params.get())); \
2037 return Error::success(); \
2039#define MACHINE_FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
2040 if (Name == "require<" NAME ">") { \
2042 RequireAnalysisPass<std::remove_reference_t<decltype(CREATE_PASS)>, \
2043 MachineFunction>()); \
2044 return Error::success(); \
2046 if (Name == "invalidate<" NAME ">") { \
2047 MFPM.addPass(InvalidateAnalysisPass< \
2048 std::remove_reference_t<decltype(CREATE_PASS)>>()); \
2049 return Error::success(); \
2051#include "llvm/Passes/MachinePassRegistry.def"
2053 for (
auto &
C : MachineFunctionPipelineParsingCallbacks)
2054 if (
C(
Name, MFPM, E.InnerPipeline))
2056 return make_error<StringError>(
2057 formatv(
"unknown machine pass '{0}'",
Name).str(),
2062#define MODULE_ALIAS_ANALYSIS(NAME, CREATE_PASS) \
2063 if (Name == NAME) { \
2064 AA.registerModuleAnalysis< \
2065 std::remove_reference_t<decltype(CREATE_PASS)>>(); \
2068#define FUNCTION_ALIAS_ANALYSIS(NAME, CREATE_PASS) \
2069 if (Name == NAME) { \
2070 AA.registerFunctionAnalysis< \
2071 std::remove_reference_t<decltype(CREATE_PASS)>>(); \
2074#include "PassRegistry.def"
2076 for (
auto &
C : AAParsingCallbacks)
2082Error PassBuilder::parseMachinePassPipeline(
2084 for (
const auto &Element : Pipeline) {
2085 if (
auto Err = parseMachinePass(MFPM, Element))
2093 for (
const auto &Element : Pipeline) {
2094 if (
auto Err = parseLoopPass(LPM, Element))
2100Error PassBuilder::parseFunctionPassPipeline(
2102 for (
const auto &Element : Pipeline) {
2103 if (
auto Err = parseFunctionPass(FPM, Element))
2111 for (
const auto &Element : Pipeline) {
2112 if (
auto Err = parseCGSCCPass(CGPM, Element))
2144 for (
const auto &Element : Pipeline) {
2145 if (
auto Err = parseModulePass(MPM, Element))
2156 auto Pipeline = parsePipelineText(PipelineText);
2157 if (!Pipeline || Pipeline->empty())
2158 return make_error<StringError>(
2159 formatv(
"invalid pipeline '{0}'", PipelineText).str(),
2169 Pipeline = {{
"cgscc", std::move(*Pipeline)}};
2171 FunctionPipelineParsingCallbacks)) {
2172 Pipeline = {{
"function", std::move(*Pipeline)}};
2175 Pipeline = {{
"function", {{UseMemorySSA ?
"loop-mssa" :
"loop",
2176 std::move(*Pipeline)}}}};
2177 }
else if (
isLoopPassName(FirstName, LoopPipelineParsingCallbacks,
2179 Pipeline = {{
"function", {{UseMemorySSA ?
"loop-mssa" :
"loop",
2180 std::move(*Pipeline)}}}};
2182 FirstName, MachineFunctionPipelineParsingCallbacks)) {
2183 Pipeline = {{
"function", {{
"machine-function", std::move(*Pipeline)}}}};
2185 for (
auto &
C : TopLevelPipelineParsingCallbacks)
2186 if (
C(MPM, *Pipeline))
2190 auto &InnerPipeline = Pipeline->front().InnerPipeline;
2191 return make_error<StringError>(
2192 formatv(
"unknown {0} name '{1}'",
2193 (InnerPipeline.empty() ?
"pass" :
"pipeline"), FirstName)
2199 if (
auto Err = parseModulePassPipeline(MPM, *Pipeline))
2207 auto Pipeline = parsePipelineText(PipelineText);
2208 if (!Pipeline || Pipeline->empty())
2209 return make_error<StringError>(
2210 formatv(
"invalid pipeline '{0}'", PipelineText).str(),
2215 return make_error<StringError>(
2216 formatv(
"unknown cgscc pass '{0}' in pipeline '{1}'", FirstName,
2221 if (
auto Err = parseCGSCCPassPipeline(CGPM, *Pipeline))
2230 auto Pipeline = parsePipelineText(PipelineText);
2231 if (!Pipeline || Pipeline->empty())
2232 return make_error<StringError>(
2233 formatv(
"invalid pipeline '{0}'", PipelineText).str(),
2238 return make_error<StringError>(
2239 formatv(
"unknown function pass '{0}' in pipeline '{1}'", FirstName,
2244 if (
auto Err = parseFunctionPassPipeline(FPM, *Pipeline))
2252 auto Pipeline = parsePipelineText(PipelineText);
2253 if (!Pipeline || Pipeline->empty())
2254 return make_error<StringError>(
2255 formatv(
"invalid pipeline '{0}'", PipelineText).str(),
2258 if (
auto Err = parseLoopPassPipeline(CGPM, *Pipeline))
2266 auto Pipeline = parsePipelineText(PipelineText);
2267 if (!Pipeline || Pipeline->empty())
2268 return make_error<StringError>(
2269 formatv(
"invalid machine pass pipeline '{0}'", PipelineText).str(),
2272 if (
auto Err = parseMachinePassPipeline(MFPM, *Pipeline))
2281 if (PipelineText ==
"default") {
2286 while (!PipelineText.
empty()) {
2288 std::tie(
Name, PipelineText) = PipelineText.
split(
',');
2289 if (!parseAAPassName(AA,
Name))
2290 return make_error<StringError>(
2291 formatv(
"unknown alias analysis name '{0}'",
Name).str(),
2298std::optional<RegAllocFilterFunc>
2300 if (FilterName ==
"all")
2302 for (
auto &
C : RegClassFilterParsingCallbacks)
2303 if (
auto F =
C(FilterName))
2305 return std::nullopt;
2313 OS <<
" " <<
PassName <<
"<" << Params <<
">\n";
2319 OS <<
"Module passes:\n";
2320#define MODULE_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2321#include "PassRegistry.def"
2323 OS <<
"Module passes with params:\n";
2324#define MODULE_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
2325 printPassName(NAME, PARAMS, OS);
2326#include "PassRegistry.def"
2328 OS <<
"Module analyses:\n";
2329#define MODULE_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2330#include "PassRegistry.def"
2332 OS <<
"Module alias analyses:\n";
2333#define MODULE_ALIAS_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2334#include "PassRegistry.def"
2336 OS <<
"CGSCC passes:\n";
2337#define CGSCC_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2338#include "PassRegistry.def"
2340 OS <<
"CGSCC passes with params:\n";
2341#define CGSCC_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
2342 printPassName(NAME, PARAMS, OS);
2343#include "PassRegistry.def"
2345 OS <<
"CGSCC analyses:\n";
2346#define CGSCC_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2347#include "PassRegistry.def"
2349 OS <<
"Function passes:\n";
2350#define FUNCTION_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2351#include "PassRegistry.def"
2353 OS <<
"Function passes with params:\n";
2354#define FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
2355 printPassName(NAME, PARAMS, OS);
2356#include "PassRegistry.def"
2358 OS <<
"Function analyses:\n";
2359#define FUNCTION_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2360#include "PassRegistry.def"
2362 OS <<
"Function alias analyses:\n";
2363#define FUNCTION_ALIAS_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2364#include "PassRegistry.def"
2366 OS <<
"LoopNest passes:\n";
2367#define LOOPNEST_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2368#include "PassRegistry.def"
2370 OS <<
"Loop passes:\n";
2371#define LOOP_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2372#include "PassRegistry.def"
2374 OS <<
"Loop passes with params:\n";
2375#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
2376 printPassName(NAME, PARAMS, OS);
2377#include "PassRegistry.def"
2379 OS <<
"Loop analyses:\n";
2380#define LOOP_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2381#include "PassRegistry.def"
2383 OS <<
"Machine module passes (WIP):\n";
2384#define MACHINE_MODULE_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2385#include "llvm/Passes/MachinePassRegistry.def"
2387 OS <<
"Machine function passes (WIP):\n";
2388#define MACHINE_FUNCTION_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2389#include "llvm/Passes/MachinePassRegistry.def"
2391 OS <<
"Machine function analyses (WIP):\n";
2392#define MACHINE_FUNCTION_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2393#include "llvm/Passes/MachinePassRegistry.def"
2399 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