305 "^(default|thinlto-pre-link|thinlto|lto-pre-link|lto)<(O[0123sz])>$");
309 "print-pipeline-passes",
310 cl::desc(
"Print a '-passes' compatible string describing the pipeline "
311 "(best-effort only)."));
327bool shouldPopulateClassToPassNames() {
335class TriggerCrashPass :
public PassInfoMixin<TriggerCrashPass> {
346class TriggerVerifierErrorPass
354 GlobalValue::LinkageTypes::InternalLinkage,
355 "__bad_alias",
nullptr, &M);
375 static StringRef name() {
return "TriggerVerifierErrorPass"; }
380class RequireAllMachineFunctionPropertiesPass
381 :
public PassInfoMixin<RequireAllMachineFunctionPropertiesPass> {
389 MFProps.
set(MachineFunctionProperties::Property::FailedISel);
390 MFProps.
set(MachineFunctionProperties::Property::FailsVerification);
391 MFProps.
set(MachineFunctionProperties::Property::IsSSA);
392 MFProps.
set(MachineFunctionProperties::Property::Legalized);
393 MFProps.
set(MachineFunctionProperties::Property::NoPHIs);
394 MFProps.
set(MachineFunctionProperties::Property::NoVRegs);
395 MFProps.
set(MachineFunctionProperties::Property::RegBankSelected);
396 MFProps.
set(MachineFunctionProperties::Property::Selected);
397 MFProps.
set(MachineFunctionProperties::Property::TiedOpsRewritten);
398 MFProps.
set(MachineFunctionProperties::Property::TracksDebugUserValues);
399 MFProps.
set(MachineFunctionProperties::Property::TracksLiveness);
402 static StringRef name() {
return "RequireAllMachineFunctionPropertiesPass"; }
408 std::optional<PGOOptions> PGOOpt,
410 :
TM(
TM), PTO(PTO), PGOOpt(PGOOpt),
PIC(
PIC) {
411 bool ShouldPopulateClassToPassNames =
PIC && shouldPopulateClassToPassNames();
413 TM->registerPassBuilderCallbacks(*
this, ShouldPopulateClassToPassNames);
414 if (ShouldPopulateClassToPassNames) {
415#define MODULE_PASS(NAME, CREATE_PASS) \
416 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
417#define MODULE_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
418 PIC->addClassToPassName(CLASS, NAME);
419#define MODULE_ANALYSIS(NAME, CREATE_PASS) \
420 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
421#define FUNCTION_PASS(NAME, CREATE_PASS) \
422 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
423#define FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
424 PIC->addClassToPassName(CLASS, NAME);
425#define FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
426 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
427#define LOOPNEST_PASS(NAME, CREATE_PASS) \
428 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
429#define LOOP_PASS(NAME, CREATE_PASS) \
430 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
431#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
432 PIC->addClassToPassName(CLASS, NAME);
433#define LOOP_ANALYSIS(NAME, CREATE_PASS) \
434 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
435#define CGSCC_PASS(NAME, CREATE_PASS) \
436 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
437#define CGSCC_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
438 PIC->addClassToPassName(CLASS, NAME);
439#define CGSCC_ANALYSIS(NAME, CREATE_PASS) \
440 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
441#include "PassRegistry.def"
443#define MACHINE_FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
444 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
445#define MACHINE_FUNCTION_PASS(NAME, CREATE_PASS) \
446 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
447#include "llvm/Passes/MachinePassRegistry.def"
452#define MODULE_ANALYSIS(NAME, CREATE_PASS) \
453 MAM.registerPass([&] { return CREATE_PASS; });
454#include "PassRegistry.def"
456 for (
auto &
C : ModuleAnalysisRegistrationCallbacks)
461#define CGSCC_ANALYSIS(NAME, CREATE_PASS) \
462 CGAM.registerPass([&] { return CREATE_PASS; });
463#include "PassRegistry.def"
465 for (
auto &
C : CGSCCAnalysisRegistrationCallbacks)
475#define FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
476 FAM.registerPass([&] { return CREATE_PASS; });
477#include "PassRegistry.def"
479 for (
auto &
C : FunctionAnalysisRegistrationCallbacks)
486#define MACHINE_FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
487 MFAM.registerPass([&] { return CREATE_PASS; });
488#include "llvm/Passes/MachinePassRegistry.def"
490 for (
auto &
C : MachineFunctionAnalysisRegistrationCallbacks)
495#define LOOP_ANALYSIS(NAME, CREATE_PASS) \
496 LAM.registerPass([&] { return CREATE_PASS; });
497#include "PassRegistry.def"
499 for (
auto &
C : LoopAnalysisRegistrationCallbacks)
504 if (!
Name.consume_front(
"repeat<") || !
Name.consume_back(
">"))
507 if (
Name.getAsInteger(0, Count) || Count <= 0)
512static std::optional<std::pair<bool, bool>>
514 std::pair<bool, bool> Params;
515 if (!
Name.consume_front(
"function"))
519 if (!
Name.consume_front(
"<") || !
Name.consume_back(
">"))
521 while (!
Name.empty()) {
522 auto [Front, Back] =
Name.split(
';');
524 if (Front ==
"eager-inv")
526 else if (Front ==
"no-rerun")
527 Params.second =
true;
535 if (!
Name.consume_front(
"devirt<") || !
Name.consume_back(
">"))
538 if (
Name.getAsInteger(0, Count) || Count < 0)
558 while (!Params.
empty()) {
560 std::tie(ParamName, Params) = Params.
split(
';');
562 if (ParamName == OptionName) {
565 return make_error<StringError>(
580 while (!Params.
empty()) {
582 std::tie(ParamName, Params) = Params.
split(
';');
586 return make_error<StringError>(
587 formatv(
"invalid HardwareLoopPass parameter '{0}' ", ParamName).str(),
592 if (ParamName.
consume_front(
"hardware-loop-counter-bitwidth=")) {
595 return make_error<StringError>(
596 formatv(
"invalid HardwareLoopPass parameter '{0}' ", ParamName).str(),
601 if (ParamName ==
"force-hardware-loops") {
603 }
else if (ParamName ==
"force-hardware-loop-phi") {
605 }
else if (ParamName ==
"force-nested-hardware-loop") {
607 }
else if (ParamName ==
"force-hardware-loop-guard") {
610 return make_error<StringError>(
611 formatv(
"invalid HardwarePass parameter '{0}' ", ParamName).str(),
615 return HardwareLoopOpts;
621 while (!Params.
empty()) {
623 std::tie(ParamName, Params) = Params.
split(
';');
624 std::optional<OptimizationLevel> OptLevel =
parseOptLevel(ParamName);
626 if (OptLevel && !OptLevel->isOptimizingForSize()) {
627 UnrollOpts.
setOptLevel(OptLevel->getSpeedupLevel());
633 return make_error<StringError>(
634 formatv(
"invalid LoopUnrollPass parameter '{0}' ", ParamName).str(),
641 if (ParamName ==
"partial") {
643 }
else if (ParamName ==
"peeling") {
645 }
else if (ParamName ==
"profile-peeling") {
647 }
else if (ParamName ==
"runtime") {
649 }
else if (ParamName ==
"upperbound") {
652 return make_error<StringError>(
653 formatv(
"invalid LoopUnrollPass parameter '{0}' ", ParamName).str(),
662 Params,
"vfe-linkage-unit-visibility",
"GlobalDCE");
682 Params,
"skip-non-recursive-function-attrs",
"PostOrderFunctionAttrs");
691 return make_error<StringError>(
692 formatv(
"too many CFGuardPass parameters '{0}' ", Params).str(),
695 if (Param ==
"check")
697 if (Param ==
"dispatch")
700 return make_error<StringError>(
701 formatv(
"invalid CFGuardPass mechanism: '{0}' ", Param).str(),
711 "EntryExitInstrumenter");
720 "LowerMatrixIntrinsics");
725 while (!Params.
empty()) {
727 std::tie(ParamName, Params) = Params.
split(
';');
729 if (ParamName ==
"kernel") {
730 Result.CompileKernel =
true;
732 return make_error<StringError>(
733 formatv(
"invalid AddressSanitizer pass parameter '{0}' ", ParamName)
743 while (!Params.
empty()) {
745 std::tie(ParamName, Params) = Params.
split(
';');
747 if (ParamName ==
"recover") {
749 }
else if (ParamName ==
"kernel") {
750 Result.CompileKernel =
true;
752 return make_error<StringError>(
753 formatv(
"invalid HWAddressSanitizer pass parameter '{0}' ", ParamName)
763 while (!Params.
empty()) {
765 std::tie(ParamName, Params) = Params.
split(
';');
767 if (ParamName ==
"thinlto") {
769 }
else if (ParamName ==
"emit-summary") {
770 Result.EmitLTOSummary =
true;
772 return make_error<StringError>(
773 formatv(
"invalid EmbedBitcode pass parameter '{0}' ", ParamName)
783 while (!Params.
empty()) {
785 std::tie(ParamName, Params) = Params.
split(
';');
787 if (ParamName ==
"recover") {
789 }
else if (ParamName ==
"kernel") {
793 return make_error<StringError>(
794 formatv(
"invalid argument to MemorySanitizer pass track-origins "
799 }
else if (ParamName ==
"eager-checks") {
800 Result.EagerChecks =
true;
802 return make_error<StringError>(
803 formatv(
"invalid MemorySanitizer pass parameter '{0}' ", ParamName)
814 while (!Params.
empty()) {
816 std::tie(ParamName, Params) = Params.
split(
';');
819 if (ParamName ==
"speculate-blocks") {
821 }
else if (ParamName ==
"simplify-cond-branch") {
823 }
else if (ParamName ==
"forward-switch-cond") {
825 }
else if (ParamName ==
"switch-range-to-icmp") {
827 }
else if (ParamName ==
"switch-to-lookup") {
829 }
else if (ParamName ==
"keep-loops") {
831 }
else if (ParamName ==
"hoist-common-insts") {
833 }
else if (ParamName ==
"sink-common-insts") {
836 APInt BonusInstThreshold;
838 return make_error<StringError>(
839 formatv(
"invalid argument to SimplifyCFG pass bonus-threshold "
845 return make_error<StringError>(
846 formatv(
"invalid SimplifyCFG pass parameter '{0}' ", ParamName).str(),
857 Result.setVerifyFixpoint(
true);
858 while (!Params.
empty()) {
860 std::tie(ParamName, Params) = Params.
split(
';');
863 if (ParamName ==
"use-loop-info") {
865 }
else if (ParamName ==
"verify-fixpoint") {
870 return make_error<StringError>(
871 formatv(
"invalid argument to InstCombine pass max-iterations "
877 return make_error<StringError>(
878 formatv(
"invalid InstCombine pass parameter '{0}' ", ParamName).str(),
888 while (!Params.
empty()) {
890 std::tie(ParamName, Params) = Params.
split(
';');
893 if (ParamName ==
"interleave-forced-only") {
895 }
else if (ParamName ==
"vectorize-forced-only") {
898 return make_error<StringError>(
899 formatv(
"invalid LoopVectorize parameter '{0}' ", ParamName).str(),
907 std::pair<bool, bool>
Result = {
false,
true};
908 while (!Params.
empty()) {
910 std::tie(ParamName, Params) = Params.
split(
';');
913 if (ParamName ==
"nontrivial") {
915 }
else if (ParamName ==
"trivial") {
918 return make_error<StringError>(
919 formatv(
"invalid LoopUnswitch pass parameter '{0}' ", ParamName)
929 while (!Params.
empty()) {
931 std::tie(ParamName, Params) = Params.
split(
';');
934 if (ParamName ==
"allowspeculation") {
937 return make_error<StringError>(
938 formatv(
"invalid LICM pass parameter '{0}' ", ParamName).str(),
946 std::pair<bool, bool>
Result = {
true,
false};
947 while (!Params.
empty()) {
949 std::tie(ParamName, Params) = Params.
split(
';');
952 if (ParamName ==
"header-duplication") {
954 }
else if (ParamName ==
"prepare-for-lto") {
957 return make_error<StringError>(
958 formatv(
"invalid LoopRotate pass parameter '{0}' ", ParamName).str(),
967 while (!Params.
empty()) {
969 std::tie(ParamName, Params) = Params.
split(
';');
972 if (ParamName ==
"split-footer-bb") {
975 return make_error<StringError>(
976 formatv(
"invalid MergedLoadStoreMotion pass parameter '{0}' ",
987 while (!Params.
empty()) {
989 std::tie(ParamName, Params) = Params.
split(
';');
992 if (ParamName ==
"pre") {
994 }
else if (ParamName ==
"load-pre") {
996 }
else if (ParamName ==
"split-backedge-load-pre") {
998 }
else if (ParamName ==
"memdep") {
1001 return make_error<StringError>(
1002 formatv(
"invalid GVN pass parameter '{0}' ", ParamName).str(),
1011 while (!Params.
empty()) {
1013 std::tie(ParamName, Params) = Params.
split(
';');
1016 if (ParamName ==
"func-spec")
1019 return make_error<StringError>(
1020 formatv(
"invalid IPSCCP pass parameter '{0}' ", ParamName).str(),
1027 if (Params.
empty() || Params ==
"modify-cfg")
1029 if (Params ==
"preserve-cfg")
1031 return make_error<StringError>(
1032 formatv(
"invalid SROA pass parameter '{0}' (either preserve-cfg or "
1033 "modify-cfg can be specified)",
1040parseStackLifetimeOptions(
StringRef Params) {
1042 while (!Params.
empty()) {
1044 std::tie(ParamName, Params) = Params.
split(
';');
1046 if (ParamName ==
"may") {
1048 }
else if (ParamName ==
"must") {
1051 return make_error<StringError>(
1052 formatv(
"invalid StackLifetime parameter '{0}' ", ParamName).str(),
1061 "DependenceAnalysisPrinter");
1066 "SeparateConstOffsetFromGEP");
1070parseFunctionSimplificationPipelineOptions(
StringRef Params) {
1073 return make_error<StringError>(
1074 formatv(
"invalid function-simplification parameter '{0}' ", Params)
1083 "MemorySSAPrinterPass");
1088 "SpeculativeExecutionPass");
1093 while (!Params.
empty()) {
1095 std::tie(ParamName, Params) = Params.
split(
';');
1100 return make_error<StringError>(
1101 formatv(
"invalid MemProfUse pass parameter '{0}' ", ParamName).str(),
1110 "StructuralHashPrinterPass");
1115 "WinEHPreparePass");
1120 while (!Params.
empty()) {
1122 std::tie(ParamName, Params) = Params.
split(
';');
1125 if (ParamName ==
"group-by-use")
1127 else if (ParamName ==
"ignore-single-use")
1129 else if (ParamName ==
"merge-const")
1131 else if (ParamName ==
"merge-external")
1135 return make_error<StringError>(
1136 formatv(
"invalid GlobalMergePass parameter '{0}' ", ParamName)
1149 return Name.starts_with(
"default") ||
Name.starts_with(
"thinlto") ||
1150 Name.starts_with(
"lto");
1161template <
typename PassManagerT,
typename CallbacksT>
1163 if (!Callbacks.empty()) {
1164 PassManagerT DummyPM;
1165 for (
auto &CB : Callbacks)
1166 if (CB(
Name, DummyPM, {}))
1172template <
typename CallbacksT>
1178 StringRef NameNoBracket =
Name.take_until([](
char C) {
return C ==
'<'; });
1181 if (
Name ==
"module")
1183 if (
Name ==
"cgscc")
1185 if (NameNoBracket ==
"function")
1187 if (
Name ==
"coro-cond")
1194#define MODULE_PASS(NAME, CREATE_PASS) \
1197#define MODULE_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1198 if (PassBuilder::checkParametrizedPassName(Name, NAME)) \
1200#define MODULE_ANALYSIS(NAME, CREATE_PASS) \
1201 if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
1203#include "PassRegistry.def"
1205 return callbacksAcceptPassName<ModulePassManager>(
Name, Callbacks);
1208template <
typename CallbacksT>
1211 StringRef NameNoBracket =
Name.take_until([](
char C) {
return C ==
'<'; });
1212 if (
Name ==
"cgscc")
1214 if (NameNoBracket ==
"function")
1223#define CGSCC_PASS(NAME, CREATE_PASS) \
1226#define CGSCC_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1227 if (PassBuilder::checkParametrizedPassName(Name, NAME)) \
1229#define CGSCC_ANALYSIS(NAME, CREATE_PASS) \
1230 if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
1232#include "PassRegistry.def"
1234 return callbacksAcceptPassName<CGSCCPassManager>(
Name, Callbacks);
1237template <
typename CallbacksT>
1240 StringRef NameNoBracket =
Name.take_until([](
char C) {
return C ==
'<'; });
1241 if (NameNoBracket ==
"function")
1243 if (
Name ==
"loop" ||
Name ==
"loop-mssa" ||
Name ==
"machine-function")
1250#define FUNCTION_PASS(NAME, CREATE_PASS) \
1253#define FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1254 if (PassBuilder::checkParametrizedPassName(Name, NAME)) \
1256#define FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
1257 if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
1259#include "PassRegistry.def"
1261 return callbacksAcceptPassName<FunctionPassManager>(
Name, Callbacks);
1264template <
typename CallbacksT>
1267 if (
Name ==
"machine-function")
1274#define MACHINE_FUNCTION_PASS(NAME, CREATE_PASS) \
1277#define MACHINE_FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
1278 if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
1281#include "llvm/Passes/MachinePassRegistry.def"
1283 return callbacksAcceptPassName<MachineFunctionPassManager>(
Name, Callbacks);
1286template <
typename CallbacksT>
1288 bool &UseMemorySSA) {
1289 UseMemorySSA =
false;
1296 UseMemorySSA =
true;
1300#define LOOPNEST_PASS(NAME, CREATE_PASS) \
1303#include "PassRegistry.def"
1305 return callbacksAcceptPassName<LoopPassManager>(
Name, Callbacks);
1308template <
typename CallbacksT>
1310 bool &UseMemorySSA) {
1311 UseMemorySSA =
false;
1318 UseMemorySSA =
true;
1322#define LOOP_PASS(NAME, CREATE_PASS) \
1325#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1326 if (PassBuilder::checkParametrizedPassName(Name, NAME)) \
1328#define LOOP_ANALYSIS(NAME, CREATE_PASS) \
1329 if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
1331#include "PassRegistry.def"
1333 return callbacksAcceptPassName<LoopPassManager>(
Name, Callbacks);
1336std::optional<std::vector<PassBuilder::PipelineElement>>
1337PassBuilder::parsePipelineText(
StringRef Text) {
1338 std::vector<PipelineElement> ResultPipeline;
1343 std::vector<PipelineElement> &Pipeline = *PipelineStack.
back();
1344 size_t Pos =
Text.find_first_of(
",()");
1345 Pipeline.push_back({
Text.substr(0, Pos), {}});
1348 if (Pos ==
Text.npos)
1351 char Sep =
Text[Pos];
1359 PipelineStack.
push_back(&Pipeline.back().InnerPipeline);
1363 assert(Sep ==
')' &&
"Bogus separator!");
1368 if (PipelineStack.
size() == 1)
1369 return std::nullopt;
1372 }
while (
Text.consume_front(
")"));
1380 if (!
Text.consume_front(
","))
1381 return std::nullopt;
1384 if (PipelineStack.
size() > 1)
1386 return std::nullopt;
1388 assert(PipelineStack.
back() == &ResultPipeline &&
1389 "Wrong pipeline at the bottom of the stack!");
1390 return {std::move(ResultPipeline)};
1394 const PipelineElement &E) {
1395 auto &
Name = E.Name;
1396 auto &InnerPipeline = E.InnerPipeline;
1399 if (!InnerPipeline.empty()) {
1400 if (
Name ==
"module") {
1402 if (
auto Err = parseModulePassPipeline(NestedMPM, InnerPipeline))
1407 if (
Name ==
"coro-cond") {
1409 if (
auto Err = parseModulePassPipeline(NestedMPM, InnerPipeline))
1414 if (
Name ==
"cgscc") {
1416 if (
auto Err = parseCGSCCPassPipeline(CGPM, InnerPipeline))
1423 return make_error<StringError>(
1424 "cannot have a no-rerun module to function adaptor",
1427 if (
auto Err = parseFunctionPassPipeline(FPM, InnerPipeline))
1435 if (
auto Err = parseModulePassPipeline(NestedMPM, InnerPipeline))
1441 for (
auto &
C : ModulePipelineParsingCallbacks)
1446 return make_error<StringError>(
1447 formatv(
"invalid use of '{0}' pass as module pipeline",
Name).str(),
1456 return make_error<StringError>(
1457 formatv(
"unknown default pipeline alias '{0}'",
Name).str(),
1460 assert(Matches.
size() == 3 &&
"Must capture two matched strings!");
1472 if (Matches[1] ==
"default") {
1474 }
else if (Matches[1] ==
"thinlto-pre-link") {
1476 }
else if (Matches[1] ==
"thinlto") {
1478 }
else if (Matches[1] ==
"lto-pre-link") {
1487 assert(Matches[1] ==
"lto" &&
"Not one of the matched options!");
1494#define MODULE_PASS(NAME, CREATE_PASS) \
1495 if (Name == NAME) { \
1496 MPM.addPass(CREATE_PASS); \
1497 return Error::success(); \
1499#define MODULE_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1500 if (checkParametrizedPassName(Name, NAME)) { \
1501 auto Params = parsePassParameters(PARSER, Name, NAME); \
1503 return Params.takeError(); \
1504 MPM.addPass(CREATE_PASS(Params.get())); \
1505 return Error::success(); \
1507#define MODULE_ANALYSIS(NAME, CREATE_PASS) \
1508 if (Name == "require<" NAME ">") { \
1510 RequireAnalysisPass< \
1511 std::remove_reference_t<decltype(CREATE_PASS)>, Module>()); \
1512 return Error::success(); \
1514 if (Name == "invalidate<" NAME ">") { \
1515 MPM.addPass(InvalidateAnalysisPass< \
1516 std::remove_reference_t<decltype(CREATE_PASS)>>()); \
1517 return Error::success(); \
1519#define CGSCC_PASS(NAME, CREATE_PASS) \
1520 if (Name == NAME) { \
1521 MPM.addPass(createModuleToPostOrderCGSCCPassAdaptor(CREATE_PASS)); \
1522 return Error::success(); \
1524#define CGSCC_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1525 if (checkParametrizedPassName(Name, NAME)) { \
1526 auto Params = parsePassParameters(PARSER, Name, NAME); \
1528 return Params.takeError(); \
1530 createModuleToPostOrderCGSCCPassAdaptor(CREATE_PASS(Params.get()))); \
1531 return Error::success(); \
1533#define FUNCTION_PASS(NAME, CREATE_PASS) \
1534 if (Name == NAME) { \
1535 MPM.addPass(createModuleToFunctionPassAdaptor(CREATE_PASS)); \
1536 return Error::success(); \
1538#define FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1539 if (checkParametrizedPassName(Name, NAME)) { \
1540 auto Params = parsePassParameters(PARSER, Name, NAME); \
1542 return Params.takeError(); \
1543 MPM.addPass(createModuleToFunctionPassAdaptor(CREATE_PASS(Params.get()))); \
1544 return Error::success(); \
1546#define LOOPNEST_PASS(NAME, CREATE_PASS) \
1547 if (Name == NAME) { \
1548 MPM.addPass(createModuleToFunctionPassAdaptor( \
1549 createFunctionToLoopPassAdaptor(CREATE_PASS, false, false))); \
1550 return Error::success(); \
1552#define LOOP_PASS(NAME, CREATE_PASS) \
1553 if (Name == NAME) { \
1554 MPM.addPass(createModuleToFunctionPassAdaptor( \
1555 createFunctionToLoopPassAdaptor(CREATE_PASS, false, false))); \
1556 return Error::success(); \
1558#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1559 if (checkParametrizedPassName(Name, NAME)) { \
1560 auto Params = parsePassParameters(PARSER, Name, NAME); \
1562 return Params.takeError(); \
1564 createModuleToFunctionPassAdaptor(createFunctionToLoopPassAdaptor( \
1565 CREATE_PASS(Params.get()), false, false))); \
1566 return Error::success(); \
1568#include "PassRegistry.def"
1570 for (
auto &
C : ModulePipelineParsingCallbacks)
1573 return make_error<StringError>(
1579 const PipelineElement &E) {
1580 auto &
Name = E.Name;
1581 auto &InnerPipeline = E.InnerPipeline;
1584 if (!InnerPipeline.empty()) {
1585 if (
Name ==
"cgscc") {
1587 if (
auto Err = parseCGSCCPassPipeline(NestedCGPM, InnerPipeline))
1590 CGPM.
addPass(std::move(NestedCGPM));
1595 if (
auto Err = parseFunctionPassPipeline(FPM, InnerPipeline))
1599 std::move(FPM), Params->first, Params->second));
1604 if (
auto Err = parseCGSCCPassPipeline(NestedCGPM, InnerPipeline))
1611 if (
auto Err = parseCGSCCPassPipeline(NestedCGPM, InnerPipeline))
1618 for (
auto &
C : CGSCCPipelineParsingCallbacks)
1619 if (
C(
Name, CGPM, InnerPipeline))
1623 return make_error<StringError>(
1624 formatv(
"invalid use of '{0}' pass as cgscc pipeline",
Name).str(),
1629#define CGSCC_PASS(NAME, CREATE_PASS) \
1630 if (Name == NAME) { \
1631 CGPM.addPass(CREATE_PASS); \
1632 return Error::success(); \
1634#define CGSCC_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1635 if (checkParametrizedPassName(Name, NAME)) { \
1636 auto Params = parsePassParameters(PARSER, Name, NAME); \
1638 return Params.takeError(); \
1639 CGPM.addPass(CREATE_PASS(Params.get())); \
1640 return Error::success(); \
1642#define CGSCC_ANALYSIS(NAME, CREATE_PASS) \
1643 if (Name == "require<" NAME ">") { \
1644 CGPM.addPass(RequireAnalysisPass< \
1645 std::remove_reference_t<decltype(CREATE_PASS)>, \
1646 LazyCallGraph::SCC, CGSCCAnalysisManager, LazyCallGraph &, \
1647 CGSCCUpdateResult &>()); \
1648 return Error::success(); \
1650 if (Name == "invalidate<" NAME ">") { \
1651 CGPM.addPass(InvalidateAnalysisPass< \
1652 std::remove_reference_t<decltype(CREATE_PASS)>>()); \
1653 return Error::success(); \
1655#define FUNCTION_PASS(NAME, CREATE_PASS) \
1656 if (Name == NAME) { \
1657 CGPM.addPass(createCGSCCToFunctionPassAdaptor(CREATE_PASS)); \
1658 return Error::success(); \
1660#define FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1661 if (checkParametrizedPassName(Name, NAME)) { \
1662 auto Params = parsePassParameters(PARSER, Name, NAME); \
1664 return Params.takeError(); \
1665 CGPM.addPass(createCGSCCToFunctionPassAdaptor(CREATE_PASS(Params.get()))); \
1666 return Error::success(); \
1668#define LOOPNEST_PASS(NAME, CREATE_PASS) \
1669 if (Name == NAME) { \
1670 CGPM.addPass(createCGSCCToFunctionPassAdaptor( \
1671 createFunctionToLoopPassAdaptor(CREATE_PASS, false, false))); \
1672 return Error::success(); \
1674#define LOOP_PASS(NAME, CREATE_PASS) \
1675 if (Name == NAME) { \
1676 CGPM.addPass(createCGSCCToFunctionPassAdaptor( \
1677 createFunctionToLoopPassAdaptor(CREATE_PASS, false, false))); \
1678 return Error::success(); \
1680#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1681 if (checkParametrizedPassName(Name, NAME)) { \
1682 auto Params = parsePassParameters(PARSER, Name, NAME); \
1684 return Params.takeError(); \
1686 createCGSCCToFunctionPassAdaptor(createFunctionToLoopPassAdaptor( \
1687 CREATE_PASS(Params.get()), false, false))); \
1688 return Error::success(); \
1690#include "PassRegistry.def"
1692 for (
auto &
C : CGSCCPipelineParsingCallbacks)
1693 if (
C(
Name, CGPM, InnerPipeline))
1695 return make_error<StringError>(
1701 const PipelineElement &E) {
1702 auto &
Name = E.Name;
1703 auto &InnerPipeline = E.InnerPipeline;
1706 if (!InnerPipeline.empty()) {
1707 if (
Name ==
"function") {
1709 if (
auto Err = parseFunctionPassPipeline(NestedFPM, InnerPipeline))
1712 FPM.
addPass(std::move(NestedFPM));
1715 if (
Name ==
"loop" ||
Name ==
"loop-mssa") {
1717 if (
auto Err = parseLoopPassPipeline(LPM, InnerPipeline))
1720 bool UseMemorySSA = (
Name ==
"loop-mssa");
1722 return Pipeline.Name.contains(
"simple-loop-unswitch");
1724 bool UseBPI =
llvm::any_of(InnerPipeline, [](
auto Pipeline) {
1725 return Pipeline.Name ==
"loop-predication";
1733 if (
auto Err = parseFunctionPassPipeline(NestedFPM, InnerPipeline))
1738 if (
Name ==
"machine-function") {
1740 if (
auto Err = parseMachinePassPipeline(MFPM, InnerPipeline))
1746 for (
auto &
C : FunctionPipelineParsingCallbacks)
1747 if (
C(
Name, FPM, InnerPipeline))
1751 return make_error<StringError>(
1752 formatv(
"invalid use of '{0}' pass as function pipeline",
Name).str(),
1757#define FUNCTION_PASS(NAME, CREATE_PASS) \
1758 if (Name == NAME) { \
1759 FPM.addPass(CREATE_PASS); \
1760 return Error::success(); \
1762#define FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1763 if (checkParametrizedPassName(Name, NAME)) { \
1764 auto Params = parsePassParameters(PARSER, Name, NAME); \
1766 return Params.takeError(); \
1767 FPM.addPass(CREATE_PASS(Params.get())); \
1768 return Error::success(); \
1770#define FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
1771 if (Name == "require<" NAME ">") { \
1773 RequireAnalysisPass< \
1774 std::remove_reference_t<decltype(CREATE_PASS)>, Function>()); \
1775 return Error::success(); \
1777 if (Name == "invalidate<" NAME ">") { \
1778 FPM.addPass(InvalidateAnalysisPass< \
1779 std::remove_reference_t<decltype(CREATE_PASS)>>()); \
1780 return Error::success(); \
1786#define LOOPNEST_PASS(NAME, CREATE_PASS) \
1787 if (Name == NAME) { \
1788 FPM.addPass(createFunctionToLoopPassAdaptor(CREATE_PASS, false, false)); \
1789 return Error::success(); \
1791#define LOOP_PASS(NAME, CREATE_PASS) \
1792 if (Name == NAME) { \
1793 FPM.addPass(createFunctionToLoopPassAdaptor(CREATE_PASS, false, false)); \
1794 return Error::success(); \
1796#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1797 if (checkParametrizedPassName(Name, NAME)) { \
1798 auto Params = parsePassParameters(PARSER, Name, NAME); \
1800 return Params.takeError(); \
1801 FPM.addPass(createFunctionToLoopPassAdaptor(CREATE_PASS(Params.get()), \
1803 return Error::success(); \
1805#include "PassRegistry.def"
1807 for (
auto &
C : FunctionPipelineParsingCallbacks)
1808 if (
C(
Name, FPM, InnerPipeline))
1810 return make_error<StringError>(
1811 formatv(
"unknown function pass '{0}'",
Name).str(),
1816 const PipelineElement &E) {
1818 auto &InnerPipeline = E.InnerPipeline;
1821 if (!InnerPipeline.empty()) {
1822 if (
Name ==
"loop") {
1824 if (
auto Err = parseLoopPassPipeline(NestedLPM, InnerPipeline))
1827 LPM.
addPass(std::move(NestedLPM));
1832 if (
auto Err = parseLoopPassPipeline(NestedLPM, InnerPipeline))
1838 for (
auto &
C : LoopPipelineParsingCallbacks)
1839 if (
C(
Name, LPM, InnerPipeline))
1843 return make_error<StringError>(
1844 formatv(
"invalid use of '{0}' pass as loop pipeline",
Name).str(),
1849#define LOOPNEST_PASS(NAME, CREATE_PASS) \
1850 if (Name == NAME) { \
1851 LPM.addPass(CREATE_PASS); \
1852 return Error::success(); \
1854#define LOOP_PASS(NAME, CREATE_PASS) \
1855 if (Name == NAME) { \
1856 LPM.addPass(CREATE_PASS); \
1857 return Error::success(); \
1859#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1860 if (checkParametrizedPassName(Name, NAME)) { \
1861 auto Params = parsePassParameters(PARSER, Name, NAME); \
1863 return Params.takeError(); \
1864 LPM.addPass(CREATE_PASS(Params.get())); \
1865 return Error::success(); \
1867#define LOOP_ANALYSIS(NAME, CREATE_PASS) \
1868 if (Name == "require<" NAME ">") { \
1869 LPM.addPass(RequireAnalysisPass< \
1870 std::remove_reference_t<decltype(CREATE_PASS)>, Loop, \
1871 LoopAnalysisManager, LoopStandardAnalysisResults &, \
1873 return Error::success(); \
1875 if (Name == "invalidate<" NAME ">") { \
1876 LPM.addPass(InvalidateAnalysisPass< \
1877 std::remove_reference_t<decltype(CREATE_PASS)>>()); \
1878 return Error::success(); \
1880#include "PassRegistry.def"
1882 for (
auto &
C : LoopPipelineParsingCallbacks)
1883 if (
C(
Name, LPM, InnerPipeline))
1885 return make_error<StringError>(
formatv(
"unknown loop pass '{0}'",
Name).str(),
1890 const PipelineElement &E) {
1892 if (!E.InnerPipeline.empty())
1893 return make_error<StringError>(
"invalid pipeline",
1896#define MACHINE_MODULE_PASS(NAME, CREATE_PASS) \
1897 if (Name == NAME) { \
1898 MFPM.addPass(CREATE_PASS); \
1899 return Error::success(); \
1901#define MACHINE_FUNCTION_PASS(NAME, CREATE_PASS) \
1902 if (Name == NAME) { \
1903 MFPM.addPass(CREATE_PASS); \
1904 return Error::success(); \
1906#include "llvm/Passes/MachinePassRegistry.def"
1908 for (
auto &
C : MachineFunctionPipelineParsingCallbacks)
1909 if (
C(
Name, MFPM, E.InnerPipeline))
1911 return make_error<StringError>(
1912 formatv(
"unknown machine pass '{0}'",
Name).str(),
1917#define MODULE_ALIAS_ANALYSIS(NAME, CREATE_PASS) \
1918 if (Name == NAME) { \
1919 AA.registerModuleAnalysis< \
1920 std::remove_reference_t<decltype(CREATE_PASS)>>(); \
1923#define FUNCTION_ALIAS_ANALYSIS(NAME, CREATE_PASS) \
1924 if (Name == NAME) { \
1925 AA.registerFunctionAnalysis< \
1926 std::remove_reference_t<decltype(CREATE_PASS)>>(); \
1929#include "PassRegistry.def"
1931 for (
auto &
C : AAParsingCallbacks)
1937Error PassBuilder::parseMachinePassPipeline(
1939 for (
const auto &Element : Pipeline) {
1940 if (
auto Err = parseMachinePass(MFPM, Element))
1948 for (
const auto &Element : Pipeline) {
1949 if (
auto Err = parseLoopPass(LPM, Element))
1955Error PassBuilder::parseFunctionPassPipeline(
1957 for (
const auto &Element : Pipeline) {
1958 if (
auto Err = parseFunctionPass(FPM, Element))
1966 for (
const auto &Element : Pipeline) {
1967 if (
auto Err = parseCGSCCPass(CGPM, Element))
1999 for (
const auto &Element : Pipeline) {
2000 if (
auto Err = parseModulePass(
MPM, Element))
2011 auto Pipeline = parsePipelineText(PipelineText);
2012 if (!Pipeline || Pipeline->empty())
2013 return make_error<StringError>(
2014 formatv(
"invalid pipeline '{0}'", PipelineText).str(),
2024 Pipeline = {{
"cgscc", std::move(*Pipeline)}};
2026 FunctionPipelineParsingCallbacks)) {
2027 Pipeline = {{
"function", std::move(*Pipeline)}};
2030 Pipeline = {{
"function", {{UseMemorySSA ?
"loop-mssa" :
"loop",
2031 std::move(*Pipeline)}}}};
2032 }
else if (
isLoopPassName(FirstName, LoopPipelineParsingCallbacks,
2034 Pipeline = {{
"function", {{UseMemorySSA ?
"loop-mssa" :
"loop",
2035 std::move(*Pipeline)}}}};
2037 FirstName, MachineFunctionPipelineParsingCallbacks)) {
2038 Pipeline = {{
"function", {{
"machine-function", std::move(*Pipeline)}}}};
2040 for (
auto &
C : TopLevelPipelineParsingCallbacks)
2041 if (
C(
MPM, *Pipeline))
2045 auto &InnerPipeline = Pipeline->front().InnerPipeline;
2046 return make_error<StringError>(
2047 formatv(
"unknown {0} name '{1}'",
2048 (InnerPipeline.empty() ?
"pass" :
"pipeline"), FirstName)
2054 if (
auto Err = parseModulePassPipeline(
MPM, *Pipeline))
2062 auto Pipeline = parsePipelineText(PipelineText);
2063 if (!Pipeline || Pipeline->empty())
2064 return make_error<StringError>(
2065 formatv(
"invalid pipeline '{0}'", PipelineText).str(),
2070 return make_error<StringError>(
2071 formatv(
"unknown cgscc pass '{0}' in pipeline '{1}'", FirstName,
2076 if (
auto Err = parseCGSCCPassPipeline(CGPM, *Pipeline))
2085 auto Pipeline = parsePipelineText(PipelineText);
2086 if (!Pipeline || Pipeline->empty())
2087 return make_error<StringError>(
2088 formatv(
"invalid pipeline '{0}'", PipelineText).str(),
2093 return make_error<StringError>(
2094 formatv(
"unknown function pass '{0}' in pipeline '{1}'", FirstName,
2099 if (
auto Err = parseFunctionPassPipeline(FPM, *Pipeline))
2107 auto Pipeline = parsePipelineText(PipelineText);
2108 if (!Pipeline || Pipeline->empty())
2109 return make_error<StringError>(
2110 formatv(
"invalid pipeline '{0}'", PipelineText).str(),
2113 if (
auto Err = parseLoopPassPipeline(CGPM, *Pipeline))
2121 auto Pipeline = parsePipelineText(PipelineText);
2122 if (!Pipeline || Pipeline->empty())
2123 return make_error<StringError>(
2124 formatv(
"invalid machine pass pipeline '{0}'", PipelineText).str(),
2127 if (
auto Err = parseMachinePassPipeline(MFPM, *Pipeline))
2136 if (PipelineText ==
"default") {
2141 while (!PipelineText.
empty()) {
2143 std::tie(
Name, PipelineText) = PipelineText.
split(
',');
2144 if (!parseAAPassName(AA,
Name))
2145 return make_error<StringError>(
2146 formatv(
"unknown alias analysis name '{0}'",
Name).str(),
2158 OS <<
" " <<
PassName <<
"<" << Params <<
">\n";
2164 OS <<
"Module passes:\n";
2165#define MODULE_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2166#include "PassRegistry.def"
2168 OS <<
"Module passes with params:\n";
2169#define MODULE_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
2170 printPassName(NAME, PARAMS, OS);
2171#include "PassRegistry.def"
2173 OS <<
"Module analyses:\n";
2174#define MODULE_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2175#include "PassRegistry.def"
2177 OS <<
"Module alias analyses:\n";
2178#define MODULE_ALIAS_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2179#include "PassRegistry.def"
2181 OS <<
"CGSCC passes:\n";
2182#define CGSCC_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2183#include "PassRegistry.def"
2185 OS <<
"CGSCC passes with params:\n";
2186#define CGSCC_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
2187 printPassName(NAME, PARAMS, OS);
2188#include "PassRegistry.def"
2190 OS <<
"CGSCC analyses:\n";
2191#define CGSCC_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2192#include "PassRegistry.def"
2194 OS <<
"Function passes:\n";
2195#define FUNCTION_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2196#include "PassRegistry.def"
2198 OS <<
"Function passes with params:\n";
2199#define FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
2200 printPassName(NAME, PARAMS, OS);
2201#include "PassRegistry.def"
2203 OS <<
"Function analyses:\n";
2204#define FUNCTION_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2205#include "PassRegistry.def"
2207 OS <<
"Function alias analyses:\n";
2208#define FUNCTION_ALIAS_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2209#include "PassRegistry.def"
2211 OS <<
"LoopNest passes:\n";
2212#define LOOPNEST_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2213#include "PassRegistry.def"
2215 OS <<
"Loop passes:\n";
2216#define LOOP_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2217#include "PassRegistry.def"
2219 OS <<
"Loop passes with params:\n";
2220#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
2221 printPassName(NAME, PARAMS, OS);
2222#include "PassRegistry.def"
2224 OS <<
"Loop analyses:\n";
2225#define LOOP_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2226#include "PassRegistry.def"
2228 OS <<
"Machine module passes (WIP):\n";
2229#define MACHINE_MODULE_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2230#include "llvm/Passes/MachinePassRegistry.def"
2232 OS <<
"Machine function passes (WIP):\n";
2233#define MACHINE_FUNCTION_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2234#include "llvm/Passes/MachinePassRegistry.def"
2236 OS <<
"Machine function analyses (WIP):\n";
2237#define MACHINE_FUNCTION_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2238#include "llvm/Passes/MachinePassRegistry.def"
2244 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
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 std::optional< int > parseRepeatPassName(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".
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.
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.
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 ...
LLVM_ATTRIBUTE_MINSIZE std::enable_if_t< is_detected< HasRunOnLoopT, PassT >::value > addPass(PassT &&Pass)
LLVM_ATTRIBUTE_MINSIZE void 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.
static bool hasLimitedCodeGenPipeline()
Returns true if one of the -start-after, -start-before, -stop-after or -stop-before options is set.
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.
std::vector< std::string > printAfterPasses()
ModuleToFunctionPassAdaptor createModuleToFunctionPassAdaptor(FunctionPassT &&Pass, bool EagerlyInvalidate=false)
A function to deduce a function pass type and wrap it in the templated adaptor.
RepeatedPass< PassT > createRepeatedPass(int Count, PassT &&P)
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.
std::vector< std::string > printBeforePasses()
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.
bool isFilterPassesEmpty()
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.