315 "^(default|thinlto-pre-link|thinlto|lto-pre-link|lto)<(O[0123sz])>$");
319 "print-pipeline-passes",
320 cl::desc(
"Print a '-passes' compatible string describing the pipeline "
321 "(best-effort only)."));
333class TriggerCrashModulePass :
public PassInfoMixin<TriggerCrashModulePass> {
342class TriggerCrashFunctionPass
349 static StringRef name() {
return "TriggerCrashFunctionPass"; }
354class TriggerVerifierErrorPass
362 GlobalValue::LinkageTypes::InternalLinkage,
363 "__bad_alias",
nullptr, &M);
383 static StringRef name() {
return "TriggerVerifierErrorPass"; }
388class RequireAllMachineFunctionPropertiesPass
389 :
public PassInfoMixin<RequireAllMachineFunctionPropertiesPass> {
398 MFProps.
set(MachineFunctionProperties::Property::FailedISel);
399 MFProps.
set(MachineFunctionProperties::Property::FailsVerification);
400 MFProps.
set(MachineFunctionProperties::Property::IsSSA);
401 MFProps.
set(MachineFunctionProperties::Property::Legalized);
402 MFProps.
set(MachineFunctionProperties::Property::NoPHIs);
403 MFProps.
set(MachineFunctionProperties::Property::NoVRegs);
404 MFProps.
set(MachineFunctionProperties::Property::RegBankSelected);
405 MFProps.
set(MachineFunctionProperties::Property::Selected);
406 MFProps.
set(MachineFunctionProperties::Property::TiedOpsRewritten);
407 MFProps.
set(MachineFunctionProperties::Property::TracksDebugUserValues);
408 MFProps.
set(MachineFunctionProperties::Property::TracksLiveness);
411 static StringRef name() {
return "RequireAllMachineFunctionPropertiesPass"; }
417 std::optional<PGOOptions> PGOOpt,
419 :
TM(
TM), PTO(PTO), PGOOpt(PGOOpt),
PIC(
PIC) {
421 TM->registerPassBuilderCallbacks(*
this);
427#define MODULE_PASS(NAME, CREATE_PASS) \
428 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
429#define MODULE_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
430 PIC->addClassToPassName(CLASS, NAME);
431#define MODULE_ANALYSIS(NAME, CREATE_PASS) \
432 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
433#define FUNCTION_PASS(NAME, CREATE_PASS) \
434 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
435#define FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
436 PIC->addClassToPassName(CLASS, NAME);
437#define FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
438 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
439#define LOOPNEST_PASS(NAME, CREATE_PASS) \
440 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
441#define LOOP_PASS(NAME, CREATE_PASS) \
442 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
443#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
444 PIC->addClassToPassName(CLASS, NAME);
445#define LOOP_ANALYSIS(NAME, CREATE_PASS) \
446 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
447#define CGSCC_PASS(NAME, CREATE_PASS) \
448 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
449#define CGSCC_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
450 PIC->addClassToPassName(CLASS, NAME);
451#define CGSCC_ANALYSIS(NAME, CREATE_PASS) \
452 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
453#include "PassRegistry.def"
455#define MACHINE_FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
456 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
457#define MACHINE_FUNCTION_PASS(NAME, CREATE_PASS) \
458 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
459#include "llvm/Passes/MachinePassRegistry.def"
465#define MODULE_ANALYSIS(NAME, CREATE_PASS) \
466 MAM.registerPass([&] { return CREATE_PASS; });
467#include "PassRegistry.def"
469 for (
auto &
C : ModuleAnalysisRegistrationCallbacks)
474#define CGSCC_ANALYSIS(NAME, CREATE_PASS) \
475 CGAM.registerPass([&] { return CREATE_PASS; });
476#include "PassRegistry.def"
478 for (
auto &
C : CGSCCAnalysisRegistrationCallbacks)
488#define FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
489 FAM.registerPass([&] { return CREATE_PASS; });
490#include "PassRegistry.def"
492 for (
auto &
C : FunctionAnalysisRegistrationCallbacks)
499#define MACHINE_FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
500 MFAM.registerPass([&] { return CREATE_PASS; });
501#include "llvm/Passes/MachinePassRegistry.def"
503 for (
auto &
C : MachineFunctionAnalysisRegistrationCallbacks)
508#define LOOP_ANALYSIS(NAME, CREATE_PASS) \
509 LAM.registerPass([&] { return CREATE_PASS; });
510#include "PassRegistry.def"
512 for (
auto &
C : LoopAnalysisRegistrationCallbacks)
516static std::optional<std::pair<bool, bool>>
518 std::pair<bool, bool> Params;
519 if (!
Name.consume_front(
"function"))
523 if (!
Name.consume_front(
"<") || !
Name.consume_back(
">"))
525 while (!
Name.empty()) {
526 auto [Front, Back] =
Name.split(
';');
528 if (Front ==
"eager-inv")
530 else if (Front ==
"no-rerun")
531 Params.second =
true;
539 if (!
Name.consume_front(
"devirt<") || !
Name.consume_back(
">"))
542 if (
Name.getAsInteger(0, Count) || Count < 0)
562 while (!Params.
empty()) {
564 std::tie(ParamName, Params) = Params.
split(
';');
566 if (ParamName == OptionName) {
569 return make_error<StringError>(
584 while (!Params.
empty()) {
586 std::tie(ParamName, Params) = Params.
split(
';');
590 return make_error<StringError>(
591 formatv(
"invalid HardwareLoopPass parameter '{0}' ", ParamName).str(),
596 if (ParamName.
consume_front(
"hardware-loop-counter-bitwidth=")) {
599 return make_error<StringError>(
600 formatv(
"invalid HardwareLoopPass parameter '{0}' ", ParamName).str(),
605 if (ParamName ==
"force-hardware-loops") {
607 }
else if (ParamName ==
"force-hardware-loop-phi") {
609 }
else if (ParamName ==
"force-nested-hardware-loop") {
611 }
else if (ParamName ==
"force-hardware-loop-guard") {
614 return make_error<StringError>(
615 formatv(
"invalid HardwarePass parameter '{0}' ", ParamName).str(),
619 return HardwareLoopOpts;
625 while (!Params.
empty()) {
627 std::tie(ParamName, Params) = Params.
split(
';');
628 std::optional<OptimizationLevel> OptLevel =
parseOptLevel(ParamName);
630 if (OptLevel && !OptLevel->isOptimizingForSize()) {
631 UnrollOpts.
setOptLevel(OptLevel->getSpeedupLevel());
637 return make_error<StringError>(
638 formatv(
"invalid LoopUnrollPass parameter '{0}' ", ParamName).str(),
645 if (ParamName ==
"partial") {
647 }
else if (ParamName ==
"peeling") {
649 }
else if (ParamName ==
"profile-peeling") {
651 }
else if (ParamName ==
"runtime") {
653 }
else if (ParamName ==
"upperbound") {
656 return make_error<StringError>(
657 formatv(
"invalid LoopUnrollPass parameter '{0}' ", ParamName).str(),
666 Params,
"vfe-linkage-unit-visibility",
"GlobalDCE");
686 Params,
"skip-non-recursive-function-attrs",
"PostOrderFunctionAttrs");
695 return make_error<StringError>(
696 formatv(
"too many CFGuardPass parameters '{0}' ", Params).str(),
699 if (Param ==
"check")
701 if (Param ==
"dispatch")
704 return make_error<StringError>(
705 formatv(
"invalid CFGuardPass mechanism: '{0}' ", Param).str(),
715 "EntryExitInstrumenter");
724 "LowerMatrixIntrinsics");
729 while (!Params.
empty()) {
731 std::tie(ParamName, Params) = Params.
split(
';');
733 if (ParamName ==
"kernel") {
734 Result.CompileKernel =
true;
736 return make_error<StringError>(
737 formatv(
"invalid AddressSanitizer pass parameter '{0}' ", ParamName)
747 while (!Params.
empty()) {
749 std::tie(ParamName, Params) = Params.
split(
';');
751 if (ParamName ==
"recover") {
753 }
else if (ParamName ==
"kernel") {
754 Result.CompileKernel =
true;
756 return make_error<StringError>(
757 formatv(
"invalid HWAddressSanitizer pass parameter '{0}' ", ParamName)
767 while (!Params.
empty()) {
769 std::tie(ParamName, Params) = Params.
split(
';');
771 if (ParamName ==
"thinlto") {
773 }
else if (ParamName ==
"emit-summary") {
774 Result.EmitLTOSummary =
true;
776 return make_error<StringError>(
777 formatv(
"invalid EmbedBitcode pass parameter '{0}' ", ParamName)
787 while (!Params.
empty()) {
789 std::tie(ParamName, Params) = Params.
split(
';');
791 if (ParamName ==
"recover") {
793 }
else if (ParamName ==
"kernel") {
797 return make_error<StringError>(
798 formatv(
"invalid argument to MemorySanitizer pass track-origins "
803 }
else if (ParamName ==
"eager-checks") {
804 Result.EagerChecks =
true;
806 return make_error<StringError>(
807 formatv(
"invalid MemorySanitizer pass parameter '{0}' ", ParamName)
818 while (!Params.
empty()) {
820 std::tie(ParamName, Params) = Params.
split(
';');
823 if (ParamName ==
"speculate-blocks") {
825 }
else if (ParamName ==
"simplify-cond-branch") {
827 }
else if (ParamName ==
"forward-switch-cond") {
829 }
else if (ParamName ==
"switch-range-to-icmp") {
831 }
else if (ParamName ==
"switch-to-lookup") {
833 }
else if (ParamName ==
"keep-loops") {
835 }
else if (ParamName ==
"hoist-common-insts") {
837 }
else if (ParamName ==
"sink-common-insts") {
840 APInt BonusInstThreshold;
842 return make_error<StringError>(
843 formatv(
"invalid argument to SimplifyCFG pass bonus-threshold "
849 return make_error<StringError>(
850 formatv(
"invalid SimplifyCFG pass parameter '{0}' ", ParamName).str(),
861 Result.setVerifyFixpoint(
true);
862 while (!Params.
empty()) {
864 std::tie(ParamName, Params) = Params.
split(
';');
867 if (ParamName ==
"use-loop-info") {
869 }
else if (ParamName ==
"verify-fixpoint") {
874 return make_error<StringError>(
875 formatv(
"invalid argument to InstCombine pass max-iterations "
881 return make_error<StringError>(
882 formatv(
"invalid InstCombine pass parameter '{0}' ", ParamName).str(),
892 while (!Params.
empty()) {
894 std::tie(ParamName, Params) = Params.
split(
';');
897 if (ParamName ==
"interleave-forced-only") {
899 }
else if (ParamName ==
"vectorize-forced-only") {
902 return make_error<StringError>(
903 formatv(
"invalid LoopVectorize parameter '{0}' ", ParamName).str(),
911 std::pair<bool, bool>
Result = {
false,
true};
912 while (!Params.
empty()) {
914 std::tie(ParamName, Params) = Params.
split(
';');
917 if (ParamName ==
"nontrivial") {
919 }
else if (ParamName ==
"trivial") {
922 return make_error<StringError>(
923 formatv(
"invalid LoopUnswitch pass parameter '{0}' ", ParamName)
933 while (!Params.
empty()) {
935 std::tie(ParamName, Params) = Params.
split(
';');
938 if (ParamName ==
"allowspeculation") {
941 return make_error<StringError>(
942 formatv(
"invalid LICM pass parameter '{0}' ", ParamName).str(),
950 std::pair<bool, bool>
Result = {
true,
false};
951 while (!Params.
empty()) {
953 std::tie(ParamName, Params) = Params.
split(
';');
956 if (ParamName ==
"header-duplication") {
958 }
else if (ParamName ==
"prepare-for-lto") {
961 return make_error<StringError>(
962 formatv(
"invalid LoopRotate pass parameter '{0}' ", ParamName).str(),
971 while (!Params.
empty()) {
973 std::tie(ParamName, Params) = Params.
split(
';');
976 if (ParamName ==
"split-footer-bb") {
979 return make_error<StringError>(
980 formatv(
"invalid MergedLoadStoreMotion pass parameter '{0}' ",
991 while (!Params.
empty()) {
993 std::tie(ParamName, Params) = Params.
split(
';');
996 if (ParamName ==
"pre") {
998 }
else if (ParamName ==
"load-pre") {
1000 }
else if (ParamName ==
"split-backedge-load-pre") {
1002 }
else if (ParamName ==
"memdep") {
1005 return make_error<StringError>(
1006 formatv(
"invalid GVN pass parameter '{0}' ", ParamName).str(),
1015 while (!Params.
empty()) {
1017 std::tie(ParamName, Params) = Params.
split(
';');
1020 if (ParamName ==
"func-spec")
1023 return make_error<StringError>(
1024 formatv(
"invalid IPSCCP pass parameter '{0}' ", ParamName).str(),
1031 if (Params.
empty() || Params ==
"modify-cfg")
1033 if (Params ==
"preserve-cfg")
1035 return make_error<StringError>(
1036 formatv(
"invalid SROA pass parameter '{0}' (either preserve-cfg or "
1037 "modify-cfg can be specified)",
1044parseStackLifetimeOptions(
StringRef Params) {
1046 while (!Params.
empty()) {
1048 std::tie(ParamName, Params) = Params.
split(
';');
1050 if (ParamName ==
"may") {
1052 }
else if (ParamName ==
"must") {
1055 return make_error<StringError>(
1056 formatv(
"invalid StackLifetime parameter '{0}' ", ParamName).str(),
1065 "DependenceAnalysisPrinter");
1070 "SeparateConstOffsetFromGEP");
1074parseFunctionSimplificationPipelineOptions(
StringRef Params) {
1077 return make_error<StringError>(
1078 formatv(
"invalid function-simplification parameter '{0}' ", Params)
1087 "MemorySSAPrinterPass");
1092 "SpeculativeExecutionPass");
1097 while (!Params.
empty()) {
1099 std::tie(ParamName, Params) = Params.
split(
';');
1104 return make_error<StringError>(
1105 formatv(
"invalid MemProfUse pass parameter '{0}' ", ParamName).str(),
1114 "StructuralHashPrinterPass");
1119 "WinEHPreparePass");
1124 while (!Params.
empty()) {
1126 std::tie(ParamName, Params) = Params.
split(
';');
1129 if (ParamName ==
"group-by-use")
1131 else if (ParamName ==
"ignore-single-use")
1133 else if (ParamName ==
"merge-const")
1135 else if (ParamName ==
"merge-external")
1139 return make_error<StringError>(
1140 formatv(
"invalid GlobalMergePass parameter '{0}' ", ParamName)
1150 while (!Params.
empty()) {
1152 std::tie(ParamName, Params) = Params.
split(
';');
1157 return make_error<StringError>(
1158 formatv(
"invalid Internalize pass parameter '{0}' ", ParamName).str(),
1169 while (!Params.
empty()) {
1171 std::tie(ParamName, Params) = Params.
split(
';');
1174 std::optional<RegClassFilterFunc>
Filter =
1177 return make_error<StringError>(
1178 formatv(
"invalid regallocfast register filter '{0}' ", ParamName)
1187 if (ParamName ==
"no-clear-vregs") {
1192 return make_error<StringError>(
1193 formatv(
"invalid regallocfast pass parameter '{0}' ", ParamName).str(),
1204 return Name.starts_with(
"default") ||
Name.starts_with(
"thinlto") ||
1205 Name.starts_with(
"lto");
1216template <
typename PassManagerT,
typename CallbacksT>
1218 if (!Callbacks.empty()) {
1219 PassManagerT DummyPM;
1220 for (
auto &CB : Callbacks)
1221 if (CB(
Name, DummyPM, {}))
1227template <
typename CallbacksT>
1233 StringRef NameNoBracket =
Name.take_until([](
char C) {
return C ==
'<'; });
1236 if (
Name ==
"module")
1238 if (
Name ==
"cgscc")
1240 if (NameNoBracket ==
"function")
1242 if (
Name ==
"coro-cond")
1245#define MODULE_PASS(NAME, CREATE_PASS) \
1248#define MODULE_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1249 if (PassBuilder::checkParametrizedPassName(Name, NAME)) \
1251#define MODULE_ANALYSIS(NAME, CREATE_PASS) \
1252 if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
1254#include "PassRegistry.def"
1256 return callbacksAcceptPassName<ModulePassManager>(
Name, Callbacks);
1259template <
typename CallbacksT>
1262 StringRef NameNoBracket =
Name.take_until([](
char C) {
return C ==
'<'; });
1263 if (
Name ==
"cgscc")
1265 if (NameNoBracket ==
"function")
1272#define CGSCC_PASS(NAME, CREATE_PASS) \
1275#define CGSCC_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1276 if (PassBuilder::checkParametrizedPassName(Name, NAME)) \
1278#define CGSCC_ANALYSIS(NAME, CREATE_PASS) \
1279 if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
1281#include "PassRegistry.def"
1283 return callbacksAcceptPassName<CGSCCPassManager>(
Name, Callbacks);
1286template <
typename CallbacksT>
1289 StringRef NameNoBracket =
Name.take_until([](
char C) {
return C ==
'<'; });
1290 if (NameNoBracket ==
"function")
1292 if (
Name ==
"loop" ||
Name ==
"loop-mssa" ||
Name ==
"machine-function")
1295#define FUNCTION_PASS(NAME, CREATE_PASS) \
1298#define FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1299 if (PassBuilder::checkParametrizedPassName(Name, NAME)) \
1301#define FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
1302 if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
1304#include "PassRegistry.def"
1306 return callbacksAcceptPassName<FunctionPassManager>(
Name, Callbacks);
1309template <
typename CallbacksT>
1312 if (
Name ==
"machine-function")
1315#define MACHINE_FUNCTION_PASS(NAME, CREATE_PASS) \
1318#define MACHINE_FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, \
1320 if (PassBuilder::checkParametrizedPassName(Name, NAME)) \
1323#define MACHINE_FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
1324 if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
1327#include "llvm/Passes/MachinePassRegistry.def"
1329 return callbacksAcceptPassName<MachineFunctionPassManager>(
Name, Callbacks);
1332template <
typename CallbacksT>
1334 bool &UseMemorySSA) {
1335 UseMemorySSA =
false;
1338 UseMemorySSA =
true;
1342#define LOOPNEST_PASS(NAME, CREATE_PASS) \
1345#include "PassRegistry.def"
1347 return callbacksAcceptPassName<LoopPassManager>(
Name, Callbacks);
1350template <
typename CallbacksT>
1352 bool &UseMemorySSA) {
1353 UseMemorySSA =
false;
1356 UseMemorySSA =
true;
1360#define LOOP_PASS(NAME, CREATE_PASS) \
1363#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1364 if (PassBuilder::checkParametrizedPassName(Name, NAME)) \
1366#define LOOP_ANALYSIS(NAME, CREATE_PASS) \
1367 if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
1369#include "PassRegistry.def"
1371 return callbacksAcceptPassName<LoopPassManager>(
Name, Callbacks);
1374std::optional<std::vector<PassBuilder::PipelineElement>>
1375PassBuilder::parsePipelineText(
StringRef Text) {
1376 std::vector<PipelineElement> ResultPipeline;
1381 std::vector<PipelineElement> &Pipeline = *PipelineStack.
back();
1382 size_t Pos =
Text.find_first_of(
",()");
1383 Pipeline.push_back({
Text.substr(0, Pos), {}});
1386 if (Pos ==
Text.npos)
1389 char Sep =
Text[Pos];
1397 PipelineStack.
push_back(&Pipeline.back().InnerPipeline);
1401 assert(Sep ==
')' &&
"Bogus separator!");
1406 if (PipelineStack.
size() == 1)
1407 return std::nullopt;
1410 }
while (
Text.consume_front(
")"));
1418 if (!
Text.consume_front(
","))
1419 return std::nullopt;
1422 if (PipelineStack.
size() > 1)
1424 return std::nullopt;
1426 assert(PipelineStack.
back() == &ResultPipeline &&
1427 "Wrong pipeline at the bottom of the stack!");
1428 return {std::move(ResultPipeline)};
1432 const PipelineElement &E) {
1433 auto &
Name = E.Name;
1434 auto &InnerPipeline = E.InnerPipeline;
1437 if (!InnerPipeline.empty()) {
1438 if (
Name ==
"module") {
1440 if (
auto Err = parseModulePassPipeline(NestedMPM, InnerPipeline))
1445 if (
Name ==
"coro-cond") {
1447 if (
auto Err = parseModulePassPipeline(NestedMPM, InnerPipeline))
1452 if (
Name ==
"cgscc") {
1454 if (
auto Err = parseCGSCCPassPipeline(CGPM, InnerPipeline))
1461 return make_error<StringError>(
1462 "cannot have a no-rerun module to function adaptor",
1465 if (
auto Err = parseFunctionPassPipeline(FPM, InnerPipeline))
1472 for (
auto &
C : ModulePipelineParsingCallbacks)
1477 return make_error<StringError>(
1478 formatv(
"invalid use of '{0}' pass as module pipeline",
Name).str(),
1487 return make_error<StringError>(
1488 formatv(
"unknown default pipeline alias '{0}'",
Name).str(),
1491 assert(Matches.
size() == 3 &&
"Must capture two matched strings!");
1503 if (Matches[1] ==
"default") {
1505 }
else if (Matches[1] ==
"thinlto-pre-link") {
1507 }
else if (Matches[1] ==
"thinlto") {
1509 }
else if (Matches[1] ==
"lto-pre-link") {
1518 assert(Matches[1] ==
"lto" &&
"Not one of the matched options!");
1525#define MODULE_PASS(NAME, CREATE_PASS) \
1526 if (Name == NAME) { \
1527 MPM.addPass(CREATE_PASS); \
1528 return Error::success(); \
1530#define MODULE_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1531 if (checkParametrizedPassName(Name, NAME)) { \
1532 auto Params = parsePassParameters(PARSER, Name, NAME); \
1534 return Params.takeError(); \
1535 MPM.addPass(CREATE_PASS(Params.get())); \
1536 return Error::success(); \
1538#define MODULE_ANALYSIS(NAME, CREATE_PASS) \
1539 if (Name == "require<" NAME ">") { \
1541 RequireAnalysisPass< \
1542 std::remove_reference_t<decltype(CREATE_PASS)>, Module>()); \
1543 return Error::success(); \
1545 if (Name == "invalidate<" NAME ">") { \
1546 MPM.addPass(InvalidateAnalysisPass< \
1547 std::remove_reference_t<decltype(CREATE_PASS)>>()); \
1548 return Error::success(); \
1550#define CGSCC_PASS(NAME, CREATE_PASS) \
1551 if (Name == NAME) { \
1552 MPM.addPass(createModuleToPostOrderCGSCCPassAdaptor(CREATE_PASS)); \
1553 return Error::success(); \
1555#define CGSCC_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1556 if (checkParametrizedPassName(Name, NAME)) { \
1557 auto Params = parsePassParameters(PARSER, Name, NAME); \
1559 return Params.takeError(); \
1561 createModuleToPostOrderCGSCCPassAdaptor(CREATE_PASS(Params.get()))); \
1562 return Error::success(); \
1564#define FUNCTION_PASS(NAME, CREATE_PASS) \
1565 if (Name == NAME) { \
1566 MPM.addPass(createModuleToFunctionPassAdaptor(CREATE_PASS)); \
1567 return Error::success(); \
1569#define FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1570 if (checkParametrizedPassName(Name, NAME)) { \
1571 auto Params = parsePassParameters(PARSER, Name, NAME); \
1573 return Params.takeError(); \
1574 MPM.addPass(createModuleToFunctionPassAdaptor(CREATE_PASS(Params.get()))); \
1575 return Error::success(); \
1577#define LOOPNEST_PASS(NAME, CREATE_PASS) \
1578 if (Name == NAME) { \
1579 MPM.addPass(createModuleToFunctionPassAdaptor( \
1580 createFunctionToLoopPassAdaptor(CREATE_PASS, false, false))); \
1581 return Error::success(); \
1583#define LOOP_PASS(NAME, CREATE_PASS) \
1584 if (Name == NAME) { \
1585 MPM.addPass(createModuleToFunctionPassAdaptor( \
1586 createFunctionToLoopPassAdaptor(CREATE_PASS, false, false))); \
1587 return Error::success(); \
1589#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1590 if (checkParametrizedPassName(Name, NAME)) { \
1591 auto Params = parsePassParameters(PARSER, Name, NAME); \
1593 return Params.takeError(); \
1595 createModuleToFunctionPassAdaptor(createFunctionToLoopPassAdaptor( \
1596 CREATE_PASS(Params.get()), false, false))); \
1597 return Error::success(); \
1599#include "PassRegistry.def"
1601 for (
auto &
C : ModulePipelineParsingCallbacks)
1604 return make_error<StringError>(
1610 const PipelineElement &E) {
1611 auto &
Name = E.Name;
1612 auto &InnerPipeline = E.InnerPipeline;
1615 if (!InnerPipeline.empty()) {
1616 if (
Name ==
"cgscc") {
1618 if (
auto Err = parseCGSCCPassPipeline(NestedCGPM, InnerPipeline))
1621 CGPM.
addPass(std::move(NestedCGPM));
1626 if (
auto Err = parseFunctionPassPipeline(FPM, InnerPipeline))
1630 std::move(FPM), Params->first, Params->second));
1635 if (
auto Err = parseCGSCCPassPipeline(NestedCGPM, InnerPipeline))
1642 for (
auto &
C : CGSCCPipelineParsingCallbacks)
1643 if (
C(
Name, CGPM, InnerPipeline))
1647 return make_error<StringError>(
1648 formatv(
"invalid use of '{0}' pass as cgscc pipeline",
Name).str(),
1653#define CGSCC_PASS(NAME, CREATE_PASS) \
1654 if (Name == NAME) { \
1655 CGPM.addPass(CREATE_PASS); \
1656 return Error::success(); \
1658#define CGSCC_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1659 if (checkParametrizedPassName(Name, NAME)) { \
1660 auto Params = parsePassParameters(PARSER, Name, NAME); \
1662 return Params.takeError(); \
1663 CGPM.addPass(CREATE_PASS(Params.get())); \
1664 return Error::success(); \
1666#define CGSCC_ANALYSIS(NAME, CREATE_PASS) \
1667 if (Name == "require<" NAME ">") { \
1668 CGPM.addPass(RequireAnalysisPass< \
1669 std::remove_reference_t<decltype(CREATE_PASS)>, \
1670 LazyCallGraph::SCC, CGSCCAnalysisManager, LazyCallGraph &, \
1671 CGSCCUpdateResult &>()); \
1672 return Error::success(); \
1674 if (Name == "invalidate<" NAME ">") { \
1675 CGPM.addPass(InvalidateAnalysisPass< \
1676 std::remove_reference_t<decltype(CREATE_PASS)>>()); \
1677 return Error::success(); \
1679#define FUNCTION_PASS(NAME, CREATE_PASS) \
1680 if (Name == NAME) { \
1681 CGPM.addPass(createCGSCCToFunctionPassAdaptor(CREATE_PASS)); \
1682 return Error::success(); \
1684#define FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1685 if (checkParametrizedPassName(Name, NAME)) { \
1686 auto Params = parsePassParameters(PARSER, Name, NAME); \
1688 return Params.takeError(); \
1689 CGPM.addPass(createCGSCCToFunctionPassAdaptor(CREATE_PASS(Params.get()))); \
1690 return Error::success(); \
1692#define LOOPNEST_PASS(NAME, CREATE_PASS) \
1693 if (Name == NAME) { \
1694 CGPM.addPass(createCGSCCToFunctionPassAdaptor( \
1695 createFunctionToLoopPassAdaptor(CREATE_PASS, false, false))); \
1696 return Error::success(); \
1698#define LOOP_PASS(NAME, CREATE_PASS) \
1699 if (Name == NAME) { \
1700 CGPM.addPass(createCGSCCToFunctionPassAdaptor( \
1701 createFunctionToLoopPassAdaptor(CREATE_PASS, false, false))); \
1702 return Error::success(); \
1704#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1705 if (checkParametrizedPassName(Name, NAME)) { \
1706 auto Params = parsePassParameters(PARSER, Name, NAME); \
1708 return Params.takeError(); \
1710 createCGSCCToFunctionPassAdaptor(createFunctionToLoopPassAdaptor( \
1711 CREATE_PASS(Params.get()), false, false))); \
1712 return Error::success(); \
1714#include "PassRegistry.def"
1716 for (
auto &
C : CGSCCPipelineParsingCallbacks)
1717 if (
C(
Name, CGPM, InnerPipeline))
1719 return make_error<StringError>(
1725 const PipelineElement &E) {
1726 auto &
Name = E.Name;
1727 auto &InnerPipeline = E.InnerPipeline;
1730 if (!InnerPipeline.empty()) {
1731 if (
Name ==
"function") {
1733 if (
auto Err = parseFunctionPassPipeline(NestedFPM, InnerPipeline))
1736 FPM.
addPass(std::move(NestedFPM));
1739 if (
Name ==
"loop" ||
Name ==
"loop-mssa") {
1741 if (
auto Err = parseLoopPassPipeline(LPM, InnerPipeline))
1744 bool UseMemorySSA = (
Name ==
"loop-mssa");
1746 return Pipeline.Name.contains(
"simple-loop-unswitch");
1748 bool UseBPI =
llvm::any_of(InnerPipeline, [](
auto Pipeline) {
1749 return Pipeline.Name ==
"loop-predication";
1755 if (
Name ==
"machine-function") {
1757 if (
auto Err = parseMachinePassPipeline(MFPM, InnerPipeline))
1763 for (
auto &
C : FunctionPipelineParsingCallbacks)
1764 if (
C(
Name, FPM, InnerPipeline))
1768 return make_error<StringError>(
1769 formatv(
"invalid use of '{0}' pass as function pipeline",
Name).str(),
1774#define FUNCTION_PASS(NAME, CREATE_PASS) \
1775 if (Name == NAME) { \
1776 FPM.addPass(CREATE_PASS); \
1777 return Error::success(); \
1779#define FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1780 if (checkParametrizedPassName(Name, NAME)) { \
1781 auto Params = parsePassParameters(PARSER, Name, NAME); \
1783 return Params.takeError(); \
1784 FPM.addPass(CREATE_PASS(Params.get())); \
1785 return Error::success(); \
1787#define FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
1788 if (Name == "require<" NAME ">") { \
1790 RequireAnalysisPass< \
1791 std::remove_reference_t<decltype(CREATE_PASS)>, Function>()); \
1792 return Error::success(); \
1794 if (Name == "invalidate<" NAME ">") { \
1795 FPM.addPass(InvalidateAnalysisPass< \
1796 std::remove_reference_t<decltype(CREATE_PASS)>>()); \
1797 return Error::success(); \
1803#define LOOPNEST_PASS(NAME, CREATE_PASS) \
1804 if (Name == NAME) { \
1805 FPM.addPass(createFunctionToLoopPassAdaptor(CREATE_PASS, false, false)); \
1806 return Error::success(); \
1808#define LOOP_PASS(NAME, CREATE_PASS) \
1809 if (Name == NAME) { \
1810 FPM.addPass(createFunctionToLoopPassAdaptor(CREATE_PASS, false, false)); \
1811 return Error::success(); \
1813#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1814 if (checkParametrizedPassName(Name, NAME)) { \
1815 auto Params = parsePassParameters(PARSER, Name, NAME); \
1817 return Params.takeError(); \
1818 FPM.addPass(createFunctionToLoopPassAdaptor(CREATE_PASS(Params.get()), \
1820 return Error::success(); \
1822#include "PassRegistry.def"
1824 for (
auto &
C : FunctionPipelineParsingCallbacks)
1825 if (
C(
Name, FPM, InnerPipeline))
1827 return make_error<StringError>(
1828 formatv(
"unknown function pass '{0}'",
Name).str(),
1833 const PipelineElement &E) {
1835 auto &InnerPipeline = E.InnerPipeline;
1838 if (!InnerPipeline.empty()) {
1839 if (
Name ==
"loop") {
1841 if (
auto Err = parseLoopPassPipeline(NestedLPM, InnerPipeline))
1844 LPM.
addPass(std::move(NestedLPM));
1848 for (
auto &
C : LoopPipelineParsingCallbacks)
1849 if (
C(
Name, LPM, InnerPipeline))
1853 return make_error<StringError>(
1854 formatv(
"invalid use of '{0}' pass as loop pipeline",
Name).str(),
1859#define LOOPNEST_PASS(NAME, CREATE_PASS) \
1860 if (Name == NAME) { \
1861 LPM.addPass(CREATE_PASS); \
1862 return Error::success(); \
1864#define LOOP_PASS(NAME, CREATE_PASS) \
1865 if (Name == NAME) { \
1866 LPM.addPass(CREATE_PASS); \
1867 return Error::success(); \
1869#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1870 if (checkParametrizedPassName(Name, NAME)) { \
1871 auto Params = parsePassParameters(PARSER, Name, NAME); \
1873 return Params.takeError(); \
1874 LPM.addPass(CREATE_PASS(Params.get())); \
1875 return Error::success(); \
1877#define LOOP_ANALYSIS(NAME, CREATE_PASS) \
1878 if (Name == "require<" NAME ">") { \
1879 LPM.addPass(RequireAnalysisPass< \
1880 std::remove_reference_t<decltype(CREATE_PASS)>, Loop, \
1881 LoopAnalysisManager, LoopStandardAnalysisResults &, \
1883 return Error::success(); \
1885 if (Name == "invalidate<" NAME ">") { \
1886 LPM.addPass(InvalidateAnalysisPass< \
1887 std::remove_reference_t<decltype(CREATE_PASS)>>()); \
1888 return Error::success(); \
1890#include "PassRegistry.def"
1892 for (
auto &
C : LoopPipelineParsingCallbacks)
1893 if (
C(
Name, LPM, InnerPipeline))
1895 return make_error<StringError>(
formatv(
"unknown loop pass '{0}'",
Name).str(),
1900 const PipelineElement &E) {
1902 if (!E.InnerPipeline.empty())
1903 return make_error<StringError>(
"invalid pipeline",
1906#define MACHINE_MODULE_PASS(NAME, CREATE_PASS) \
1907 if (Name == NAME) { \
1908 MFPM.addPass(CREATE_PASS); \
1909 return Error::success(); \
1911#define MACHINE_FUNCTION_PASS(NAME, CREATE_PASS) \
1912 if (Name == NAME) { \
1913 MFPM.addPass(CREATE_PASS); \
1914 return Error::success(); \
1916#define MACHINE_FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, \
1918 if (checkParametrizedPassName(Name, NAME)) { \
1919 auto Params = parsePassParameters(PARSER, Name, NAME); \
1921 return Params.takeError(); \
1922 MFPM.addPass(CREATE_PASS(Params.get())); \
1923 return Error::success(); \
1925#define MACHINE_FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
1926 if (Name == "require<" NAME ">") { \
1928 RequireAnalysisPass<std::remove_reference_t<decltype(CREATE_PASS)>, \
1929 MachineFunction>()); \
1930 return Error::success(); \
1932 if (Name == "invalidate<" NAME ">") { \
1933 MFPM.addPass(InvalidateAnalysisPass< \
1934 std::remove_reference_t<decltype(CREATE_PASS)>>()); \
1935 return Error::success(); \
1937#include "llvm/Passes/MachinePassRegistry.def"
1939 for (
auto &
C : MachineFunctionPipelineParsingCallbacks)
1940 if (
C(
Name, MFPM, E.InnerPipeline))
1942 return make_error<StringError>(
1943 formatv(
"unknown machine pass '{0}'",
Name).str(),
1948#define MODULE_ALIAS_ANALYSIS(NAME, CREATE_PASS) \
1949 if (Name == NAME) { \
1950 AA.registerModuleAnalysis< \
1951 std::remove_reference_t<decltype(CREATE_PASS)>>(); \
1954#define FUNCTION_ALIAS_ANALYSIS(NAME, CREATE_PASS) \
1955 if (Name == NAME) { \
1956 AA.registerFunctionAnalysis< \
1957 std::remove_reference_t<decltype(CREATE_PASS)>>(); \
1960#include "PassRegistry.def"
1962 for (
auto &
C : AAParsingCallbacks)
1968Error PassBuilder::parseMachinePassPipeline(
1970 for (
const auto &Element : Pipeline) {
1971 if (
auto Err = parseMachinePass(MFPM, Element))
1979 for (
const auto &Element : Pipeline) {
1980 if (
auto Err = parseLoopPass(LPM, Element))
1986Error PassBuilder::parseFunctionPassPipeline(
1988 for (
const auto &Element : Pipeline) {
1989 if (
auto Err = parseFunctionPass(FPM, Element))
1997 for (
const auto &Element : Pipeline) {
1998 if (
auto Err = parseCGSCCPass(CGPM, Element))
2030 for (
const auto &Element : Pipeline) {
2031 if (
auto Err = parseModulePass(
MPM, Element))
2042 auto Pipeline = parsePipelineText(PipelineText);
2043 if (!Pipeline || Pipeline->empty())
2044 return make_error<StringError>(
2045 formatv(
"invalid pipeline '{0}'", PipelineText).str(),
2055 Pipeline = {{
"cgscc", std::move(*Pipeline)}};
2057 FunctionPipelineParsingCallbacks)) {
2058 Pipeline = {{
"function", std::move(*Pipeline)}};
2061 Pipeline = {{
"function", {{UseMemorySSA ?
"loop-mssa" :
"loop",
2062 std::move(*Pipeline)}}}};
2063 }
else if (
isLoopPassName(FirstName, LoopPipelineParsingCallbacks,
2065 Pipeline = {{
"function", {{UseMemorySSA ?
"loop-mssa" :
"loop",
2066 std::move(*Pipeline)}}}};
2068 FirstName, MachineFunctionPipelineParsingCallbacks)) {
2069 Pipeline = {{
"function", {{
"machine-function", std::move(*Pipeline)}}}};
2071 for (
auto &
C : TopLevelPipelineParsingCallbacks)
2072 if (
C(
MPM, *Pipeline))
2076 auto &InnerPipeline = Pipeline->front().InnerPipeline;
2077 return make_error<StringError>(
2078 formatv(
"unknown {0} name '{1}'",
2079 (InnerPipeline.empty() ?
"pass" :
"pipeline"), FirstName)
2085 if (
auto Err = parseModulePassPipeline(
MPM, *Pipeline))
2093 auto Pipeline = parsePipelineText(PipelineText);
2094 if (!Pipeline || Pipeline->empty())
2095 return make_error<StringError>(
2096 formatv(
"invalid pipeline '{0}'", PipelineText).str(),
2101 return make_error<StringError>(
2102 formatv(
"unknown cgscc pass '{0}' in pipeline '{1}'", FirstName,
2107 if (
auto Err = parseCGSCCPassPipeline(CGPM, *Pipeline))
2116 auto Pipeline = parsePipelineText(PipelineText);
2117 if (!Pipeline || Pipeline->empty())
2118 return make_error<StringError>(
2119 formatv(
"invalid pipeline '{0}'", PipelineText).str(),
2124 return make_error<StringError>(
2125 formatv(
"unknown function pass '{0}' in pipeline '{1}'", FirstName,
2130 if (
auto Err = parseFunctionPassPipeline(FPM, *Pipeline))
2138 auto Pipeline = parsePipelineText(PipelineText);
2139 if (!Pipeline || Pipeline->empty())
2140 return make_error<StringError>(
2141 formatv(
"invalid pipeline '{0}'", PipelineText).str(),
2144 if (
auto Err = parseLoopPassPipeline(CGPM, *Pipeline))
2152 auto Pipeline = parsePipelineText(PipelineText);
2153 if (!Pipeline || Pipeline->empty())
2154 return make_error<StringError>(
2155 formatv(
"invalid machine pass pipeline '{0}'", PipelineText).str(),
2158 if (
auto Err = parseMachinePassPipeline(MFPM, *Pipeline))
2167 if (PipelineText ==
"default") {
2172 while (!PipelineText.
empty()) {
2174 std::tie(
Name, PipelineText) = PipelineText.
split(
',');
2175 if (!parseAAPassName(AA,
Name))
2176 return make_error<StringError>(
2177 formatv(
"unknown alias analysis name '{0}'",
Name).str(),
2184std::optional<RegClassFilterFunc>
2186 if (FilterName ==
"all")
2188 for (
auto &
C : RegClassFilterParsingCallbacks)
2189 if (
auto F =
C(FilterName))
2191 return std::nullopt;
2199 OS <<
" " <<
PassName <<
"<" << Params <<
">\n";
2205 OS <<
"Module passes:\n";
2206#define MODULE_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2207#include "PassRegistry.def"
2209 OS <<
"Module passes with params:\n";
2210#define MODULE_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
2211 printPassName(NAME, PARAMS, OS);
2212#include "PassRegistry.def"
2214 OS <<
"Module analyses:\n";
2215#define MODULE_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2216#include "PassRegistry.def"
2218 OS <<
"Module alias analyses:\n";
2219#define MODULE_ALIAS_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2220#include "PassRegistry.def"
2222 OS <<
"CGSCC passes:\n";
2223#define CGSCC_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2224#include "PassRegistry.def"
2226 OS <<
"CGSCC passes with params:\n";
2227#define CGSCC_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
2228 printPassName(NAME, PARAMS, OS);
2229#include "PassRegistry.def"
2231 OS <<
"CGSCC analyses:\n";
2232#define CGSCC_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2233#include "PassRegistry.def"
2235 OS <<
"Function passes:\n";
2236#define FUNCTION_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2237#include "PassRegistry.def"
2239 OS <<
"Function passes with params:\n";
2240#define FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
2241 printPassName(NAME, PARAMS, OS);
2242#include "PassRegistry.def"
2244 OS <<
"Function analyses:\n";
2245#define FUNCTION_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2246#include "PassRegistry.def"
2248 OS <<
"Function alias analyses:\n";
2249#define FUNCTION_ALIAS_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2250#include "PassRegistry.def"
2252 OS <<
"LoopNest passes:\n";
2253#define LOOPNEST_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2254#include "PassRegistry.def"
2256 OS <<
"Loop passes:\n";
2257#define LOOP_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2258#include "PassRegistry.def"
2260 OS <<
"Loop passes with params:\n";
2261#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
2262 printPassName(NAME, PARAMS, OS);
2263#include "PassRegistry.def"
2265 OS <<
"Loop analyses:\n";
2266#define LOOP_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2267#include "PassRegistry.def"
2269 OS <<
"Machine module passes (WIP):\n";
2270#define MACHINE_MODULE_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2271#include "llvm/Passes/MachinePassRegistry.def"
2273 OS <<
"Machine function passes (WIP):\n";
2274#define MACHINE_FUNCTION_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2275#include "llvm/Passes/MachinePassRegistry.def"
2277 OS <<
"Machine function analyses (WIP):\n";
2278#define MACHINE_FUNCTION_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2279#include "llvm/Passes/MachinePassRegistry.def"
2285 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