314 "^(default|thinlto-pre-link|thinlto|lto-pre-link|lto)<(O[0123sz])>$");
318 "print-pipeline-passes",
319 cl::desc(
"Print a '-passes' compatible string describing the pipeline "
320 "(best-effort only)."));
332class TriggerCrashModulePass :
public PassInfoMixin<TriggerCrashModulePass> {
341class TriggerCrashFunctionPass
348 static StringRef name() {
return "TriggerCrashFunctionPass"; }
353class TriggerVerifierErrorPass
361 GlobalValue::LinkageTypes::InternalLinkage,
362 "__bad_alias",
nullptr, &M);
382 static StringRef name() {
return "TriggerVerifierErrorPass"; }
387class RequireAllMachineFunctionPropertiesPass
388 :
public PassInfoMixin<RequireAllMachineFunctionPropertiesPass> {
397 MFProps.
set(MachineFunctionProperties::Property::FailedISel);
398 MFProps.
set(MachineFunctionProperties::Property::FailsVerification);
399 MFProps.
set(MachineFunctionProperties::Property::IsSSA);
400 MFProps.
set(MachineFunctionProperties::Property::Legalized);
401 MFProps.
set(MachineFunctionProperties::Property::NoPHIs);
402 MFProps.
set(MachineFunctionProperties::Property::NoVRegs);
403 MFProps.
set(MachineFunctionProperties::Property::RegBankSelected);
404 MFProps.
set(MachineFunctionProperties::Property::Selected);
405 MFProps.
set(MachineFunctionProperties::Property::TiedOpsRewritten);
406 MFProps.
set(MachineFunctionProperties::Property::TracksDebugUserValues);
407 MFProps.
set(MachineFunctionProperties::Property::TracksLiveness);
410 static StringRef name() {
return "RequireAllMachineFunctionPropertiesPass"; }
416 std::optional<PGOOptions> PGOOpt,
418 :
TM(
TM), PTO(PTO), PGOOpt(PGOOpt),
PIC(
PIC) {
420 TM->registerPassBuilderCallbacks(*
this);
426#define MODULE_PASS(NAME, CREATE_PASS) \
427 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
428#define MODULE_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
429 PIC->addClassToPassName(CLASS, NAME);
430#define MODULE_ANALYSIS(NAME, CREATE_PASS) \
431 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
432#define FUNCTION_PASS(NAME, CREATE_PASS) \
433 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
434#define FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
435 PIC->addClassToPassName(CLASS, NAME);
436#define FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
437 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
438#define LOOPNEST_PASS(NAME, CREATE_PASS) \
439 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
440#define LOOP_PASS(NAME, CREATE_PASS) \
441 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
442#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
443 PIC->addClassToPassName(CLASS, NAME);
444#define LOOP_ANALYSIS(NAME, CREATE_PASS) \
445 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
446#define CGSCC_PASS(NAME, CREATE_PASS) \
447 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
448#define CGSCC_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
449 PIC->addClassToPassName(CLASS, NAME);
450#define CGSCC_ANALYSIS(NAME, CREATE_PASS) \
451 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
452#include "PassRegistry.def"
454#define MACHINE_FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
455 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
456#define MACHINE_FUNCTION_PASS(NAME, CREATE_PASS) \
457 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
458#include "llvm/Passes/MachinePassRegistry.def"
464#define MODULE_ANALYSIS(NAME, CREATE_PASS) \
465 MAM.registerPass([&] { return CREATE_PASS; });
466#include "PassRegistry.def"
468 for (
auto &
C : ModuleAnalysisRegistrationCallbacks)
473#define CGSCC_ANALYSIS(NAME, CREATE_PASS) \
474 CGAM.registerPass([&] { return CREATE_PASS; });
475#include "PassRegistry.def"
477 for (
auto &
C : CGSCCAnalysisRegistrationCallbacks)
487#define FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
488 FAM.registerPass([&] { return CREATE_PASS; });
489#include "PassRegistry.def"
491 for (
auto &
C : FunctionAnalysisRegistrationCallbacks)
498#define MACHINE_FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
499 MFAM.registerPass([&] { return CREATE_PASS; });
500#include "llvm/Passes/MachinePassRegistry.def"
502 for (
auto &
C : MachineFunctionAnalysisRegistrationCallbacks)
507#define LOOP_ANALYSIS(NAME, CREATE_PASS) \
508 LAM.registerPass([&] { return CREATE_PASS; });
509#include "PassRegistry.def"
511 for (
auto &
C : LoopAnalysisRegistrationCallbacks)
515static std::optional<std::pair<bool, bool>>
517 std::pair<bool, bool> Params;
518 if (!
Name.consume_front(
"function"))
522 if (!
Name.consume_front(
"<") || !
Name.consume_back(
">"))
524 while (!
Name.empty()) {
525 auto [Front, Back] =
Name.split(
';');
527 if (Front ==
"eager-inv")
529 else if (Front ==
"no-rerun")
530 Params.second =
true;
538 if (!
Name.consume_front(
"devirt<") || !
Name.consume_back(
">"))
541 if (
Name.getAsInteger(0, Count) || Count < 0)
561 while (!Params.
empty()) {
563 std::tie(ParamName, Params) = Params.
split(
';');
565 if (ParamName == OptionName) {
568 return make_error<StringError>(
583 while (!Params.
empty()) {
585 std::tie(ParamName, Params) = Params.
split(
';');
589 return make_error<StringError>(
590 formatv(
"invalid HardwareLoopPass parameter '{0}' ", ParamName).str(),
595 if (ParamName.
consume_front(
"hardware-loop-counter-bitwidth=")) {
598 return make_error<StringError>(
599 formatv(
"invalid HardwareLoopPass parameter '{0}' ", ParamName).str(),
604 if (ParamName ==
"force-hardware-loops") {
606 }
else if (ParamName ==
"force-hardware-loop-phi") {
608 }
else if (ParamName ==
"force-nested-hardware-loop") {
610 }
else if (ParamName ==
"force-hardware-loop-guard") {
613 return make_error<StringError>(
614 formatv(
"invalid HardwarePass parameter '{0}' ", ParamName).str(),
618 return HardwareLoopOpts;
624 while (!Params.
empty()) {
626 std::tie(ParamName, Params) = Params.
split(
';');
627 std::optional<OptimizationLevel> OptLevel =
parseOptLevel(ParamName);
629 if (OptLevel && !OptLevel->isOptimizingForSize()) {
630 UnrollOpts.
setOptLevel(OptLevel->getSpeedupLevel());
636 return make_error<StringError>(
637 formatv(
"invalid LoopUnrollPass parameter '{0}' ", ParamName).str(),
644 if (ParamName ==
"partial") {
646 }
else if (ParamName ==
"peeling") {
648 }
else if (ParamName ==
"profile-peeling") {
650 }
else if (ParamName ==
"runtime") {
652 }
else if (ParamName ==
"upperbound") {
655 return make_error<StringError>(
656 formatv(
"invalid LoopUnrollPass parameter '{0}' ", ParamName).str(),
665 Params,
"vfe-linkage-unit-visibility",
"GlobalDCE");
685 Params,
"skip-non-recursive-function-attrs",
"PostOrderFunctionAttrs");
694 return make_error<StringError>(
695 formatv(
"too many CFGuardPass parameters '{0}' ", Params).str(),
698 if (Param ==
"check")
700 if (Param ==
"dispatch")
703 return make_error<StringError>(
704 formatv(
"invalid CFGuardPass mechanism: '{0}' ", Param).str(),
714 "EntryExitInstrumenter");
723 "LowerMatrixIntrinsics");
728 while (!Params.
empty()) {
730 std::tie(ParamName, Params) = Params.
split(
';');
732 if (ParamName ==
"kernel") {
733 Result.CompileKernel =
true;
735 return make_error<StringError>(
736 formatv(
"invalid AddressSanitizer pass parameter '{0}' ", ParamName)
746 while (!Params.
empty()) {
748 std::tie(ParamName, Params) = Params.
split(
';');
750 if (ParamName ==
"recover") {
752 }
else if (ParamName ==
"kernel") {
753 Result.CompileKernel =
true;
755 return make_error<StringError>(
756 formatv(
"invalid HWAddressSanitizer pass parameter '{0}' ", ParamName)
766 while (!Params.
empty()) {
768 std::tie(ParamName, Params) = Params.
split(
';');
770 if (ParamName ==
"thinlto") {
772 }
else if (ParamName ==
"emit-summary") {
773 Result.EmitLTOSummary =
true;
775 return make_error<StringError>(
776 formatv(
"invalid EmbedBitcode pass parameter '{0}' ", ParamName)
786 while (!Params.
empty()) {
788 std::tie(ParamName, Params) = Params.
split(
';');
790 if (ParamName ==
"recover") {
792 }
else if (ParamName ==
"kernel") {
796 return make_error<StringError>(
797 formatv(
"invalid argument to MemorySanitizer pass track-origins "
802 }
else if (ParamName ==
"eager-checks") {
803 Result.EagerChecks =
true;
805 return make_error<StringError>(
806 formatv(
"invalid MemorySanitizer pass parameter '{0}' ", ParamName)
817 while (!Params.
empty()) {
819 std::tie(ParamName, Params) = Params.
split(
';');
822 if (ParamName ==
"speculate-blocks") {
824 }
else if (ParamName ==
"simplify-cond-branch") {
826 }
else if (ParamName ==
"forward-switch-cond") {
828 }
else if (ParamName ==
"switch-range-to-icmp") {
830 }
else if (ParamName ==
"switch-to-lookup") {
832 }
else if (ParamName ==
"keep-loops") {
834 }
else if (ParamName ==
"hoist-common-insts") {
836 }
else if (ParamName ==
"sink-common-insts") {
839 APInt BonusInstThreshold;
841 return make_error<StringError>(
842 formatv(
"invalid argument to SimplifyCFG pass bonus-threshold "
848 return make_error<StringError>(
849 formatv(
"invalid SimplifyCFG pass parameter '{0}' ", ParamName).str(),
860 Result.setVerifyFixpoint(
true);
861 while (!Params.
empty()) {
863 std::tie(ParamName, Params) = Params.
split(
';');
866 if (ParamName ==
"use-loop-info") {
868 }
else if (ParamName ==
"verify-fixpoint") {
873 return make_error<StringError>(
874 formatv(
"invalid argument to InstCombine pass max-iterations "
880 return make_error<StringError>(
881 formatv(
"invalid InstCombine pass parameter '{0}' ", ParamName).str(),
891 while (!Params.
empty()) {
893 std::tie(ParamName, Params) = Params.
split(
';');
896 if (ParamName ==
"interleave-forced-only") {
898 }
else if (ParamName ==
"vectorize-forced-only") {
901 return make_error<StringError>(
902 formatv(
"invalid LoopVectorize parameter '{0}' ", ParamName).str(),
910 std::pair<bool, bool>
Result = {
false,
true};
911 while (!Params.
empty()) {
913 std::tie(ParamName, Params) = Params.
split(
';');
916 if (ParamName ==
"nontrivial") {
918 }
else if (ParamName ==
"trivial") {
921 return make_error<StringError>(
922 formatv(
"invalid LoopUnswitch pass parameter '{0}' ", ParamName)
932 while (!Params.
empty()) {
934 std::tie(ParamName, Params) = Params.
split(
';');
937 if (ParamName ==
"allowspeculation") {
940 return make_error<StringError>(
941 formatv(
"invalid LICM pass parameter '{0}' ", ParamName).str(),
949 std::pair<bool, bool>
Result = {
true,
false};
950 while (!Params.
empty()) {
952 std::tie(ParamName, Params) = Params.
split(
';');
955 if (ParamName ==
"header-duplication") {
957 }
else if (ParamName ==
"prepare-for-lto") {
960 return make_error<StringError>(
961 formatv(
"invalid LoopRotate pass parameter '{0}' ", ParamName).str(),
970 while (!Params.
empty()) {
972 std::tie(ParamName, Params) = Params.
split(
';');
975 if (ParamName ==
"split-footer-bb") {
978 return make_error<StringError>(
979 formatv(
"invalid MergedLoadStoreMotion pass parameter '{0}' ",
990 while (!Params.
empty()) {
992 std::tie(ParamName, Params) = Params.
split(
';');
995 if (ParamName ==
"pre") {
997 }
else if (ParamName ==
"load-pre") {
999 }
else if (ParamName ==
"split-backedge-load-pre") {
1001 }
else if (ParamName ==
"memdep") {
1004 return make_error<StringError>(
1005 formatv(
"invalid GVN pass parameter '{0}' ", ParamName).str(),
1014 while (!Params.
empty()) {
1016 std::tie(ParamName, Params) = Params.
split(
';');
1019 if (ParamName ==
"func-spec")
1022 return make_error<StringError>(
1023 formatv(
"invalid IPSCCP pass parameter '{0}' ", ParamName).str(),
1030 if (Params.
empty() || Params ==
"modify-cfg")
1032 if (Params ==
"preserve-cfg")
1034 return make_error<StringError>(
1035 formatv(
"invalid SROA pass parameter '{0}' (either preserve-cfg or "
1036 "modify-cfg can be specified)",
1043parseStackLifetimeOptions(
StringRef Params) {
1045 while (!Params.
empty()) {
1047 std::tie(ParamName, Params) = Params.
split(
';');
1049 if (ParamName ==
"may") {
1051 }
else if (ParamName ==
"must") {
1054 return make_error<StringError>(
1055 formatv(
"invalid StackLifetime parameter '{0}' ", ParamName).str(),
1064 "DependenceAnalysisPrinter");
1069 "SeparateConstOffsetFromGEP");
1073parseFunctionSimplificationPipelineOptions(
StringRef Params) {
1076 return make_error<StringError>(
1077 formatv(
"invalid function-simplification parameter '{0}' ", Params)
1086 "MemorySSAPrinterPass");
1091 "SpeculativeExecutionPass");
1096 while (!Params.
empty()) {
1098 std::tie(ParamName, Params) = Params.
split(
';');
1103 return make_error<StringError>(
1104 formatv(
"invalid MemProfUse pass parameter '{0}' ", ParamName).str(),
1113 "StructuralHashPrinterPass");
1118 "WinEHPreparePass");
1123 while (!Params.
empty()) {
1125 std::tie(ParamName, Params) = Params.
split(
';');
1128 if (ParamName ==
"group-by-use")
1130 else if (ParamName ==
"ignore-single-use")
1132 else if (ParamName ==
"merge-const")
1134 else if (ParamName ==
"merge-external")
1138 return make_error<StringError>(
1139 formatv(
"invalid GlobalMergePass parameter '{0}' ", ParamName)
1149 while (!Params.
empty()) {
1151 std::tie(ParamName, Params) = Params.
split(
';');
1156 return make_error<StringError>(
1157 formatv(
"invalid Internalize pass parameter '{0}' ", ParamName).str(),
1168 while (!Params.
empty()) {
1170 std::tie(ParamName, Params) = Params.
split(
';');
1173 std::optional<RegClassFilterFunc>
Filter =
1176 return make_error<StringError>(
1177 formatv(
"invalid regallocfast register filter '{0}' ", ParamName)
1186 if (ParamName ==
"no-clear-vregs") {
1191 return make_error<StringError>(
1192 formatv(
"invalid regallocfast pass parameter '{0}' ", ParamName).str(),
1203 return Name.starts_with(
"default") ||
Name.starts_with(
"thinlto") ||
1204 Name.starts_with(
"lto");
1215template <
typename PassManagerT,
typename CallbacksT>
1217 if (!Callbacks.empty()) {
1218 PassManagerT DummyPM;
1219 for (
auto &CB : Callbacks)
1220 if (CB(
Name, DummyPM, {}))
1226template <
typename CallbacksT>
1232 StringRef NameNoBracket =
Name.take_until([](
char C) {
return C ==
'<'; });
1235 if (
Name ==
"module")
1237 if (
Name ==
"cgscc")
1239 if (NameNoBracket ==
"function")
1241 if (
Name ==
"coro-cond")
1244#define MODULE_PASS(NAME, CREATE_PASS) \
1247#define MODULE_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1248 if (PassBuilder::checkParametrizedPassName(Name, NAME)) \
1250#define MODULE_ANALYSIS(NAME, CREATE_PASS) \
1251 if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
1253#include "PassRegistry.def"
1255 return callbacksAcceptPassName<ModulePassManager>(
Name, Callbacks);
1258template <
typename CallbacksT>
1261 StringRef NameNoBracket =
Name.take_until([](
char C) {
return C ==
'<'; });
1262 if (
Name ==
"cgscc")
1264 if (NameNoBracket ==
"function")
1271#define CGSCC_PASS(NAME, CREATE_PASS) \
1274#define CGSCC_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1275 if (PassBuilder::checkParametrizedPassName(Name, NAME)) \
1277#define CGSCC_ANALYSIS(NAME, CREATE_PASS) \
1278 if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
1280#include "PassRegistry.def"
1282 return callbacksAcceptPassName<CGSCCPassManager>(
Name, Callbacks);
1285template <
typename CallbacksT>
1288 StringRef NameNoBracket =
Name.take_until([](
char C) {
return C ==
'<'; });
1289 if (NameNoBracket ==
"function")
1291 if (
Name ==
"loop" ||
Name ==
"loop-mssa" ||
Name ==
"machine-function")
1294#define FUNCTION_PASS(NAME, CREATE_PASS) \
1297#define FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1298 if (PassBuilder::checkParametrizedPassName(Name, NAME)) \
1300#define FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
1301 if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
1303#include "PassRegistry.def"
1305 return callbacksAcceptPassName<FunctionPassManager>(
Name, Callbacks);
1308template <
typename CallbacksT>
1311 if (
Name ==
"machine-function")
1314#define MACHINE_FUNCTION_PASS(NAME, CREATE_PASS) \
1317#define MACHINE_FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, \
1319 if (PassBuilder::checkParametrizedPassName(Name, NAME)) \
1322#define MACHINE_FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
1323 if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
1326#include "llvm/Passes/MachinePassRegistry.def"
1328 return callbacksAcceptPassName<MachineFunctionPassManager>(
Name, Callbacks);
1331template <
typename CallbacksT>
1333 bool &UseMemorySSA) {
1334 UseMemorySSA =
false;
1337 UseMemorySSA =
true;
1341#define LOOPNEST_PASS(NAME, CREATE_PASS) \
1344#include "PassRegistry.def"
1346 return callbacksAcceptPassName<LoopPassManager>(
Name, Callbacks);
1349template <
typename CallbacksT>
1351 bool &UseMemorySSA) {
1352 UseMemorySSA =
false;
1355 UseMemorySSA =
true;
1359#define LOOP_PASS(NAME, CREATE_PASS) \
1362#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1363 if (PassBuilder::checkParametrizedPassName(Name, NAME)) \
1365#define LOOP_ANALYSIS(NAME, CREATE_PASS) \
1366 if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
1368#include "PassRegistry.def"
1370 return callbacksAcceptPassName<LoopPassManager>(
Name, Callbacks);
1373std::optional<std::vector<PassBuilder::PipelineElement>>
1374PassBuilder::parsePipelineText(
StringRef Text) {
1375 std::vector<PipelineElement> ResultPipeline;
1380 std::vector<PipelineElement> &Pipeline = *PipelineStack.
back();
1381 size_t Pos =
Text.find_first_of(
",()");
1382 Pipeline.push_back({
Text.substr(0, Pos), {}});
1385 if (Pos ==
Text.npos)
1388 char Sep =
Text[Pos];
1396 PipelineStack.
push_back(&Pipeline.back().InnerPipeline);
1400 assert(Sep ==
')' &&
"Bogus separator!");
1405 if (PipelineStack.
size() == 1)
1406 return std::nullopt;
1409 }
while (
Text.consume_front(
")"));
1417 if (!
Text.consume_front(
","))
1418 return std::nullopt;
1421 if (PipelineStack.
size() > 1)
1423 return std::nullopt;
1425 assert(PipelineStack.
back() == &ResultPipeline &&
1426 "Wrong pipeline at the bottom of the stack!");
1427 return {std::move(ResultPipeline)};
1431 const PipelineElement &E) {
1432 auto &
Name = E.Name;
1433 auto &InnerPipeline = E.InnerPipeline;
1436 if (!InnerPipeline.empty()) {
1437 if (
Name ==
"module") {
1439 if (
auto Err = parseModulePassPipeline(NestedMPM, InnerPipeline))
1444 if (
Name ==
"coro-cond") {
1446 if (
auto Err = parseModulePassPipeline(NestedMPM, InnerPipeline))
1451 if (
Name ==
"cgscc") {
1453 if (
auto Err = parseCGSCCPassPipeline(CGPM, InnerPipeline))
1460 return make_error<StringError>(
1461 "cannot have a no-rerun module to function adaptor",
1464 if (
auto Err = parseFunctionPassPipeline(FPM, InnerPipeline))
1471 for (
auto &
C : ModulePipelineParsingCallbacks)
1476 return make_error<StringError>(
1477 formatv(
"invalid use of '{0}' pass as module pipeline",
Name).str(),
1486 return make_error<StringError>(
1487 formatv(
"unknown default pipeline alias '{0}'",
Name).str(),
1490 assert(Matches.
size() == 3 &&
"Must capture two matched strings!");
1502 if (Matches[1] ==
"default") {
1504 }
else if (Matches[1] ==
"thinlto-pre-link") {
1506 }
else if (Matches[1] ==
"thinlto") {
1508 }
else if (Matches[1] ==
"lto-pre-link") {
1517 assert(Matches[1] ==
"lto" &&
"Not one of the matched options!");
1524#define MODULE_PASS(NAME, CREATE_PASS) \
1525 if (Name == NAME) { \
1526 MPM.addPass(CREATE_PASS); \
1527 return Error::success(); \
1529#define MODULE_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1530 if (checkParametrizedPassName(Name, NAME)) { \
1531 auto Params = parsePassParameters(PARSER, Name, NAME); \
1533 return Params.takeError(); \
1534 MPM.addPass(CREATE_PASS(Params.get())); \
1535 return Error::success(); \
1537#define MODULE_ANALYSIS(NAME, CREATE_PASS) \
1538 if (Name == "require<" NAME ">") { \
1540 RequireAnalysisPass< \
1541 std::remove_reference_t<decltype(CREATE_PASS)>, Module>()); \
1542 return Error::success(); \
1544 if (Name == "invalidate<" NAME ">") { \
1545 MPM.addPass(InvalidateAnalysisPass< \
1546 std::remove_reference_t<decltype(CREATE_PASS)>>()); \
1547 return Error::success(); \
1549#define CGSCC_PASS(NAME, CREATE_PASS) \
1550 if (Name == NAME) { \
1551 MPM.addPass(createModuleToPostOrderCGSCCPassAdaptor(CREATE_PASS)); \
1552 return Error::success(); \
1554#define CGSCC_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1555 if (checkParametrizedPassName(Name, NAME)) { \
1556 auto Params = parsePassParameters(PARSER, Name, NAME); \
1558 return Params.takeError(); \
1560 createModuleToPostOrderCGSCCPassAdaptor(CREATE_PASS(Params.get()))); \
1561 return Error::success(); \
1563#define FUNCTION_PASS(NAME, CREATE_PASS) \
1564 if (Name == NAME) { \
1565 MPM.addPass(createModuleToFunctionPassAdaptor(CREATE_PASS)); \
1566 return Error::success(); \
1568#define FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1569 if (checkParametrizedPassName(Name, NAME)) { \
1570 auto Params = parsePassParameters(PARSER, Name, NAME); \
1572 return Params.takeError(); \
1573 MPM.addPass(createModuleToFunctionPassAdaptor(CREATE_PASS(Params.get()))); \
1574 return Error::success(); \
1576#define LOOPNEST_PASS(NAME, CREATE_PASS) \
1577 if (Name == NAME) { \
1578 MPM.addPass(createModuleToFunctionPassAdaptor( \
1579 createFunctionToLoopPassAdaptor(CREATE_PASS, false, false))); \
1580 return Error::success(); \
1582#define LOOP_PASS(NAME, CREATE_PASS) \
1583 if (Name == NAME) { \
1584 MPM.addPass(createModuleToFunctionPassAdaptor( \
1585 createFunctionToLoopPassAdaptor(CREATE_PASS, false, false))); \
1586 return Error::success(); \
1588#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1589 if (checkParametrizedPassName(Name, NAME)) { \
1590 auto Params = parsePassParameters(PARSER, Name, NAME); \
1592 return Params.takeError(); \
1594 createModuleToFunctionPassAdaptor(createFunctionToLoopPassAdaptor( \
1595 CREATE_PASS(Params.get()), false, false))); \
1596 return Error::success(); \
1598#include "PassRegistry.def"
1600 for (
auto &
C : ModulePipelineParsingCallbacks)
1603 return make_error<StringError>(
1609 const PipelineElement &E) {
1610 auto &
Name = E.Name;
1611 auto &InnerPipeline = E.InnerPipeline;
1614 if (!InnerPipeline.empty()) {
1615 if (
Name ==
"cgscc") {
1617 if (
auto Err = parseCGSCCPassPipeline(NestedCGPM, InnerPipeline))
1620 CGPM.
addPass(std::move(NestedCGPM));
1625 if (
auto Err = parseFunctionPassPipeline(FPM, InnerPipeline))
1629 std::move(FPM), Params->first, Params->second));
1634 if (
auto Err = parseCGSCCPassPipeline(NestedCGPM, InnerPipeline))
1641 for (
auto &
C : CGSCCPipelineParsingCallbacks)
1642 if (
C(
Name, CGPM, InnerPipeline))
1646 return make_error<StringError>(
1647 formatv(
"invalid use of '{0}' pass as cgscc pipeline",
Name).str(),
1652#define CGSCC_PASS(NAME, CREATE_PASS) \
1653 if (Name == NAME) { \
1654 CGPM.addPass(CREATE_PASS); \
1655 return Error::success(); \
1657#define CGSCC_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1658 if (checkParametrizedPassName(Name, NAME)) { \
1659 auto Params = parsePassParameters(PARSER, Name, NAME); \
1661 return Params.takeError(); \
1662 CGPM.addPass(CREATE_PASS(Params.get())); \
1663 return Error::success(); \
1665#define CGSCC_ANALYSIS(NAME, CREATE_PASS) \
1666 if (Name == "require<" NAME ">") { \
1667 CGPM.addPass(RequireAnalysisPass< \
1668 std::remove_reference_t<decltype(CREATE_PASS)>, \
1669 LazyCallGraph::SCC, CGSCCAnalysisManager, LazyCallGraph &, \
1670 CGSCCUpdateResult &>()); \
1671 return Error::success(); \
1673 if (Name == "invalidate<" NAME ">") { \
1674 CGPM.addPass(InvalidateAnalysisPass< \
1675 std::remove_reference_t<decltype(CREATE_PASS)>>()); \
1676 return Error::success(); \
1678#define FUNCTION_PASS(NAME, CREATE_PASS) \
1679 if (Name == NAME) { \
1680 CGPM.addPass(createCGSCCToFunctionPassAdaptor(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 CGPM.addPass(createCGSCCToFunctionPassAdaptor(CREATE_PASS(Params.get()))); \
1689 return Error::success(); \
1691#define LOOPNEST_PASS(NAME, CREATE_PASS) \
1692 if (Name == NAME) { \
1693 CGPM.addPass(createCGSCCToFunctionPassAdaptor( \
1694 createFunctionToLoopPassAdaptor(CREATE_PASS, false, false))); \
1695 return Error::success(); \
1697#define LOOP_PASS(NAME, CREATE_PASS) \
1698 if (Name == NAME) { \
1699 CGPM.addPass(createCGSCCToFunctionPassAdaptor( \
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 createCGSCCToFunctionPassAdaptor(createFunctionToLoopPassAdaptor( \
1710 CREATE_PASS(Params.get()), false, false))); \
1711 return Error::success(); \
1713#include "PassRegistry.def"
1715 for (
auto &
C : CGSCCPipelineParsingCallbacks)
1716 if (
C(
Name, CGPM, 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 ==
"function") {
1732 if (
auto Err = parseFunctionPassPipeline(NestedFPM, InnerPipeline))
1735 FPM.
addPass(std::move(NestedFPM));
1738 if (
Name ==
"loop" ||
Name ==
"loop-mssa") {
1740 if (
auto Err = parseLoopPassPipeline(LPM, InnerPipeline))
1743 bool UseMemorySSA = (
Name ==
"loop-mssa");
1745 return Pipeline.Name.contains(
"simple-loop-unswitch");
1747 bool UseBPI =
llvm::any_of(InnerPipeline, [](
auto Pipeline) {
1748 return Pipeline.Name ==
"loop-predication";
1754 if (
Name ==
"machine-function") {
1756 if (
auto Err = parseMachinePassPipeline(MFPM, InnerPipeline))
1762 for (
auto &
C : FunctionPipelineParsingCallbacks)
1763 if (
C(
Name, FPM, InnerPipeline))
1767 return make_error<StringError>(
1768 formatv(
"invalid use of '{0}' pass as function pipeline",
Name).str(),
1773#define FUNCTION_PASS(NAME, CREATE_PASS) \
1774 if (Name == NAME) { \
1775 FPM.addPass(CREATE_PASS); \
1776 return Error::success(); \
1778#define FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1779 if (checkParametrizedPassName(Name, NAME)) { \
1780 auto Params = parsePassParameters(PARSER, Name, NAME); \
1782 return Params.takeError(); \
1783 FPM.addPass(CREATE_PASS(Params.get())); \
1784 return Error::success(); \
1786#define FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
1787 if (Name == "require<" NAME ">") { \
1789 RequireAnalysisPass< \
1790 std::remove_reference_t<decltype(CREATE_PASS)>, Function>()); \
1791 return Error::success(); \
1793 if (Name == "invalidate<" NAME ">") { \
1794 FPM.addPass(InvalidateAnalysisPass< \
1795 std::remove_reference_t<decltype(CREATE_PASS)>>()); \
1796 return Error::success(); \
1802#define LOOPNEST_PASS(NAME, CREATE_PASS) \
1803 if (Name == NAME) { \
1804 FPM.addPass(createFunctionToLoopPassAdaptor(CREATE_PASS, false, false)); \
1805 return Error::success(); \
1807#define LOOP_PASS(NAME, CREATE_PASS) \
1808 if (Name == NAME) { \
1809 FPM.addPass(createFunctionToLoopPassAdaptor(CREATE_PASS, false, false)); \
1810 return Error::success(); \
1812#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1813 if (checkParametrizedPassName(Name, NAME)) { \
1814 auto Params = parsePassParameters(PARSER, Name, NAME); \
1816 return Params.takeError(); \
1817 FPM.addPass(createFunctionToLoopPassAdaptor(CREATE_PASS(Params.get()), \
1819 return Error::success(); \
1821#include "PassRegistry.def"
1823 for (
auto &
C : FunctionPipelineParsingCallbacks)
1824 if (
C(
Name, FPM, InnerPipeline))
1826 return make_error<StringError>(
1827 formatv(
"unknown function pass '{0}'",
Name).str(),
1832 const PipelineElement &E) {
1834 auto &InnerPipeline = E.InnerPipeline;
1837 if (!InnerPipeline.empty()) {
1838 if (
Name ==
"loop") {
1840 if (
auto Err = parseLoopPassPipeline(NestedLPM, InnerPipeline))
1843 LPM.
addPass(std::move(NestedLPM));
1847 for (
auto &
C : LoopPipelineParsingCallbacks)
1848 if (
C(
Name, LPM, InnerPipeline))
1852 return make_error<StringError>(
1853 formatv(
"invalid use of '{0}' pass as loop pipeline",
Name).str(),
1858#define LOOPNEST_PASS(NAME, CREATE_PASS) \
1859 if (Name == NAME) { \
1860 LPM.addPass(CREATE_PASS); \
1861 return Error::success(); \
1863#define LOOP_PASS(NAME, CREATE_PASS) \
1864 if (Name == NAME) { \
1865 LPM.addPass(CREATE_PASS); \
1866 return Error::success(); \
1868#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1869 if (checkParametrizedPassName(Name, NAME)) { \
1870 auto Params = parsePassParameters(PARSER, Name, NAME); \
1872 return Params.takeError(); \
1873 LPM.addPass(CREATE_PASS(Params.get())); \
1874 return Error::success(); \
1876#define LOOP_ANALYSIS(NAME, CREATE_PASS) \
1877 if (Name == "require<" NAME ">") { \
1878 LPM.addPass(RequireAnalysisPass< \
1879 std::remove_reference_t<decltype(CREATE_PASS)>, Loop, \
1880 LoopAnalysisManager, LoopStandardAnalysisResults &, \
1882 return Error::success(); \
1884 if (Name == "invalidate<" NAME ">") { \
1885 LPM.addPass(InvalidateAnalysisPass< \
1886 std::remove_reference_t<decltype(CREATE_PASS)>>()); \
1887 return Error::success(); \
1889#include "PassRegistry.def"
1891 for (
auto &
C : LoopPipelineParsingCallbacks)
1892 if (
C(
Name, LPM, InnerPipeline))
1894 return make_error<StringError>(
formatv(
"unknown loop pass '{0}'",
Name).str(),
1899 const PipelineElement &E) {
1901 if (!E.InnerPipeline.empty())
1902 return make_error<StringError>(
"invalid pipeline",
1905#define MACHINE_MODULE_PASS(NAME, CREATE_PASS) \
1906 if (Name == NAME) { \
1907 MFPM.addPass(CREATE_PASS); \
1908 return Error::success(); \
1910#define MACHINE_FUNCTION_PASS(NAME, CREATE_PASS) \
1911 if (Name == NAME) { \
1912 MFPM.addPass(CREATE_PASS); \
1913 return Error::success(); \
1915#define MACHINE_FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, \
1917 if (checkParametrizedPassName(Name, NAME)) { \
1918 auto Params = parsePassParameters(PARSER, Name, NAME); \
1920 return Params.takeError(); \
1921 MFPM.addPass(CREATE_PASS(Params.get())); \
1922 return Error::success(); \
1924#define MACHINE_FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
1925 if (Name == "require<" NAME ">") { \
1927 RequireAnalysisPass<std::remove_reference_t<decltype(CREATE_PASS)>, \
1928 MachineFunction>()); \
1929 return Error::success(); \
1931 if (Name == "invalidate<" NAME ">") { \
1932 MFPM.addPass(InvalidateAnalysisPass< \
1933 std::remove_reference_t<decltype(CREATE_PASS)>>()); \
1934 return Error::success(); \
1936#include "llvm/Passes/MachinePassRegistry.def"
1938 for (
auto &
C : MachineFunctionPipelineParsingCallbacks)
1939 if (
C(
Name, MFPM, E.InnerPipeline))
1941 return make_error<StringError>(
1942 formatv(
"unknown machine pass '{0}'",
Name).str(),
1947#define MODULE_ALIAS_ANALYSIS(NAME, CREATE_PASS) \
1948 if (Name == NAME) { \
1949 AA.registerModuleAnalysis< \
1950 std::remove_reference_t<decltype(CREATE_PASS)>>(); \
1953#define FUNCTION_ALIAS_ANALYSIS(NAME, CREATE_PASS) \
1954 if (Name == NAME) { \
1955 AA.registerFunctionAnalysis< \
1956 std::remove_reference_t<decltype(CREATE_PASS)>>(); \
1959#include "PassRegistry.def"
1961 for (
auto &
C : AAParsingCallbacks)
1967Error PassBuilder::parseMachinePassPipeline(
1969 for (
const auto &Element : Pipeline) {
1970 if (
auto Err = parseMachinePass(MFPM, Element))
1978 for (
const auto &Element : Pipeline) {
1979 if (
auto Err = parseLoopPass(LPM, Element))
1985Error PassBuilder::parseFunctionPassPipeline(
1987 for (
const auto &Element : Pipeline) {
1988 if (
auto Err = parseFunctionPass(FPM, Element))
1996 for (
const auto &Element : Pipeline) {
1997 if (
auto Err = parseCGSCCPass(CGPM, Element))
2029 for (
const auto &Element : Pipeline) {
2030 if (
auto Err = parseModulePass(
MPM, Element))
2041 auto Pipeline = parsePipelineText(PipelineText);
2042 if (!Pipeline || Pipeline->empty())
2043 return make_error<StringError>(
2044 formatv(
"invalid pipeline '{0}'", PipelineText).str(),
2054 Pipeline = {{
"cgscc", std::move(*Pipeline)}};
2056 FunctionPipelineParsingCallbacks)) {
2057 Pipeline = {{
"function", std::move(*Pipeline)}};
2060 Pipeline = {{
"function", {{UseMemorySSA ?
"loop-mssa" :
"loop",
2061 std::move(*Pipeline)}}}};
2062 }
else if (
isLoopPassName(FirstName, LoopPipelineParsingCallbacks,
2064 Pipeline = {{
"function", {{UseMemorySSA ?
"loop-mssa" :
"loop",
2065 std::move(*Pipeline)}}}};
2067 FirstName, MachineFunctionPipelineParsingCallbacks)) {
2068 Pipeline = {{
"function", {{
"machine-function", std::move(*Pipeline)}}}};
2070 for (
auto &
C : TopLevelPipelineParsingCallbacks)
2071 if (
C(
MPM, *Pipeline))
2075 auto &InnerPipeline = Pipeline->front().InnerPipeline;
2076 return make_error<StringError>(
2077 formatv(
"unknown {0} name '{1}'",
2078 (InnerPipeline.empty() ?
"pass" :
"pipeline"), FirstName)
2084 if (
auto Err = parseModulePassPipeline(
MPM, *Pipeline))
2092 auto Pipeline = parsePipelineText(PipelineText);
2093 if (!Pipeline || Pipeline->empty())
2094 return make_error<StringError>(
2095 formatv(
"invalid pipeline '{0}'", PipelineText).str(),
2100 return make_error<StringError>(
2101 formatv(
"unknown cgscc pass '{0}' in pipeline '{1}'", FirstName,
2106 if (
auto Err = parseCGSCCPassPipeline(CGPM, *Pipeline))
2115 auto Pipeline = parsePipelineText(PipelineText);
2116 if (!Pipeline || Pipeline->empty())
2117 return make_error<StringError>(
2118 formatv(
"invalid pipeline '{0}'", PipelineText).str(),
2123 return make_error<StringError>(
2124 formatv(
"unknown function pass '{0}' in pipeline '{1}'", FirstName,
2129 if (
auto Err = parseFunctionPassPipeline(FPM, *Pipeline))
2137 auto Pipeline = parsePipelineText(PipelineText);
2138 if (!Pipeline || Pipeline->empty())
2139 return make_error<StringError>(
2140 formatv(
"invalid pipeline '{0}'", PipelineText).str(),
2143 if (
auto Err = parseLoopPassPipeline(CGPM, *Pipeline))
2151 auto Pipeline = parsePipelineText(PipelineText);
2152 if (!Pipeline || Pipeline->empty())
2153 return make_error<StringError>(
2154 formatv(
"invalid machine pass pipeline '{0}'", PipelineText).str(),
2157 if (
auto Err = parseMachinePassPipeline(MFPM, *Pipeline))
2166 if (PipelineText ==
"default") {
2171 while (!PipelineText.
empty()) {
2173 std::tie(
Name, PipelineText) = PipelineText.
split(
',');
2174 if (!parseAAPassName(AA,
Name))
2175 return make_error<StringError>(
2176 formatv(
"unknown alias analysis name '{0}'",
Name).str(),
2183std::optional<RegClassFilterFunc>
2185 if (FilterName ==
"all")
2187 for (
auto &
C : RegClassFilterParsingCallbacks)
2188 if (
auto F =
C(FilterName))
2190 return std::nullopt;
2198 OS <<
" " <<
PassName <<
"<" << Params <<
">\n";
2204 OS <<
"Module passes:\n";
2205#define MODULE_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2206#include "PassRegistry.def"
2208 OS <<
"Module passes with params:\n";
2209#define MODULE_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
2210 printPassName(NAME, PARAMS, OS);
2211#include "PassRegistry.def"
2213 OS <<
"Module analyses:\n";
2214#define MODULE_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2215#include "PassRegistry.def"
2217 OS <<
"Module alias analyses:\n";
2218#define MODULE_ALIAS_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2219#include "PassRegistry.def"
2221 OS <<
"CGSCC passes:\n";
2222#define CGSCC_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2223#include "PassRegistry.def"
2225 OS <<
"CGSCC passes with params:\n";
2226#define CGSCC_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
2227 printPassName(NAME, PARAMS, OS);
2228#include "PassRegistry.def"
2230 OS <<
"CGSCC analyses:\n";
2231#define CGSCC_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2232#include "PassRegistry.def"
2234 OS <<
"Function passes:\n";
2235#define FUNCTION_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2236#include "PassRegistry.def"
2238 OS <<
"Function passes with params:\n";
2239#define FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
2240 printPassName(NAME, PARAMS, OS);
2241#include "PassRegistry.def"
2243 OS <<
"Function analyses:\n";
2244#define FUNCTION_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2245#include "PassRegistry.def"
2247 OS <<
"Function alias analyses:\n";
2248#define FUNCTION_ALIAS_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2249#include "PassRegistry.def"
2251 OS <<
"LoopNest passes:\n";
2252#define LOOPNEST_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2253#include "PassRegistry.def"
2255 OS <<
"Loop passes:\n";
2256#define LOOP_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2257#include "PassRegistry.def"
2259 OS <<
"Loop passes with params:\n";
2260#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
2261 printPassName(NAME, PARAMS, OS);
2262#include "PassRegistry.def"
2264 OS <<
"Loop analyses:\n";
2265#define LOOP_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2266#include "PassRegistry.def"
2268 OS <<
"Machine module passes (WIP):\n";
2269#define MACHINE_MODULE_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2270#include "llvm/Passes/MachinePassRegistry.def"
2272 OS <<
"Machine function passes (WIP):\n";
2273#define MACHINE_FUNCTION_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2274#include "llvm/Passes/MachinePassRegistry.def"
2276 OS <<
"Machine function analyses (WIP):\n";
2277#define MACHINE_FUNCTION_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2278#include "llvm/Passes/MachinePassRegistry.def"
2284 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.
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
const char LLVMTargetMachineRef TM
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 header defines various interfaces for pass management in LLVM.
This file implements the PredicateInfo analysis, which creates an Extended SSA form for operations us...
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.
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, bool LTOPreLink=false)
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.
std::optional< RegClassFilterFunc > parseRegAllocFilter(StringRef RegClassFilterName)
Parse RegClassFilterName to get RegClassFilterFunc.
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.
This class manages callbacks registration, as well as provides a way for PassInstrumentation to pass ...
void registerClassToPassNameCallback(CallableT C)
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...
auto formatv(const char *Fmt, Ts &&...Vals) -> formatv_object< decltype(std::make_tuple(support::detail::build_format_adapter(std::forward< Ts >(Vals))...))>
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.
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
cl::opt< bool > PrintPipelinePasses("print-pipeline-passes", cl::desc("Print a '-passes' compatible string describing the pipeline " "(best-effort only)."))
OuterAnalysisManagerProxy< FunctionAnalysisManager, Loop, LoopStandardAnalysisResults & > FunctionAnalysisManagerLoopProxy
A proxy from a FunctionAnalysisManager to a Loop.
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.
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.
RegClassFilterFunc Filter