306 "^(default|thinlto-pre-link|thinlto|lto-pre-link|lto)<(O[0123sz])>$");
310 "print-pipeline-passes",
311 cl::desc(
"Print a '-passes' compatible string describing the pipeline "
312 "(best-effort only)."));
328bool shouldPopulateClassToPassNames() {
336class TriggerCrashPass :
public PassInfoMixin<TriggerCrashPass> {
347class TriggerVerifierErrorPass
355 GlobalValue::LinkageTypes::InternalLinkage,
356 "__bad_alias",
nullptr, &M);
376 static StringRef name() {
return "TriggerVerifierErrorPass"; }
381class RequireAllMachineFunctionPropertiesPass
382 :
public PassInfoMixin<RequireAllMachineFunctionPropertiesPass> {
390 MFProps.
set(MachineFunctionProperties::Property::FailedISel);
391 MFProps.
set(MachineFunctionProperties::Property::FailsVerification);
392 MFProps.
set(MachineFunctionProperties::Property::IsSSA);
393 MFProps.
set(MachineFunctionProperties::Property::Legalized);
394 MFProps.
set(MachineFunctionProperties::Property::NoPHIs);
395 MFProps.
set(MachineFunctionProperties::Property::NoVRegs);
396 MFProps.
set(MachineFunctionProperties::Property::RegBankSelected);
397 MFProps.
set(MachineFunctionProperties::Property::Selected);
398 MFProps.
set(MachineFunctionProperties::Property::TiedOpsRewritten);
399 MFProps.
set(MachineFunctionProperties::Property::TracksDebugUserValues);
400 MFProps.
set(MachineFunctionProperties::Property::TracksLiveness);
403 static StringRef name() {
return "RequireAllMachineFunctionPropertiesPass"; }
409 std::optional<PGOOptions> PGOOpt,
411 :
TM(
TM), PTO(PTO), PGOOpt(PGOOpt),
PIC(
PIC) {
412 bool ShouldPopulateClassToPassNames =
PIC && shouldPopulateClassToPassNames();
414 TM->registerPassBuilderCallbacks(*
this, ShouldPopulateClassToPassNames);
415 if (ShouldPopulateClassToPassNames) {
416#define MODULE_PASS(NAME, CREATE_PASS) \
417 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
418#define MODULE_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
419 PIC->addClassToPassName(CLASS, NAME);
420#define MODULE_ANALYSIS(NAME, CREATE_PASS) \
421 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
422#define FUNCTION_PASS(NAME, CREATE_PASS) \
423 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
424#define FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
425 PIC->addClassToPassName(CLASS, NAME);
426#define FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
427 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
428#define LOOPNEST_PASS(NAME, CREATE_PASS) \
429 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
430#define LOOP_PASS(NAME, CREATE_PASS) \
431 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
432#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
433 PIC->addClassToPassName(CLASS, NAME);
434#define LOOP_ANALYSIS(NAME, CREATE_PASS) \
435 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
436#define CGSCC_PASS(NAME, CREATE_PASS) \
437 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
438#define CGSCC_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
439 PIC->addClassToPassName(CLASS, NAME);
440#define CGSCC_ANALYSIS(NAME, CREATE_PASS) \
441 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
442#include "PassRegistry.def"
444#define MACHINE_FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
445 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
446#define MACHINE_FUNCTION_PASS(NAME, CREATE_PASS) \
447 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
448#include "llvm/Passes/MachinePassRegistry.def"
453#define MODULE_ANALYSIS(NAME, CREATE_PASS) \
454 MAM.registerPass([&] { return CREATE_PASS; });
455#include "PassRegistry.def"
457 for (
auto &
C : ModuleAnalysisRegistrationCallbacks)
462#define CGSCC_ANALYSIS(NAME, CREATE_PASS) \
463 CGAM.registerPass([&] { return CREATE_PASS; });
464#include "PassRegistry.def"
466 for (
auto &
C : CGSCCAnalysisRegistrationCallbacks)
476#define FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
477 FAM.registerPass([&] { return CREATE_PASS; });
478#include "PassRegistry.def"
480 for (
auto &
C : FunctionAnalysisRegistrationCallbacks)
487#define MACHINE_FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
488 MFAM.registerPass([&] { return CREATE_PASS; });
489#include "llvm/Passes/MachinePassRegistry.def"
491 for (
auto &
C : MachineFunctionAnalysisRegistrationCallbacks)
496#define LOOP_ANALYSIS(NAME, CREATE_PASS) \
497 LAM.registerPass([&] { return CREATE_PASS; });
498#include "PassRegistry.def"
500 for (
auto &
C : LoopAnalysisRegistrationCallbacks)
505 if (!
Name.consume_front(
"repeat<") || !
Name.consume_back(
">"))
508 if (
Name.getAsInteger(0, Count) || Count <= 0)
513static std::optional<std::pair<bool, bool>>
515 std::pair<bool, bool> Params;
516 if (!
Name.consume_front(
"function"))
520 if (!
Name.consume_front(
"<") || !
Name.consume_back(
">"))
522 while (!
Name.empty()) {
523 auto [Front, Back] =
Name.split(
';');
525 if (Front ==
"eager-inv")
527 else if (Front ==
"no-rerun")
528 Params.second =
true;
536 if (!
Name.consume_front(
"devirt<") || !
Name.consume_back(
">"))
539 if (
Name.getAsInteger(0, Count) || Count < 0)
559 while (!Params.
empty()) {
561 std::tie(ParamName, Params) = Params.
split(
';');
563 if (ParamName == OptionName) {
566 return make_error<StringError>(
581 while (!Params.
empty()) {
583 std::tie(ParamName, Params) = Params.
split(
';');
587 return make_error<StringError>(
588 formatv(
"invalid HardwareLoopPass parameter '{0}' ", ParamName).str(),
593 if (ParamName.
consume_front(
"hardware-loop-counter-bitwidth=")) {
596 return make_error<StringError>(
597 formatv(
"invalid HardwareLoopPass parameter '{0}' ", ParamName).str(),
602 if (ParamName ==
"force-hardware-loops") {
604 }
else if (ParamName ==
"force-hardware-loop-phi") {
606 }
else if (ParamName ==
"force-nested-hardware-loop") {
608 }
else if (ParamName ==
"force-hardware-loop-guard") {
611 return make_error<StringError>(
612 formatv(
"invalid HardwarePass parameter '{0}' ", ParamName).str(),
616 return HardwareLoopOpts;
622 while (!Params.
empty()) {
624 std::tie(ParamName, Params) = Params.
split(
';');
625 std::optional<OptimizationLevel> OptLevel =
parseOptLevel(ParamName);
627 if (OptLevel && !OptLevel->isOptimizingForSize()) {
628 UnrollOpts.
setOptLevel(OptLevel->getSpeedupLevel());
634 return make_error<StringError>(
635 formatv(
"invalid LoopUnrollPass parameter '{0}' ", ParamName).str(),
642 if (ParamName ==
"partial") {
644 }
else if (ParamName ==
"peeling") {
646 }
else if (ParamName ==
"profile-peeling") {
648 }
else if (ParamName ==
"runtime") {
650 }
else if (ParamName ==
"upperbound") {
653 return make_error<StringError>(
654 formatv(
"invalid LoopUnrollPass parameter '{0}' ", ParamName).str(),
663 Params,
"vfe-linkage-unit-visibility",
"GlobalDCE");
683 Params,
"skip-non-recursive-function-attrs",
"PostOrderFunctionAttrs");
692 return make_error<StringError>(
693 formatv(
"too many CFGuardPass parameters '{0}' ", Params).str(),
696 if (Param ==
"check")
698 if (Param ==
"dispatch")
701 return make_error<StringError>(
702 formatv(
"invalid CFGuardPass mechanism: '{0}' ", Param).str(),
712 "EntryExitInstrumenter");
721 "LowerMatrixIntrinsics");
726 while (!Params.
empty()) {
728 std::tie(ParamName, Params) = Params.
split(
';');
730 if (ParamName ==
"kernel") {
731 Result.CompileKernel =
true;
733 return make_error<StringError>(
734 formatv(
"invalid AddressSanitizer pass parameter '{0}' ", ParamName)
744 while (!Params.
empty()) {
746 std::tie(ParamName, Params) = Params.
split(
';');
748 if (ParamName ==
"recover") {
750 }
else if (ParamName ==
"kernel") {
751 Result.CompileKernel =
true;
753 return make_error<StringError>(
754 formatv(
"invalid HWAddressSanitizer pass parameter '{0}' ", ParamName)
764 while (!Params.
empty()) {
766 std::tie(ParamName, Params) = Params.
split(
';');
768 if (ParamName ==
"thinlto") {
770 }
else if (ParamName ==
"emit-summary") {
771 Result.EmitLTOSummary =
true;
773 return make_error<StringError>(
774 formatv(
"invalid EmbedBitcode pass parameter '{0}' ", ParamName)
784 while (!Params.
empty()) {
786 std::tie(ParamName, Params) = Params.
split(
';');
788 if (ParamName ==
"recover") {
790 }
else if (ParamName ==
"kernel") {
794 return make_error<StringError>(
795 formatv(
"invalid argument to MemorySanitizer pass track-origins "
800 }
else if (ParamName ==
"eager-checks") {
801 Result.EagerChecks =
true;
803 return make_error<StringError>(
804 formatv(
"invalid MemorySanitizer pass parameter '{0}' ", ParamName)
815 while (!Params.
empty()) {
817 std::tie(ParamName, Params) = Params.
split(
';');
820 if (ParamName ==
"speculate-blocks") {
822 }
else if (ParamName ==
"simplify-cond-branch") {
824 }
else if (ParamName ==
"forward-switch-cond") {
826 }
else if (ParamName ==
"switch-range-to-icmp") {
828 }
else if (ParamName ==
"switch-to-lookup") {
830 }
else if (ParamName ==
"keep-loops") {
832 }
else if (ParamName ==
"hoist-common-insts") {
834 }
else if (ParamName ==
"sink-common-insts") {
837 APInt BonusInstThreshold;
839 return make_error<StringError>(
840 formatv(
"invalid argument to SimplifyCFG pass bonus-threshold "
846 return make_error<StringError>(
847 formatv(
"invalid SimplifyCFG pass parameter '{0}' ", ParamName).str(),
858 Result.setVerifyFixpoint(
true);
859 while (!Params.
empty()) {
861 std::tie(ParamName, Params) = Params.
split(
';');
864 if (ParamName ==
"use-loop-info") {
866 }
else if (ParamName ==
"verify-fixpoint") {
871 return make_error<StringError>(
872 formatv(
"invalid argument to InstCombine pass max-iterations "
878 return make_error<StringError>(
879 formatv(
"invalid InstCombine pass parameter '{0}' ", ParamName).str(),
889 while (!Params.
empty()) {
891 std::tie(ParamName, Params) = Params.
split(
';');
894 if (ParamName ==
"interleave-forced-only") {
896 }
else if (ParamName ==
"vectorize-forced-only") {
899 return make_error<StringError>(
900 formatv(
"invalid LoopVectorize parameter '{0}' ", ParamName).str(),
908 std::pair<bool, bool>
Result = {
false,
true};
909 while (!Params.
empty()) {
911 std::tie(ParamName, Params) = Params.
split(
';');
914 if (ParamName ==
"nontrivial") {
916 }
else if (ParamName ==
"trivial") {
919 return make_error<StringError>(
920 formatv(
"invalid LoopUnswitch pass parameter '{0}' ", ParamName)
930 while (!Params.
empty()) {
932 std::tie(ParamName, Params) = Params.
split(
';');
935 if (ParamName ==
"allowspeculation") {
938 return make_error<StringError>(
939 formatv(
"invalid LICM pass parameter '{0}' ", ParamName).str(),
947 std::pair<bool, bool>
Result = {
true,
false};
948 while (!Params.
empty()) {
950 std::tie(ParamName, Params) = Params.
split(
';');
953 if (ParamName ==
"header-duplication") {
955 }
else if (ParamName ==
"prepare-for-lto") {
958 return make_error<StringError>(
959 formatv(
"invalid LoopRotate pass parameter '{0}' ", ParamName).str(),
968 while (!Params.
empty()) {
970 std::tie(ParamName, Params) = Params.
split(
';');
973 if (ParamName ==
"split-footer-bb") {
976 return make_error<StringError>(
977 formatv(
"invalid MergedLoadStoreMotion pass parameter '{0}' ",
988 while (!Params.
empty()) {
990 std::tie(ParamName, Params) = Params.
split(
';');
993 if (ParamName ==
"pre") {
995 }
else if (ParamName ==
"load-pre") {
997 }
else if (ParamName ==
"split-backedge-load-pre") {
999 }
else if (ParamName ==
"memdep") {
1002 return make_error<StringError>(
1003 formatv(
"invalid GVN pass parameter '{0}' ", ParamName).str(),
1012 while (!Params.
empty()) {
1014 std::tie(ParamName, Params) = Params.
split(
';');
1017 if (ParamName ==
"func-spec")
1020 return make_error<StringError>(
1021 formatv(
"invalid IPSCCP pass parameter '{0}' ", ParamName).str(),
1028 if (Params.
empty() || Params ==
"modify-cfg")
1030 if (Params ==
"preserve-cfg")
1032 return make_error<StringError>(
1033 formatv(
"invalid SROA pass parameter '{0}' (either preserve-cfg or "
1034 "modify-cfg can be specified)",
1041parseStackLifetimeOptions(
StringRef Params) {
1043 while (!Params.
empty()) {
1045 std::tie(ParamName, Params) = Params.
split(
';');
1047 if (ParamName ==
"may") {
1049 }
else if (ParamName ==
"must") {
1052 return make_error<StringError>(
1053 formatv(
"invalid StackLifetime parameter '{0}' ", ParamName).str(),
1062 "DependenceAnalysisPrinter");
1067 "SeparateConstOffsetFromGEP");
1071parseFunctionSimplificationPipelineOptions(
StringRef Params) {
1074 return make_error<StringError>(
1075 formatv(
"invalid function-simplification parameter '{0}' ", Params)
1084 "MemorySSAPrinterPass");
1089 "SpeculativeExecutionPass");
1094 while (!Params.
empty()) {
1096 std::tie(ParamName, Params) = Params.
split(
';');
1101 return make_error<StringError>(
1102 formatv(
"invalid MemProfUse pass parameter '{0}' ", ParamName).str(),
1111 "StructuralHashPrinterPass");
1116 "WinEHPreparePass");
1121 while (!Params.
empty()) {
1123 std::tie(ParamName, Params) = Params.
split(
';');
1126 if (ParamName ==
"group-by-use")
1128 else if (ParamName ==
"ignore-single-use")
1130 else if (ParamName ==
"merge-const")
1132 else if (ParamName ==
"merge-external")
1136 return make_error<StringError>(
1137 formatv(
"invalid GlobalMergePass parameter '{0}' ", ParamName)
1147 while (!Params.
empty()) {
1149 std::tie(ParamName, Params) = Params.
split(
';');
1154 return make_error<StringError>(
1155 formatv(
"invalid Internalize pass parameter '{0}' ", ParamName).str(),
1168 return Name.starts_with(
"default") ||
Name.starts_with(
"thinlto") ||
1169 Name.starts_with(
"lto");
1180template <
typename PassManagerT,
typename CallbacksT>
1182 if (!Callbacks.empty()) {
1183 PassManagerT DummyPM;
1184 for (
auto &CB : Callbacks)
1185 if (CB(
Name, DummyPM, {}))
1191template <
typename CallbacksT>
1197 StringRef NameNoBracket =
Name.take_until([](
char C) {
return C ==
'<'; });
1200 if (
Name ==
"module")
1202 if (
Name ==
"cgscc")
1204 if (NameNoBracket ==
"function")
1206 if (
Name ==
"coro-cond")
1213#define MODULE_PASS(NAME, CREATE_PASS) \
1216#define MODULE_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1217 if (PassBuilder::checkParametrizedPassName(Name, NAME)) \
1219#define MODULE_ANALYSIS(NAME, CREATE_PASS) \
1220 if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
1222#include "PassRegistry.def"
1224 return callbacksAcceptPassName<ModulePassManager>(
Name, Callbacks);
1227template <
typename CallbacksT>
1230 StringRef NameNoBracket =
Name.take_until([](
char C) {
return C ==
'<'; });
1231 if (
Name ==
"cgscc")
1233 if (NameNoBracket ==
"function")
1242#define CGSCC_PASS(NAME, CREATE_PASS) \
1245#define CGSCC_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1246 if (PassBuilder::checkParametrizedPassName(Name, NAME)) \
1248#define CGSCC_ANALYSIS(NAME, CREATE_PASS) \
1249 if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
1251#include "PassRegistry.def"
1253 return callbacksAcceptPassName<CGSCCPassManager>(
Name, Callbacks);
1256template <
typename CallbacksT>
1259 StringRef NameNoBracket =
Name.take_until([](
char C) {
return C ==
'<'; });
1260 if (NameNoBracket ==
"function")
1262 if (
Name ==
"loop" ||
Name ==
"loop-mssa" ||
Name ==
"machine-function")
1269#define FUNCTION_PASS(NAME, CREATE_PASS) \
1272#define FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1273 if (PassBuilder::checkParametrizedPassName(Name, NAME)) \
1275#define FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
1276 if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
1278#include "PassRegistry.def"
1280 return callbacksAcceptPassName<FunctionPassManager>(
Name, Callbacks);
1283template <
typename CallbacksT>
1286 if (
Name ==
"machine-function")
1293#define MACHINE_FUNCTION_PASS(NAME, CREATE_PASS) \
1296#define MACHINE_FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
1297 if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
1300#include "llvm/Passes/MachinePassRegistry.def"
1302 return callbacksAcceptPassName<MachineFunctionPassManager>(
Name, Callbacks);
1305template <
typename CallbacksT>
1307 bool &UseMemorySSA) {
1308 UseMemorySSA =
false;
1315 UseMemorySSA =
true;
1319#define LOOPNEST_PASS(NAME, CREATE_PASS) \
1322#include "PassRegistry.def"
1324 return callbacksAcceptPassName<LoopPassManager>(
Name, Callbacks);
1327template <
typename CallbacksT>
1329 bool &UseMemorySSA) {
1330 UseMemorySSA =
false;
1337 UseMemorySSA =
true;
1341#define LOOP_PASS(NAME, CREATE_PASS) \
1344#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1345 if (PassBuilder::checkParametrizedPassName(Name, NAME)) \
1347#define LOOP_ANALYSIS(NAME, CREATE_PASS) \
1348 if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
1350#include "PassRegistry.def"
1352 return callbacksAcceptPassName<LoopPassManager>(
Name, Callbacks);
1355std::optional<std::vector<PassBuilder::PipelineElement>>
1356PassBuilder::parsePipelineText(
StringRef Text) {
1357 std::vector<PipelineElement> ResultPipeline;
1362 std::vector<PipelineElement> &Pipeline = *PipelineStack.
back();
1363 size_t Pos =
Text.find_first_of(
",()");
1364 Pipeline.push_back({
Text.substr(0, Pos), {}});
1367 if (Pos ==
Text.npos)
1370 char Sep =
Text[Pos];
1378 PipelineStack.
push_back(&Pipeline.back().InnerPipeline);
1382 assert(Sep ==
')' &&
"Bogus separator!");
1387 if (PipelineStack.
size() == 1)
1388 return std::nullopt;
1391 }
while (
Text.consume_front(
")"));
1399 if (!
Text.consume_front(
","))
1400 return std::nullopt;
1403 if (PipelineStack.
size() > 1)
1405 return std::nullopt;
1407 assert(PipelineStack.
back() == &ResultPipeline &&
1408 "Wrong pipeline at the bottom of the stack!");
1409 return {std::move(ResultPipeline)};
1413 const PipelineElement &E) {
1414 auto &
Name = E.Name;
1415 auto &InnerPipeline = E.InnerPipeline;
1418 if (!InnerPipeline.empty()) {
1419 if (
Name ==
"module") {
1421 if (
auto Err = parseModulePassPipeline(NestedMPM, InnerPipeline))
1426 if (
Name ==
"coro-cond") {
1428 if (
auto Err = parseModulePassPipeline(NestedMPM, InnerPipeline))
1433 if (
Name ==
"cgscc") {
1435 if (
auto Err = parseCGSCCPassPipeline(CGPM, InnerPipeline))
1442 return make_error<StringError>(
1443 "cannot have a no-rerun module to function adaptor",
1446 if (
auto Err = parseFunctionPassPipeline(FPM, InnerPipeline))
1454 if (
auto Err = parseModulePassPipeline(NestedMPM, InnerPipeline))
1460 for (
auto &
C : ModulePipelineParsingCallbacks)
1465 return make_error<StringError>(
1466 formatv(
"invalid use of '{0}' pass as module pipeline",
Name).str(),
1475 return make_error<StringError>(
1476 formatv(
"unknown default pipeline alias '{0}'",
Name).str(),
1479 assert(Matches.
size() == 3 &&
"Must capture two matched strings!");
1491 if (Matches[1] ==
"default") {
1493 }
else if (Matches[1] ==
"thinlto-pre-link") {
1495 }
else if (Matches[1] ==
"thinlto") {
1497 }
else if (Matches[1] ==
"lto-pre-link") {
1506 assert(Matches[1] ==
"lto" &&
"Not one of the matched options!");
1513#define MODULE_PASS(NAME, CREATE_PASS) \
1514 if (Name == NAME) { \
1515 MPM.addPass(CREATE_PASS); \
1516 return Error::success(); \
1518#define MODULE_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1519 if (checkParametrizedPassName(Name, NAME)) { \
1520 auto Params = parsePassParameters(PARSER, Name, NAME); \
1522 return Params.takeError(); \
1523 MPM.addPass(CREATE_PASS(Params.get())); \
1524 return Error::success(); \
1526#define MODULE_ANALYSIS(NAME, CREATE_PASS) \
1527 if (Name == "require<" NAME ">") { \
1529 RequireAnalysisPass< \
1530 std::remove_reference_t<decltype(CREATE_PASS)>, Module>()); \
1531 return Error::success(); \
1533 if (Name == "invalidate<" NAME ">") { \
1534 MPM.addPass(InvalidateAnalysisPass< \
1535 std::remove_reference_t<decltype(CREATE_PASS)>>()); \
1536 return Error::success(); \
1538#define CGSCC_PASS(NAME, CREATE_PASS) \
1539 if (Name == NAME) { \
1540 MPM.addPass(createModuleToPostOrderCGSCCPassAdaptor(CREATE_PASS)); \
1541 return Error::success(); \
1543#define CGSCC_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1544 if (checkParametrizedPassName(Name, NAME)) { \
1545 auto Params = parsePassParameters(PARSER, Name, NAME); \
1547 return Params.takeError(); \
1549 createModuleToPostOrderCGSCCPassAdaptor(CREATE_PASS(Params.get()))); \
1550 return Error::success(); \
1552#define FUNCTION_PASS(NAME, CREATE_PASS) \
1553 if (Name == NAME) { \
1554 MPM.addPass(createModuleToFunctionPassAdaptor(CREATE_PASS)); \
1555 return Error::success(); \
1557#define FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1558 if (checkParametrizedPassName(Name, NAME)) { \
1559 auto Params = parsePassParameters(PARSER, Name, NAME); \
1561 return Params.takeError(); \
1562 MPM.addPass(createModuleToFunctionPassAdaptor(CREATE_PASS(Params.get()))); \
1563 return Error::success(); \
1565#define LOOPNEST_PASS(NAME, CREATE_PASS) \
1566 if (Name == NAME) { \
1567 MPM.addPass(createModuleToFunctionPassAdaptor( \
1568 createFunctionToLoopPassAdaptor(CREATE_PASS, false, false))); \
1569 return Error::success(); \
1571#define LOOP_PASS(NAME, CREATE_PASS) \
1572 if (Name == NAME) { \
1573 MPM.addPass(createModuleToFunctionPassAdaptor( \
1574 createFunctionToLoopPassAdaptor(CREATE_PASS, false, false))); \
1575 return Error::success(); \
1577#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1578 if (checkParametrizedPassName(Name, NAME)) { \
1579 auto Params = parsePassParameters(PARSER, Name, NAME); \
1581 return Params.takeError(); \
1583 createModuleToFunctionPassAdaptor(createFunctionToLoopPassAdaptor( \
1584 CREATE_PASS(Params.get()), false, false))); \
1585 return Error::success(); \
1587#include "PassRegistry.def"
1589 for (
auto &
C : ModulePipelineParsingCallbacks)
1592 return make_error<StringError>(
1598 const PipelineElement &E) {
1599 auto &
Name = E.Name;
1600 auto &InnerPipeline = E.InnerPipeline;
1603 if (!InnerPipeline.empty()) {
1604 if (
Name ==
"cgscc") {
1606 if (
auto Err = parseCGSCCPassPipeline(NestedCGPM, InnerPipeline))
1609 CGPM.
addPass(std::move(NestedCGPM));
1614 if (
auto Err = parseFunctionPassPipeline(FPM, InnerPipeline))
1618 std::move(FPM), Params->first, Params->second));
1623 if (
auto Err = parseCGSCCPassPipeline(NestedCGPM, InnerPipeline))
1630 if (
auto Err = parseCGSCCPassPipeline(NestedCGPM, InnerPipeline))
1637 for (
auto &
C : CGSCCPipelineParsingCallbacks)
1638 if (
C(
Name, CGPM, InnerPipeline))
1642 return make_error<StringError>(
1643 formatv(
"invalid use of '{0}' pass as cgscc pipeline",
Name).str(),
1648#define CGSCC_PASS(NAME, CREATE_PASS) \
1649 if (Name == NAME) { \
1650 CGPM.addPass(CREATE_PASS); \
1651 return Error::success(); \
1653#define CGSCC_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1654 if (checkParametrizedPassName(Name, NAME)) { \
1655 auto Params = parsePassParameters(PARSER, Name, NAME); \
1657 return Params.takeError(); \
1658 CGPM.addPass(CREATE_PASS(Params.get())); \
1659 return Error::success(); \
1661#define CGSCC_ANALYSIS(NAME, CREATE_PASS) \
1662 if (Name == "require<" NAME ">") { \
1663 CGPM.addPass(RequireAnalysisPass< \
1664 std::remove_reference_t<decltype(CREATE_PASS)>, \
1665 LazyCallGraph::SCC, CGSCCAnalysisManager, LazyCallGraph &, \
1666 CGSCCUpdateResult &>()); \
1667 return Error::success(); \
1669 if (Name == "invalidate<" NAME ">") { \
1670 CGPM.addPass(InvalidateAnalysisPass< \
1671 std::remove_reference_t<decltype(CREATE_PASS)>>()); \
1672 return Error::success(); \
1674#define FUNCTION_PASS(NAME, CREATE_PASS) \
1675 if (Name == NAME) { \
1676 CGPM.addPass(createCGSCCToFunctionPassAdaptor(CREATE_PASS)); \
1677 return Error::success(); \
1679#define FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1680 if (checkParametrizedPassName(Name, NAME)) { \
1681 auto Params = parsePassParameters(PARSER, Name, NAME); \
1683 return Params.takeError(); \
1684 CGPM.addPass(createCGSCCToFunctionPassAdaptor(CREATE_PASS(Params.get()))); \
1685 return Error::success(); \
1687#define LOOPNEST_PASS(NAME, CREATE_PASS) \
1688 if (Name == NAME) { \
1689 CGPM.addPass(createCGSCCToFunctionPassAdaptor( \
1690 createFunctionToLoopPassAdaptor(CREATE_PASS, false, false))); \
1691 return Error::success(); \
1693#define LOOP_PASS(NAME, CREATE_PASS) \
1694 if (Name == NAME) { \
1695 CGPM.addPass(createCGSCCToFunctionPassAdaptor( \
1696 createFunctionToLoopPassAdaptor(CREATE_PASS, false, false))); \
1697 return Error::success(); \
1699#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1700 if (checkParametrizedPassName(Name, NAME)) { \
1701 auto Params = parsePassParameters(PARSER, Name, NAME); \
1703 return Params.takeError(); \
1705 createCGSCCToFunctionPassAdaptor(createFunctionToLoopPassAdaptor( \
1706 CREATE_PASS(Params.get()), false, false))); \
1707 return Error::success(); \
1709#include "PassRegistry.def"
1711 for (
auto &
C : CGSCCPipelineParsingCallbacks)
1712 if (
C(
Name, CGPM, InnerPipeline))
1714 return make_error<StringError>(
1720 const PipelineElement &E) {
1721 auto &
Name = E.Name;
1722 auto &InnerPipeline = E.InnerPipeline;
1725 if (!InnerPipeline.empty()) {
1726 if (
Name ==
"function") {
1728 if (
auto Err = parseFunctionPassPipeline(NestedFPM, InnerPipeline))
1731 FPM.
addPass(std::move(NestedFPM));
1734 if (
Name ==
"loop" ||
Name ==
"loop-mssa") {
1736 if (
auto Err = parseLoopPassPipeline(LPM, InnerPipeline))
1739 bool UseMemorySSA = (
Name ==
"loop-mssa");
1741 return Pipeline.Name.contains(
"simple-loop-unswitch");
1743 bool UseBPI =
llvm::any_of(InnerPipeline, [](
auto Pipeline) {
1744 return Pipeline.Name ==
"loop-predication";
1752 if (
auto Err = parseFunctionPassPipeline(NestedFPM, InnerPipeline))
1757 if (
Name ==
"machine-function") {
1759 if (
auto Err = parseMachinePassPipeline(MFPM, InnerPipeline))
1765 for (
auto &
C : FunctionPipelineParsingCallbacks)
1766 if (
C(
Name, FPM, InnerPipeline))
1770 return make_error<StringError>(
1771 formatv(
"invalid use of '{0}' pass as function pipeline",
Name).str(),
1776#define FUNCTION_PASS(NAME, CREATE_PASS) \
1777 if (Name == NAME) { \
1778 FPM.addPass(CREATE_PASS); \
1779 return Error::success(); \
1781#define FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1782 if (checkParametrizedPassName(Name, NAME)) { \
1783 auto Params = parsePassParameters(PARSER, Name, NAME); \
1785 return Params.takeError(); \
1786 FPM.addPass(CREATE_PASS(Params.get())); \
1787 return Error::success(); \
1789#define FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
1790 if (Name == "require<" NAME ">") { \
1792 RequireAnalysisPass< \
1793 std::remove_reference_t<decltype(CREATE_PASS)>, Function>()); \
1794 return Error::success(); \
1796 if (Name == "invalidate<" NAME ">") { \
1797 FPM.addPass(InvalidateAnalysisPass< \
1798 std::remove_reference_t<decltype(CREATE_PASS)>>()); \
1799 return Error::success(); \
1805#define LOOPNEST_PASS(NAME, CREATE_PASS) \
1806 if (Name == NAME) { \
1807 FPM.addPass(createFunctionToLoopPassAdaptor(CREATE_PASS, false, false)); \
1808 return Error::success(); \
1810#define LOOP_PASS(NAME, CREATE_PASS) \
1811 if (Name == NAME) { \
1812 FPM.addPass(createFunctionToLoopPassAdaptor(CREATE_PASS, false, false)); \
1813 return Error::success(); \
1815#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1816 if (checkParametrizedPassName(Name, NAME)) { \
1817 auto Params = parsePassParameters(PARSER, Name, NAME); \
1819 return Params.takeError(); \
1820 FPM.addPass(createFunctionToLoopPassAdaptor(CREATE_PASS(Params.get()), \
1822 return Error::success(); \
1824#include "PassRegistry.def"
1826 for (
auto &
C : FunctionPipelineParsingCallbacks)
1827 if (
C(
Name, FPM, InnerPipeline))
1829 return make_error<StringError>(
1830 formatv(
"unknown function pass '{0}'",
Name).str(),
1835 const PipelineElement &E) {
1837 auto &InnerPipeline = E.InnerPipeline;
1840 if (!InnerPipeline.empty()) {
1841 if (
Name ==
"loop") {
1843 if (
auto Err = parseLoopPassPipeline(NestedLPM, InnerPipeline))
1846 LPM.
addPass(std::move(NestedLPM));
1851 if (
auto Err = parseLoopPassPipeline(NestedLPM, InnerPipeline))
1857 for (
auto &
C : LoopPipelineParsingCallbacks)
1858 if (
C(
Name, LPM, InnerPipeline))
1862 return make_error<StringError>(
1863 formatv(
"invalid use of '{0}' pass as loop pipeline",
Name).str(),
1868#define LOOPNEST_PASS(NAME, CREATE_PASS) \
1869 if (Name == NAME) { \
1870 LPM.addPass(CREATE_PASS); \
1871 return Error::success(); \
1873#define LOOP_PASS(NAME, CREATE_PASS) \
1874 if (Name == NAME) { \
1875 LPM.addPass(CREATE_PASS); \
1876 return Error::success(); \
1878#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1879 if (checkParametrizedPassName(Name, NAME)) { \
1880 auto Params = parsePassParameters(PARSER, Name, NAME); \
1882 return Params.takeError(); \
1883 LPM.addPass(CREATE_PASS(Params.get())); \
1884 return Error::success(); \
1886#define LOOP_ANALYSIS(NAME, CREATE_PASS) \
1887 if (Name == "require<" NAME ">") { \
1888 LPM.addPass(RequireAnalysisPass< \
1889 std::remove_reference_t<decltype(CREATE_PASS)>, Loop, \
1890 LoopAnalysisManager, LoopStandardAnalysisResults &, \
1892 return Error::success(); \
1894 if (Name == "invalidate<" NAME ">") { \
1895 LPM.addPass(InvalidateAnalysisPass< \
1896 std::remove_reference_t<decltype(CREATE_PASS)>>()); \
1897 return Error::success(); \
1899#include "PassRegistry.def"
1901 for (
auto &
C : LoopPipelineParsingCallbacks)
1902 if (
C(
Name, LPM, InnerPipeline))
1904 return make_error<StringError>(
formatv(
"unknown loop pass '{0}'",
Name).str(),
1909 const PipelineElement &E) {
1911 if (!E.InnerPipeline.empty())
1912 return make_error<StringError>(
"invalid pipeline",
1915#define MACHINE_MODULE_PASS(NAME, CREATE_PASS) \
1916 if (Name == NAME) { \
1917 MFPM.addPass(CREATE_PASS); \
1918 return Error::success(); \
1920#define MACHINE_FUNCTION_PASS(NAME, CREATE_PASS) \
1921 if (Name == NAME) { \
1922 MFPM.addPass(CREATE_PASS); \
1923 return Error::success(); \
1925#include "llvm/Passes/MachinePassRegistry.def"
1927 for (
auto &
C : MachineFunctionPipelineParsingCallbacks)
1928 if (
C(
Name, MFPM, E.InnerPipeline))
1930 return make_error<StringError>(
1931 formatv(
"unknown machine pass '{0}'",
Name).str(),
1936#define MODULE_ALIAS_ANALYSIS(NAME, CREATE_PASS) \
1937 if (Name == NAME) { \
1938 AA.registerModuleAnalysis< \
1939 std::remove_reference_t<decltype(CREATE_PASS)>>(); \
1942#define FUNCTION_ALIAS_ANALYSIS(NAME, CREATE_PASS) \
1943 if (Name == NAME) { \
1944 AA.registerFunctionAnalysis< \
1945 std::remove_reference_t<decltype(CREATE_PASS)>>(); \
1948#include "PassRegistry.def"
1950 for (
auto &
C : AAParsingCallbacks)
1956Error PassBuilder::parseMachinePassPipeline(
1958 for (
const auto &Element : Pipeline) {
1959 if (
auto Err = parseMachinePass(MFPM, Element))
1967 for (
const auto &Element : Pipeline) {
1968 if (
auto Err = parseLoopPass(LPM, Element))
1974Error PassBuilder::parseFunctionPassPipeline(
1976 for (
const auto &Element : Pipeline) {
1977 if (
auto Err = parseFunctionPass(FPM, Element))
1985 for (
const auto &Element : Pipeline) {
1986 if (
auto Err = parseCGSCCPass(CGPM, Element))
2018 for (
const auto &Element : Pipeline) {
2019 if (
auto Err = parseModulePass(
MPM, Element))
2030 auto Pipeline = parsePipelineText(PipelineText);
2031 if (!Pipeline || Pipeline->empty())
2032 return make_error<StringError>(
2033 formatv(
"invalid pipeline '{0}'", PipelineText).str(),
2043 Pipeline = {{
"cgscc", std::move(*Pipeline)}};
2045 FunctionPipelineParsingCallbacks)) {
2046 Pipeline = {{
"function", std::move(*Pipeline)}};
2049 Pipeline = {{
"function", {{UseMemorySSA ?
"loop-mssa" :
"loop",
2050 std::move(*Pipeline)}}}};
2051 }
else if (
isLoopPassName(FirstName, LoopPipelineParsingCallbacks,
2053 Pipeline = {{
"function", {{UseMemorySSA ?
"loop-mssa" :
"loop",
2054 std::move(*Pipeline)}}}};
2056 FirstName, MachineFunctionPipelineParsingCallbacks)) {
2057 Pipeline = {{
"function", {{
"machine-function", std::move(*Pipeline)}}}};
2059 for (
auto &
C : TopLevelPipelineParsingCallbacks)
2060 if (
C(
MPM, *Pipeline))
2064 auto &InnerPipeline = Pipeline->front().InnerPipeline;
2065 return make_error<StringError>(
2066 formatv(
"unknown {0} name '{1}'",
2067 (InnerPipeline.empty() ?
"pass" :
"pipeline"), FirstName)
2073 if (
auto Err = parseModulePassPipeline(
MPM, *Pipeline))
2081 auto Pipeline = parsePipelineText(PipelineText);
2082 if (!Pipeline || Pipeline->empty())
2083 return make_error<StringError>(
2084 formatv(
"invalid pipeline '{0}'", PipelineText).str(),
2089 return make_error<StringError>(
2090 formatv(
"unknown cgscc pass '{0}' in pipeline '{1}'", FirstName,
2095 if (
auto Err = parseCGSCCPassPipeline(CGPM, *Pipeline))
2104 auto Pipeline = parsePipelineText(PipelineText);
2105 if (!Pipeline || Pipeline->empty())
2106 return make_error<StringError>(
2107 formatv(
"invalid pipeline '{0}'", PipelineText).str(),
2112 return make_error<StringError>(
2113 formatv(
"unknown function pass '{0}' in pipeline '{1}'", FirstName,
2118 if (
auto Err = parseFunctionPassPipeline(FPM, *Pipeline))
2126 auto Pipeline = parsePipelineText(PipelineText);
2127 if (!Pipeline || Pipeline->empty())
2128 return make_error<StringError>(
2129 formatv(
"invalid pipeline '{0}'", PipelineText).str(),
2132 if (
auto Err = parseLoopPassPipeline(CGPM, *Pipeline))
2140 auto Pipeline = parsePipelineText(PipelineText);
2141 if (!Pipeline || Pipeline->empty())
2142 return make_error<StringError>(
2143 formatv(
"invalid machine pass pipeline '{0}'", PipelineText).str(),
2146 if (
auto Err = parseMachinePassPipeline(MFPM, *Pipeline))
2155 if (PipelineText ==
"default") {
2160 while (!PipelineText.
empty()) {
2162 std::tie(
Name, PipelineText) = PipelineText.
split(
',');
2163 if (!parseAAPassName(AA,
Name))
2164 return make_error<StringError>(
2165 formatv(
"unknown alias analysis name '{0}'",
Name).str(),
2177 OS <<
" " <<
PassName <<
"<" << Params <<
">\n";
2183 OS <<
"Module passes:\n";
2184#define MODULE_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2185#include "PassRegistry.def"
2187 OS <<
"Module passes with params:\n";
2188#define MODULE_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
2189 printPassName(NAME, PARAMS, OS);
2190#include "PassRegistry.def"
2192 OS <<
"Module analyses:\n";
2193#define MODULE_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2194#include "PassRegistry.def"
2196 OS <<
"Module alias analyses:\n";
2197#define MODULE_ALIAS_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2198#include "PassRegistry.def"
2200 OS <<
"CGSCC passes:\n";
2201#define CGSCC_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2202#include "PassRegistry.def"
2204 OS <<
"CGSCC passes with params:\n";
2205#define CGSCC_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
2206 printPassName(NAME, PARAMS, OS);
2207#include "PassRegistry.def"
2209 OS <<
"CGSCC analyses:\n";
2210#define CGSCC_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2211#include "PassRegistry.def"
2213 OS <<
"Function passes:\n";
2214#define FUNCTION_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2215#include "PassRegistry.def"
2217 OS <<
"Function passes with params:\n";
2218#define FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
2219 printPassName(NAME, PARAMS, OS);
2220#include "PassRegistry.def"
2222 OS <<
"Function analyses:\n";
2223#define FUNCTION_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2224#include "PassRegistry.def"
2226 OS <<
"Function alias analyses:\n";
2227#define FUNCTION_ALIAS_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2228#include "PassRegistry.def"
2230 OS <<
"LoopNest passes:\n";
2231#define LOOPNEST_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2232#include "PassRegistry.def"
2234 OS <<
"Loop passes:\n";
2235#define LOOP_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2236#include "PassRegistry.def"
2238 OS <<
"Loop passes with params:\n";
2239#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
2240 printPassName(NAME, PARAMS, OS);
2241#include "PassRegistry.def"
2243 OS <<
"Loop analyses:\n";
2244#define LOOP_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2245#include "PassRegistry.def"
2247 OS <<
"Machine module passes (WIP):\n";
2248#define MACHINE_MODULE_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2249#include "llvm/Passes/MachinePassRegistry.def"
2251 OS <<
"Machine function passes (WIP):\n";
2252#define MACHINE_FUNCTION_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2253#include "llvm/Passes/MachinePassRegistry.def"
2255 OS <<
"Machine function analyses (WIP):\n";
2256#define MACHINE_FUNCTION_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2257#include "llvm/Passes/MachinePassRegistry.def"
2263 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.