324 "^(default|thinlto-pre-link|thinlto|lto-pre-link|lto)<(O[0123sz])>$");
328 "print-pipeline-passes",
329 cl::desc(
"Print a '-passes' compatible string describing the pipeline "
330 "(best-effort only)."));
342class TriggerCrashModulePass :
public PassInfoMixin<TriggerCrashModulePass> {
351class TriggerCrashFunctionPass
358 static StringRef name() {
return "TriggerCrashFunctionPass"; }
363class TriggerVerifierErrorPass
371 GlobalValue::LinkageTypes::InternalLinkage,
372 "__bad_alias",
nullptr, &M);
392 static StringRef name() {
return "TriggerVerifierErrorPass"; }
397class RequireAllMachineFunctionPropertiesPass
398 :
public PassInfoMixin<RequireAllMachineFunctionPropertiesPass> {
407 MFProps.
set(MachineFunctionProperties::Property::FailedISel);
408 MFProps.
set(MachineFunctionProperties::Property::FailsVerification);
409 MFProps.
set(MachineFunctionProperties::Property::IsSSA);
410 MFProps.
set(MachineFunctionProperties::Property::Legalized);
411 MFProps.
set(MachineFunctionProperties::Property::NoPHIs);
412 MFProps.
set(MachineFunctionProperties::Property::NoVRegs);
413 MFProps.
set(MachineFunctionProperties::Property::RegBankSelected);
414 MFProps.
set(MachineFunctionProperties::Property::Selected);
415 MFProps.
set(MachineFunctionProperties::Property::TiedOpsRewritten);
416 MFProps.
set(MachineFunctionProperties::Property::TracksDebugUserValues);
417 MFProps.
set(MachineFunctionProperties::Property::TracksLiveness);
420 static StringRef name() {
return "RequireAllMachineFunctionPropertiesPass"; }
426 std::optional<PGOOptions> PGOOpt,
428 :
TM(
TM), PTO(PTO), PGOOpt(PGOOpt),
PIC(
PIC) {
430 TM->registerPassBuilderCallbacks(*
this);
436#define MODULE_PASS(NAME, CREATE_PASS) \
437 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
438#define MODULE_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
439 PIC->addClassToPassName(CLASS, NAME);
440#define MODULE_ANALYSIS(NAME, CREATE_PASS) \
441 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
442#define FUNCTION_PASS(NAME, CREATE_PASS) \
443 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
444#define FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
445 PIC->addClassToPassName(CLASS, NAME);
446#define FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
447 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
448#define LOOPNEST_PASS(NAME, CREATE_PASS) \
449 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
450#define LOOP_PASS(NAME, CREATE_PASS) \
451 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
452#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
453 PIC->addClassToPassName(CLASS, NAME);
454#define LOOP_ANALYSIS(NAME, CREATE_PASS) \
455 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
456#define CGSCC_PASS(NAME, CREATE_PASS) \
457 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
458#define CGSCC_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
459 PIC->addClassToPassName(CLASS, NAME);
460#define CGSCC_ANALYSIS(NAME, CREATE_PASS) \
461 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
462#include "PassRegistry.def"
464#define MACHINE_FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
465 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
466#define MACHINE_FUNCTION_PASS(NAME, CREATE_PASS) \
467 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
468#include "llvm/Passes/MachinePassRegistry.def"
474#define MODULE_ANALYSIS(NAME, CREATE_PASS) \
475 MAM.registerPass([&] { return CREATE_PASS; });
476#include "PassRegistry.def"
478 for (
auto &
C : ModuleAnalysisRegistrationCallbacks)
483#define CGSCC_ANALYSIS(NAME, CREATE_PASS) \
484 CGAM.registerPass([&] { return CREATE_PASS; });
485#include "PassRegistry.def"
487 for (
auto &
C : CGSCCAnalysisRegistrationCallbacks)
497#define FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
498 FAM.registerPass([&] { return CREATE_PASS; });
499#include "PassRegistry.def"
501 for (
auto &
C : FunctionAnalysisRegistrationCallbacks)
508#define MACHINE_FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
509 MFAM.registerPass([&] { return CREATE_PASS; });
510#include "llvm/Passes/MachinePassRegistry.def"
512 for (
auto &
C : MachineFunctionAnalysisRegistrationCallbacks)
517#define LOOP_ANALYSIS(NAME, CREATE_PASS) \
518 LAM.registerPass([&] { return CREATE_PASS; });
519#include "PassRegistry.def"
521 for (
auto &
C : LoopAnalysisRegistrationCallbacks)
525static std::optional<std::pair<bool, bool>>
527 std::pair<bool, bool> Params;
528 if (!
Name.consume_front(
"function"))
532 if (!
Name.consume_front(
"<") || !
Name.consume_back(
">"))
534 while (!
Name.empty()) {
535 auto [Front, Back] =
Name.split(
';');
537 if (Front ==
"eager-inv")
539 else if (Front ==
"no-rerun")
540 Params.second =
true;
548 if (!
Name.consume_front(
"devirt<") || !
Name.consume_back(
">"))
551 if (
Name.getAsInteger(0, Count) || Count < 0)
571 while (!Params.
empty()) {
573 std::tie(ParamName, Params) = Params.
split(
';');
575 if (ParamName == OptionName) {
578 return make_error<StringError>(
593 while (!Params.
empty()) {
595 std::tie(ParamName, Params) = Params.
split(
';');
599 return make_error<StringError>(
600 formatv(
"invalid HardwareLoopPass parameter '{0}' ", ParamName).str(),
605 if (ParamName.
consume_front(
"hardware-loop-counter-bitwidth=")) {
608 return make_error<StringError>(
609 formatv(
"invalid HardwareLoopPass parameter '{0}' ", ParamName).str(),
614 if (ParamName ==
"force-hardware-loops") {
616 }
else if (ParamName ==
"force-hardware-loop-phi") {
618 }
else if (ParamName ==
"force-nested-hardware-loop") {
620 }
else if (ParamName ==
"force-hardware-loop-guard") {
623 return make_error<StringError>(
624 formatv(
"invalid HardwarePass parameter '{0}' ", ParamName).str(),
628 return HardwareLoopOpts;
634 while (!Params.
empty()) {
636 std::tie(ParamName, Params) = Params.
split(
';');
637 std::optional<OptimizationLevel> OptLevel =
parseOptLevel(ParamName);
639 if (OptLevel && !OptLevel->isOptimizingForSize()) {
640 UnrollOpts.
setOptLevel(OptLevel->getSpeedupLevel());
646 return make_error<StringError>(
647 formatv(
"invalid LoopUnrollPass parameter '{0}' ", ParamName).str(),
654 if (ParamName ==
"partial") {
656 }
else if (ParamName ==
"peeling") {
658 }
else if (ParamName ==
"profile-peeling") {
660 }
else if (ParamName ==
"runtime") {
662 }
else if (ParamName ==
"upperbound") {
665 return make_error<StringError>(
666 formatv(
"invalid LoopUnrollPass parameter '{0}' ", ParamName).str(),
675 Params,
"vfe-linkage-unit-visibility",
"GlobalDCE");
695 Params,
"skip-non-recursive-function-attrs",
"PostOrderFunctionAttrs");
704 return make_error<StringError>(
705 formatv(
"too many CFGuardPass parameters '{0}' ", Params).str(),
708 if (Param ==
"check")
710 if (Param ==
"dispatch")
713 return make_error<StringError>(
714 formatv(
"invalid CFGuardPass mechanism: '{0}' ", Param).str(),
724 "EntryExitInstrumenter");
733 "LowerMatrixIntrinsics");
738 while (!Params.
empty()) {
740 std::tie(ParamName, Params) = Params.
split(
';');
742 if (ParamName ==
"kernel") {
743 Result.CompileKernel =
true;
745 return make_error<StringError>(
746 formatv(
"invalid AddressSanitizer pass parameter '{0}' ", ParamName)
756 while (!Params.
empty()) {
758 std::tie(ParamName, Params) = Params.
split(
';');
760 if (ParamName ==
"recover") {
762 }
else if (ParamName ==
"kernel") {
763 Result.CompileKernel =
true;
765 return make_error<StringError>(
766 formatv(
"invalid HWAddressSanitizer pass parameter '{0}' ", ParamName)
776 while (!Params.
empty()) {
778 std::tie(ParamName, Params) = Params.
split(
';');
780 if (ParamName ==
"thinlto") {
782 }
else if (ParamName ==
"emit-summary") {
783 Result.EmitLTOSummary =
true;
785 return make_error<StringError>(
786 formatv(
"invalid EmbedBitcode pass parameter '{0}' ", ParamName)
796 while (!Params.
empty()) {
798 std::tie(ParamName, Params) = Params.
split(
';');
800 if (ParamName ==
"recover") {
802 }
else if (ParamName ==
"kernel") {
806 return make_error<StringError>(
807 formatv(
"invalid argument to MemorySanitizer pass track-origins "
812 }
else if (ParamName ==
"eager-checks") {
813 Result.EagerChecks =
true;
815 return make_error<StringError>(
816 formatv(
"invalid MemorySanitizer pass parameter '{0}' ", ParamName)
827 while (!Params.
empty()) {
829 std::tie(ParamName, Params) = Params.
split(
';');
832 if (ParamName ==
"speculate-blocks") {
834 }
else if (ParamName ==
"simplify-cond-branch") {
836 }
else if (ParamName ==
"forward-switch-cond") {
838 }
else if (ParamName ==
"switch-range-to-icmp") {
840 }
else if (ParamName ==
"switch-to-lookup") {
842 }
else if (ParamName ==
"keep-loops") {
844 }
else if (ParamName ==
"hoist-common-insts") {
846 }
else if (ParamName ==
"sink-common-insts") {
848 }
else if (ParamName ==
"speculate-unpredictables") {
851 APInt BonusInstThreshold;
853 return make_error<StringError>(
854 formatv(
"invalid argument to SimplifyCFG pass bonus-threshold "
860 return make_error<StringError>(
861 formatv(
"invalid SimplifyCFG pass parameter '{0}' ", ParamName).str(),
872 Result.setVerifyFixpoint(
true);
873 while (!Params.
empty()) {
875 std::tie(ParamName, Params) = Params.
split(
';');
878 if (ParamName ==
"use-loop-info") {
880 }
else if (ParamName ==
"verify-fixpoint") {
885 return make_error<StringError>(
886 formatv(
"invalid argument to InstCombine pass max-iterations "
892 return make_error<StringError>(
893 formatv(
"invalid InstCombine pass parameter '{0}' ", ParamName).str(),
903 while (!Params.
empty()) {
905 std::tie(ParamName, Params) = Params.
split(
';');
908 if (ParamName ==
"interleave-forced-only") {
910 }
else if (ParamName ==
"vectorize-forced-only") {
913 return make_error<StringError>(
914 formatv(
"invalid LoopVectorize parameter '{0}' ", ParamName).str(),
922 std::pair<bool, bool>
Result = {
false,
true};
923 while (!Params.
empty()) {
925 std::tie(ParamName, Params) = Params.
split(
';');
928 if (ParamName ==
"nontrivial") {
930 }
else if (ParamName ==
"trivial") {
933 return make_error<StringError>(
934 formatv(
"invalid LoopUnswitch pass parameter '{0}' ", ParamName)
944 while (!Params.
empty()) {
946 std::tie(ParamName, Params) = Params.
split(
';');
949 if (ParamName ==
"allowspeculation") {
952 return make_error<StringError>(
953 formatv(
"invalid LICM pass parameter '{0}' ", ParamName).str(),
961 std::pair<bool, bool>
Result = {
true,
false};
962 while (!Params.
empty()) {
964 std::tie(ParamName, Params) = Params.
split(
';');
967 if (ParamName ==
"header-duplication") {
969 }
else if (ParamName ==
"prepare-for-lto") {
972 return make_error<StringError>(
973 formatv(
"invalid LoopRotate pass parameter '{0}' ", ParamName).str(),
982 while (!Params.
empty()) {
984 std::tie(ParamName, Params) = Params.
split(
';');
987 if (ParamName ==
"split-footer-bb") {
990 return make_error<StringError>(
991 formatv(
"invalid MergedLoadStoreMotion pass parameter '{0}' ",
1002 while (!Params.
empty()) {
1004 std::tie(ParamName, Params) = Params.
split(
';');
1007 if (ParamName ==
"pre") {
1009 }
else if (ParamName ==
"load-pre") {
1011 }
else if (ParamName ==
"split-backedge-load-pre") {
1013 }
else if (ParamName ==
"memdep") {
1016 return make_error<StringError>(
1017 formatv(
"invalid GVN pass parameter '{0}' ", ParamName).str(),
1026 while (!Params.
empty()) {
1028 std::tie(ParamName, Params) = Params.
split(
';');
1031 if (ParamName ==
"func-spec")
1034 return make_error<StringError>(
1035 formatv(
"invalid IPSCCP pass parameter '{0}' ", ParamName).str(),
1042 if (Params.
empty() || Params ==
"modify-cfg")
1044 if (Params ==
"preserve-cfg")
1046 return make_error<StringError>(
1047 formatv(
"invalid SROA pass parameter '{0}' (either preserve-cfg or "
1048 "modify-cfg can be specified)",
1055parseStackLifetimeOptions(
StringRef Params) {
1057 while (!Params.
empty()) {
1059 std::tie(ParamName, Params) = Params.
split(
';');
1061 if (ParamName ==
"may") {
1063 }
else if (ParamName ==
"must") {
1066 return make_error<StringError>(
1067 formatv(
"invalid StackLifetime parameter '{0}' ", ParamName).str(),
1076 "DependenceAnalysisPrinter");
1081 "SeparateConstOffsetFromGEP");
1085parseFunctionSimplificationPipelineOptions(
StringRef Params) {
1088 return make_error<StringError>(
1089 formatv(
"invalid function-simplification parameter '{0}' ", Params)
1098 "MemorySSAPrinterPass");
1103 "SpeculativeExecutionPass");
1108 while (!Params.
empty()) {
1110 std::tie(ParamName, Params) = Params.
split(
';');
1115 return make_error<StringError>(
1116 formatv(
"invalid MemProfUse pass parameter '{0}' ", ParamName).str(),
1125 "StructuralHashPrinterPass");
1130 "WinEHPreparePass");
1135 while (!Params.
empty()) {
1137 std::tie(ParamName, Params) = Params.
split(
';');
1140 if (ParamName ==
"group-by-use")
1142 else if (ParamName ==
"ignore-single-use")
1144 else if (ParamName ==
"merge-const")
1146 else if (ParamName ==
"merge-external")
1150 return make_error<StringError>(
1151 formatv(
"invalid GlobalMergePass parameter '{0}' ", ParamName)
1161 while (!Params.
empty()) {
1163 std::tie(ParamName, Params) = Params.
split(
';');
1168 return make_error<StringError>(
1169 formatv(
"invalid Internalize pass parameter '{0}' ", ParamName).str(),
1180 while (!Params.
empty()) {
1182 std::tie(ParamName, Params) = Params.
split(
';');
1185 std::optional<RegAllocFilterFunc>
Filter =
1188 return make_error<StringError>(
1189 formatv(
"invalid regallocfast register filter '{0}' ", ParamName)
1198 if (ParamName ==
"no-clear-vregs") {
1203 return make_error<StringError>(
1204 formatv(
"invalid regallocfast pass parameter '{0}' ", ParamName).str(),
1215 return Name.starts_with(
"default") ||
Name.starts_with(
"thinlto") ||
1216 Name.starts_with(
"lto");
1227template <
typename PassManagerT,
typename CallbacksT>
1229 if (!Callbacks.empty()) {
1230 PassManagerT DummyPM;
1231 for (
auto &CB : Callbacks)
1232 if (CB(
Name, DummyPM, {}))
1238template <
typename CallbacksT>
1244 StringRef NameNoBracket =
Name.take_until([](
char C) {
return C ==
'<'; });
1247 if (
Name ==
"module")
1249 if (
Name ==
"cgscc")
1251 if (NameNoBracket ==
"function")
1253 if (
Name ==
"coro-cond")
1256#define MODULE_PASS(NAME, CREATE_PASS) \
1259#define MODULE_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1260 if (PassBuilder::checkParametrizedPassName(Name, NAME)) \
1262#define MODULE_ANALYSIS(NAME, CREATE_PASS) \
1263 if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
1265#include "PassRegistry.def"
1267 return callbacksAcceptPassName<ModulePassManager>(
Name, Callbacks);
1270template <
typename CallbacksT>
1273 StringRef NameNoBracket =
Name.take_until([](
char C) {
return C ==
'<'; });
1274 if (
Name ==
"cgscc")
1276 if (NameNoBracket ==
"function")
1283#define CGSCC_PASS(NAME, CREATE_PASS) \
1286#define CGSCC_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1287 if (PassBuilder::checkParametrizedPassName(Name, NAME)) \
1289#define CGSCC_ANALYSIS(NAME, CREATE_PASS) \
1290 if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
1292#include "PassRegistry.def"
1294 return callbacksAcceptPassName<CGSCCPassManager>(
Name, Callbacks);
1297template <
typename CallbacksT>
1300 StringRef NameNoBracket =
Name.take_until([](
char C) {
return C ==
'<'; });
1301 if (NameNoBracket ==
"function")
1303 if (
Name ==
"loop" ||
Name ==
"loop-mssa" ||
Name ==
"machine-function")
1306#define FUNCTION_PASS(NAME, CREATE_PASS) \
1309#define FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1310 if (PassBuilder::checkParametrizedPassName(Name, NAME)) \
1312#define FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
1313 if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
1315#include "PassRegistry.def"
1317 return callbacksAcceptPassName<FunctionPassManager>(
Name, Callbacks);
1320template <
typename CallbacksT>
1323 if (
Name ==
"machine-function")
1326#define MACHINE_FUNCTION_PASS(NAME, CREATE_PASS) \
1329#define MACHINE_FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, \
1331 if (PassBuilder::checkParametrizedPassName(Name, NAME)) \
1334#define MACHINE_FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
1335 if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
1338#include "llvm/Passes/MachinePassRegistry.def"
1340 return callbacksAcceptPassName<MachineFunctionPassManager>(
Name, Callbacks);
1343template <
typename CallbacksT>
1345 bool &UseMemorySSA) {
1346 UseMemorySSA =
false;
1349 UseMemorySSA =
true;
1353#define LOOPNEST_PASS(NAME, CREATE_PASS) \
1356#include "PassRegistry.def"
1358 return callbacksAcceptPassName<LoopPassManager>(
Name, Callbacks);
1361template <
typename CallbacksT>
1363 bool &UseMemorySSA) {
1364 UseMemorySSA =
false;
1367 UseMemorySSA =
true;
1371#define LOOP_PASS(NAME, CREATE_PASS) \
1374#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1375 if (PassBuilder::checkParametrizedPassName(Name, NAME)) \
1377#define LOOP_ANALYSIS(NAME, CREATE_PASS) \
1378 if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
1380#include "PassRegistry.def"
1382 return callbacksAcceptPassName<LoopPassManager>(
Name, Callbacks);
1385std::optional<std::vector<PassBuilder::PipelineElement>>
1386PassBuilder::parsePipelineText(
StringRef Text) {
1387 std::vector<PipelineElement> ResultPipeline;
1392 std::vector<PipelineElement> &Pipeline = *PipelineStack.
back();
1393 size_t Pos =
Text.find_first_of(
",()");
1394 Pipeline.push_back({
Text.substr(0, Pos), {}});
1397 if (Pos ==
Text.npos)
1400 char Sep =
Text[Pos];
1408 PipelineStack.
push_back(&Pipeline.back().InnerPipeline);
1412 assert(Sep ==
')' &&
"Bogus separator!");
1417 if (PipelineStack.
size() == 1)
1418 return std::nullopt;
1421 }
while (
Text.consume_front(
")"));
1429 if (!
Text.consume_front(
","))
1430 return std::nullopt;
1433 if (PipelineStack.
size() > 1)
1435 return std::nullopt;
1437 assert(PipelineStack.
back() == &ResultPipeline &&
1438 "Wrong pipeline at the bottom of the stack!");
1439 return {std::move(ResultPipeline)};
1443 const PipelineElement &E) {
1444 auto &
Name = E.Name;
1445 auto &InnerPipeline = E.InnerPipeline;
1448 if (!InnerPipeline.empty()) {
1449 if (
Name ==
"module") {
1451 if (
auto Err = parseModulePassPipeline(NestedMPM, InnerPipeline))
1456 if (
Name ==
"coro-cond") {
1458 if (
auto Err = parseModulePassPipeline(NestedMPM, InnerPipeline))
1463 if (
Name ==
"cgscc") {
1465 if (
auto Err = parseCGSCCPassPipeline(CGPM, InnerPipeline))
1472 return make_error<StringError>(
1473 "cannot have a no-rerun module to function adaptor",
1476 if (
auto Err = parseFunctionPassPipeline(FPM, InnerPipeline))
1483 for (
auto &
C : ModulePipelineParsingCallbacks)
1488 return make_error<StringError>(
1489 formatv(
"invalid use of '{0}' pass as module pipeline",
Name).str(),
1498 return make_error<StringError>(
1499 formatv(
"unknown default pipeline alias '{0}'",
Name).str(),
1502 assert(Matches.
size() == 3 &&
"Must capture two matched strings!");
1514 if (Matches[1] ==
"default") {
1516 }
else if (Matches[1] ==
"thinlto-pre-link") {
1518 }
else if (Matches[1] ==
"thinlto") {
1520 }
else if (Matches[1] ==
"lto-pre-link") {
1529 assert(Matches[1] ==
"lto" &&
"Not one of the matched options!");
1536#define MODULE_PASS(NAME, CREATE_PASS) \
1537 if (Name == NAME) { \
1538 MPM.addPass(CREATE_PASS); \
1539 return Error::success(); \
1541#define MODULE_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1542 if (checkParametrizedPassName(Name, NAME)) { \
1543 auto Params = parsePassParameters(PARSER, Name, NAME); \
1545 return Params.takeError(); \
1546 MPM.addPass(CREATE_PASS(Params.get())); \
1547 return Error::success(); \
1549#define MODULE_ANALYSIS(NAME, CREATE_PASS) \
1550 if (Name == "require<" NAME ">") { \
1552 RequireAnalysisPass< \
1553 std::remove_reference_t<decltype(CREATE_PASS)>, Module>()); \
1554 return Error::success(); \
1556 if (Name == "invalidate<" NAME ">") { \
1557 MPM.addPass(InvalidateAnalysisPass< \
1558 std::remove_reference_t<decltype(CREATE_PASS)>>()); \
1559 return Error::success(); \
1561#define CGSCC_PASS(NAME, CREATE_PASS) \
1562 if (Name == NAME) { \
1563 MPM.addPass(createModuleToPostOrderCGSCCPassAdaptor(CREATE_PASS)); \
1564 return Error::success(); \
1566#define CGSCC_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1567 if (checkParametrizedPassName(Name, NAME)) { \
1568 auto Params = parsePassParameters(PARSER, Name, NAME); \
1570 return Params.takeError(); \
1572 createModuleToPostOrderCGSCCPassAdaptor(CREATE_PASS(Params.get()))); \
1573 return Error::success(); \
1575#define FUNCTION_PASS(NAME, CREATE_PASS) \
1576 if (Name == NAME) { \
1577 MPM.addPass(createModuleToFunctionPassAdaptor(CREATE_PASS)); \
1578 return Error::success(); \
1580#define FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1581 if (checkParametrizedPassName(Name, NAME)) { \
1582 auto Params = parsePassParameters(PARSER, Name, NAME); \
1584 return Params.takeError(); \
1585 MPM.addPass(createModuleToFunctionPassAdaptor(CREATE_PASS(Params.get()))); \
1586 return Error::success(); \
1588#define LOOPNEST_PASS(NAME, CREATE_PASS) \
1589 if (Name == NAME) { \
1590 MPM.addPass(createModuleToFunctionPassAdaptor( \
1591 createFunctionToLoopPassAdaptor(CREATE_PASS, false, false))); \
1592 return Error::success(); \
1594#define LOOP_PASS(NAME, CREATE_PASS) \
1595 if (Name == NAME) { \
1596 MPM.addPass(createModuleToFunctionPassAdaptor( \
1597 createFunctionToLoopPassAdaptor(CREATE_PASS, false, false))); \
1598 return Error::success(); \
1600#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1601 if (checkParametrizedPassName(Name, NAME)) { \
1602 auto Params = parsePassParameters(PARSER, Name, NAME); \
1604 return Params.takeError(); \
1606 createModuleToFunctionPassAdaptor(createFunctionToLoopPassAdaptor( \
1607 CREATE_PASS(Params.get()), false, false))); \
1608 return Error::success(); \
1610#include "PassRegistry.def"
1612 for (
auto &
C : ModulePipelineParsingCallbacks)
1615 return make_error<StringError>(
1621 const PipelineElement &E) {
1622 auto &
Name = E.Name;
1623 auto &InnerPipeline = E.InnerPipeline;
1626 if (!InnerPipeline.empty()) {
1627 if (
Name ==
"cgscc") {
1629 if (
auto Err = parseCGSCCPassPipeline(NestedCGPM, InnerPipeline))
1632 CGPM.
addPass(std::move(NestedCGPM));
1637 if (
auto Err = parseFunctionPassPipeline(FPM, InnerPipeline))
1641 std::move(FPM), Params->first, Params->second));
1646 if (
auto Err = parseCGSCCPassPipeline(NestedCGPM, InnerPipeline))
1653 for (
auto &
C : CGSCCPipelineParsingCallbacks)
1654 if (
C(
Name, CGPM, InnerPipeline))
1658 return make_error<StringError>(
1659 formatv(
"invalid use of '{0}' pass as cgscc pipeline",
Name).str(),
1664#define CGSCC_PASS(NAME, CREATE_PASS) \
1665 if (Name == NAME) { \
1666 CGPM.addPass(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(); \
1674 CGPM.addPass(CREATE_PASS(Params.get())); \
1675 return Error::success(); \
1677#define CGSCC_ANALYSIS(NAME, CREATE_PASS) \
1678 if (Name == "require<" NAME ">") { \
1679 CGPM.addPass(RequireAnalysisPass< \
1680 std::remove_reference_t<decltype(CREATE_PASS)>, \
1681 LazyCallGraph::SCC, CGSCCAnalysisManager, LazyCallGraph &, \
1682 CGSCCUpdateResult &>()); \
1683 return Error::success(); \
1685 if (Name == "invalidate<" NAME ">") { \
1686 CGPM.addPass(InvalidateAnalysisPass< \
1687 std::remove_reference_t<decltype(CREATE_PASS)>>()); \
1688 return Error::success(); \
1690#define FUNCTION_PASS(NAME, CREATE_PASS) \
1691 if (Name == NAME) { \
1692 CGPM.addPass(createCGSCCToFunctionPassAdaptor(CREATE_PASS)); \
1693 return Error::success(); \
1695#define FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1696 if (checkParametrizedPassName(Name, NAME)) { \
1697 auto Params = parsePassParameters(PARSER, Name, NAME); \
1699 return Params.takeError(); \
1700 CGPM.addPass(createCGSCCToFunctionPassAdaptor(CREATE_PASS(Params.get()))); \
1701 return Error::success(); \
1703#define LOOPNEST_PASS(NAME, CREATE_PASS) \
1704 if (Name == NAME) { \
1705 CGPM.addPass(createCGSCCToFunctionPassAdaptor( \
1706 createFunctionToLoopPassAdaptor(CREATE_PASS, false, false))); \
1707 return Error::success(); \
1709#define LOOP_PASS(NAME, CREATE_PASS) \
1710 if (Name == NAME) { \
1711 CGPM.addPass(createCGSCCToFunctionPassAdaptor( \
1712 createFunctionToLoopPassAdaptor(CREATE_PASS, false, false))); \
1713 return Error::success(); \
1715#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1716 if (checkParametrizedPassName(Name, NAME)) { \
1717 auto Params = parsePassParameters(PARSER, Name, NAME); \
1719 return Params.takeError(); \
1721 createCGSCCToFunctionPassAdaptor(createFunctionToLoopPassAdaptor( \
1722 CREATE_PASS(Params.get()), false, false))); \
1723 return Error::success(); \
1725#include "PassRegistry.def"
1727 for (
auto &
C : CGSCCPipelineParsingCallbacks)
1728 if (
C(
Name, CGPM, InnerPipeline))
1730 return make_error<StringError>(
1736 const PipelineElement &E) {
1737 auto &
Name = E.Name;
1738 auto &InnerPipeline = E.InnerPipeline;
1741 if (!InnerPipeline.empty()) {
1742 if (
Name ==
"function") {
1744 if (
auto Err = parseFunctionPassPipeline(NestedFPM, InnerPipeline))
1747 FPM.
addPass(std::move(NestedFPM));
1750 if (
Name ==
"loop" ||
Name ==
"loop-mssa") {
1752 if (
auto Err = parseLoopPassPipeline(LPM, InnerPipeline))
1755 bool UseMemorySSA = (
Name ==
"loop-mssa");
1757 return Pipeline.Name.contains(
"simple-loop-unswitch");
1759 bool UseBPI =
llvm::any_of(InnerPipeline, [](
auto Pipeline) {
1760 return Pipeline.Name ==
"loop-predication";
1766 if (
Name ==
"machine-function") {
1768 if (
auto Err = parseMachinePassPipeline(MFPM, InnerPipeline))
1774 for (
auto &
C : FunctionPipelineParsingCallbacks)
1775 if (
C(
Name, FPM, InnerPipeline))
1779 return make_error<StringError>(
1780 formatv(
"invalid use of '{0}' pass as function pipeline",
Name).str(),
1785#define FUNCTION_PASS(NAME, CREATE_PASS) \
1786 if (Name == NAME) { \
1787 FPM.addPass(CREATE_PASS); \
1788 return Error::success(); \
1790#define FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1791 if (checkParametrizedPassName(Name, NAME)) { \
1792 auto Params = parsePassParameters(PARSER, Name, NAME); \
1794 return Params.takeError(); \
1795 FPM.addPass(CREATE_PASS(Params.get())); \
1796 return Error::success(); \
1798#define FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
1799 if (Name == "require<" NAME ">") { \
1801 RequireAnalysisPass< \
1802 std::remove_reference_t<decltype(CREATE_PASS)>, Function>()); \
1803 return Error::success(); \
1805 if (Name == "invalidate<" NAME ">") { \
1806 FPM.addPass(InvalidateAnalysisPass< \
1807 std::remove_reference_t<decltype(CREATE_PASS)>>()); \
1808 return Error::success(); \
1814#define LOOPNEST_PASS(NAME, CREATE_PASS) \
1815 if (Name == NAME) { \
1816 FPM.addPass(createFunctionToLoopPassAdaptor(CREATE_PASS, false, false)); \
1817 return Error::success(); \
1819#define LOOP_PASS(NAME, CREATE_PASS) \
1820 if (Name == NAME) { \
1821 FPM.addPass(createFunctionToLoopPassAdaptor(CREATE_PASS, false, false)); \
1822 return Error::success(); \
1824#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1825 if (checkParametrizedPassName(Name, NAME)) { \
1826 auto Params = parsePassParameters(PARSER, Name, NAME); \
1828 return Params.takeError(); \
1829 FPM.addPass(createFunctionToLoopPassAdaptor(CREATE_PASS(Params.get()), \
1831 return Error::success(); \
1833#include "PassRegistry.def"
1835 for (
auto &
C : FunctionPipelineParsingCallbacks)
1836 if (
C(
Name, FPM, InnerPipeline))
1838 return make_error<StringError>(
1839 formatv(
"unknown function pass '{0}'",
Name).str(),
1844 const PipelineElement &E) {
1846 auto &InnerPipeline = E.InnerPipeline;
1849 if (!InnerPipeline.empty()) {
1850 if (
Name ==
"loop") {
1852 if (
auto Err = parseLoopPassPipeline(NestedLPM, InnerPipeline))
1855 LPM.
addPass(std::move(NestedLPM));
1859 for (
auto &
C : LoopPipelineParsingCallbacks)
1860 if (
C(
Name, LPM, InnerPipeline))
1864 return make_error<StringError>(
1865 formatv(
"invalid use of '{0}' pass as loop pipeline",
Name).str(),
1870#define LOOPNEST_PASS(NAME, CREATE_PASS) \
1871 if (Name == NAME) { \
1872 LPM.addPass(CREATE_PASS); \
1873 return Error::success(); \
1875#define LOOP_PASS(NAME, CREATE_PASS) \
1876 if (Name == NAME) { \
1877 LPM.addPass(CREATE_PASS); \
1878 return Error::success(); \
1880#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1881 if (checkParametrizedPassName(Name, NAME)) { \
1882 auto Params = parsePassParameters(PARSER, Name, NAME); \
1884 return Params.takeError(); \
1885 LPM.addPass(CREATE_PASS(Params.get())); \
1886 return Error::success(); \
1888#define LOOP_ANALYSIS(NAME, CREATE_PASS) \
1889 if (Name == "require<" NAME ">") { \
1890 LPM.addPass(RequireAnalysisPass< \
1891 std::remove_reference_t<decltype(CREATE_PASS)>, Loop, \
1892 LoopAnalysisManager, LoopStandardAnalysisResults &, \
1894 return Error::success(); \
1896 if (Name == "invalidate<" NAME ">") { \
1897 LPM.addPass(InvalidateAnalysisPass< \
1898 std::remove_reference_t<decltype(CREATE_PASS)>>()); \
1899 return Error::success(); \
1901#include "PassRegistry.def"
1903 for (
auto &
C : LoopPipelineParsingCallbacks)
1904 if (
C(
Name, LPM, InnerPipeline))
1906 return make_error<StringError>(
formatv(
"unknown loop pass '{0}'",
Name).str(),
1911 const PipelineElement &E) {
1913 if (!E.InnerPipeline.empty())
1914 return make_error<StringError>(
"invalid pipeline",
1917#define MACHINE_MODULE_PASS(NAME, CREATE_PASS) \
1918 if (Name == NAME) { \
1919 MFPM.addPass(CREATE_PASS); \
1920 return Error::success(); \
1922#define MACHINE_FUNCTION_PASS(NAME, CREATE_PASS) \
1923 if (Name == NAME) { \
1924 MFPM.addPass(CREATE_PASS); \
1925 return Error::success(); \
1927#define MACHINE_FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, \
1929 if (checkParametrizedPassName(Name, NAME)) { \
1930 auto Params = parsePassParameters(PARSER, Name, NAME); \
1932 return Params.takeError(); \
1933 MFPM.addPass(CREATE_PASS(Params.get())); \
1934 return Error::success(); \
1936#define MACHINE_FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
1937 if (Name == "require<" NAME ">") { \
1939 RequireAnalysisPass<std::remove_reference_t<decltype(CREATE_PASS)>, \
1940 MachineFunction>()); \
1941 return Error::success(); \
1943 if (Name == "invalidate<" NAME ">") { \
1944 MFPM.addPass(InvalidateAnalysisPass< \
1945 std::remove_reference_t<decltype(CREATE_PASS)>>()); \
1946 return Error::success(); \
1948#include "llvm/Passes/MachinePassRegistry.def"
1950 for (
auto &
C : MachineFunctionPipelineParsingCallbacks)
1951 if (
C(
Name, MFPM, E.InnerPipeline))
1953 return make_error<StringError>(
1954 formatv(
"unknown machine pass '{0}'",
Name).str(),
1959#define MODULE_ALIAS_ANALYSIS(NAME, CREATE_PASS) \
1960 if (Name == NAME) { \
1961 AA.registerModuleAnalysis< \
1962 std::remove_reference_t<decltype(CREATE_PASS)>>(); \
1965#define FUNCTION_ALIAS_ANALYSIS(NAME, CREATE_PASS) \
1966 if (Name == NAME) { \
1967 AA.registerFunctionAnalysis< \
1968 std::remove_reference_t<decltype(CREATE_PASS)>>(); \
1971#include "PassRegistry.def"
1973 for (
auto &
C : AAParsingCallbacks)
1979Error PassBuilder::parseMachinePassPipeline(
1981 for (
const auto &Element : Pipeline) {
1982 if (
auto Err = parseMachinePass(MFPM, Element))
1990 for (
const auto &Element : Pipeline) {
1991 if (
auto Err = parseLoopPass(LPM, Element))
1997Error PassBuilder::parseFunctionPassPipeline(
1999 for (
const auto &Element : Pipeline) {
2000 if (
auto Err = parseFunctionPass(FPM, Element))
2008 for (
const auto &Element : Pipeline) {
2009 if (
auto Err = parseCGSCCPass(CGPM, Element))
2041 for (
const auto &Element : Pipeline) {
2042 if (
auto Err = parseModulePass(
MPM, Element))
2053 auto Pipeline = parsePipelineText(PipelineText);
2054 if (!Pipeline || Pipeline->empty())
2055 return make_error<StringError>(
2056 formatv(
"invalid pipeline '{0}'", PipelineText).str(),
2066 Pipeline = {{
"cgscc", std::move(*Pipeline)}};
2068 FunctionPipelineParsingCallbacks)) {
2069 Pipeline = {{
"function", std::move(*Pipeline)}};
2072 Pipeline = {{
"function", {{UseMemorySSA ?
"loop-mssa" :
"loop",
2073 std::move(*Pipeline)}}}};
2074 }
else if (
isLoopPassName(FirstName, LoopPipelineParsingCallbacks,
2076 Pipeline = {{
"function", {{UseMemorySSA ?
"loop-mssa" :
"loop",
2077 std::move(*Pipeline)}}}};
2079 FirstName, MachineFunctionPipelineParsingCallbacks)) {
2080 Pipeline = {{
"function", {{
"machine-function", std::move(*Pipeline)}}}};
2082 for (
auto &
C : TopLevelPipelineParsingCallbacks)
2083 if (
C(
MPM, *Pipeline))
2087 auto &InnerPipeline = Pipeline->front().InnerPipeline;
2088 return make_error<StringError>(
2089 formatv(
"unknown {0} name '{1}'",
2090 (InnerPipeline.empty() ?
"pass" :
"pipeline"), FirstName)
2096 if (
auto Err = parseModulePassPipeline(
MPM, *Pipeline))
2104 auto Pipeline = parsePipelineText(PipelineText);
2105 if (!Pipeline || Pipeline->empty())
2106 return make_error<StringError>(
2107 formatv(
"invalid pipeline '{0}'", PipelineText).str(),
2112 return make_error<StringError>(
2113 formatv(
"unknown cgscc pass '{0}' in pipeline '{1}'", FirstName,
2118 if (
auto Err = parseCGSCCPassPipeline(CGPM, *Pipeline))
2127 auto Pipeline = parsePipelineText(PipelineText);
2128 if (!Pipeline || Pipeline->empty())
2129 return make_error<StringError>(
2130 formatv(
"invalid pipeline '{0}'", PipelineText).str(),
2135 return make_error<StringError>(
2136 formatv(
"unknown function pass '{0}' in pipeline '{1}'", FirstName,
2141 if (
auto Err = parseFunctionPassPipeline(FPM, *Pipeline))
2149 auto Pipeline = parsePipelineText(PipelineText);
2150 if (!Pipeline || Pipeline->empty())
2151 return make_error<StringError>(
2152 formatv(
"invalid pipeline '{0}'", PipelineText).str(),
2155 if (
auto Err = parseLoopPassPipeline(CGPM, *Pipeline))
2163 auto Pipeline = parsePipelineText(PipelineText);
2164 if (!Pipeline || Pipeline->empty())
2165 return make_error<StringError>(
2166 formatv(
"invalid machine pass pipeline '{0}'", PipelineText).str(),
2169 if (
auto Err = parseMachinePassPipeline(MFPM, *Pipeline))
2178 if (PipelineText ==
"default") {
2183 while (!PipelineText.
empty()) {
2185 std::tie(
Name, PipelineText) = PipelineText.
split(
',');
2186 if (!parseAAPassName(AA,
Name))
2187 return make_error<StringError>(
2188 formatv(
"unknown alias analysis name '{0}'",
Name).str(),
2195std::optional<RegAllocFilterFunc>
2197 if (FilterName ==
"all")
2199 for (
auto &
C : RegClassFilterParsingCallbacks)
2200 if (
auto F =
C(FilterName))
2202 return std::nullopt;
2210 OS <<
" " <<
PassName <<
"<" << Params <<
">\n";
2216 OS <<
"Module passes:\n";
2217#define MODULE_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2218#include "PassRegistry.def"
2220 OS <<
"Module passes with params:\n";
2221#define MODULE_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
2222 printPassName(NAME, PARAMS, OS);
2223#include "PassRegistry.def"
2225 OS <<
"Module analyses:\n";
2226#define MODULE_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2227#include "PassRegistry.def"
2229 OS <<
"Module alias analyses:\n";
2230#define MODULE_ALIAS_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2231#include "PassRegistry.def"
2233 OS <<
"CGSCC passes:\n";
2234#define CGSCC_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2235#include "PassRegistry.def"
2237 OS <<
"CGSCC passes with params:\n";
2238#define CGSCC_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
2239 printPassName(NAME, PARAMS, OS);
2240#include "PassRegistry.def"
2242 OS <<
"CGSCC analyses:\n";
2243#define CGSCC_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2244#include "PassRegistry.def"
2246 OS <<
"Function passes:\n";
2247#define FUNCTION_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2248#include "PassRegistry.def"
2250 OS <<
"Function passes with params:\n";
2251#define FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
2252 printPassName(NAME, PARAMS, OS);
2253#include "PassRegistry.def"
2255 OS <<
"Function analyses:\n";
2256#define FUNCTION_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2257#include "PassRegistry.def"
2259 OS <<
"Function alias analyses:\n";
2260#define FUNCTION_ALIAS_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2261#include "PassRegistry.def"
2263 OS <<
"LoopNest passes:\n";
2264#define LOOPNEST_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2265#include "PassRegistry.def"
2267 OS <<
"Loop passes:\n";
2268#define LOOP_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2269#include "PassRegistry.def"
2271 OS <<
"Loop passes with params:\n";
2272#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
2273 printPassName(NAME, PARAMS, OS);
2274#include "PassRegistry.def"
2276 OS <<
"Loop analyses:\n";
2277#define LOOP_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2278#include "PassRegistry.def"
2280 OS <<
"Machine module passes (WIP):\n";
2281#define MACHINE_MODULE_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2282#include "llvm/Passes/MachinePassRegistry.def"
2284 OS <<
"Machine function passes (WIP):\n";
2285#define MACHINE_FUNCTION_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2286#include "llvm/Passes/MachinePassRegistry.def"
2288 OS <<
"Machine function analyses (WIP):\n";
2289#define MACHINE_FUNCTION_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2290#include "llvm/Passes/MachinePassRegistry.def"
2296 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.
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, 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.
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.
RegAllocFilterFunc Filter