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)
1150 return Name.starts_with(
"default") ||
Name.starts_with(
"thinlto") ||
1151 Name.starts_with(
"lto");
1162template <
typename PassManagerT,
typename CallbacksT>
1164 if (!Callbacks.empty()) {
1165 PassManagerT DummyPM;
1166 for (
auto &CB : Callbacks)
1167 if (CB(
Name, DummyPM, {}))
1173template <
typename CallbacksT>
1179 StringRef NameNoBracket =
Name.take_until([](
char C) {
return C ==
'<'; });
1182 if (
Name ==
"module")
1184 if (
Name ==
"cgscc")
1186 if (NameNoBracket ==
"function")
1188 if (
Name ==
"coro-cond")
1195#define MODULE_PASS(NAME, CREATE_PASS) \
1198#define MODULE_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1199 if (PassBuilder::checkParametrizedPassName(Name, NAME)) \
1201#define MODULE_ANALYSIS(NAME, CREATE_PASS) \
1202 if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
1204#include "PassRegistry.def"
1206 return callbacksAcceptPassName<ModulePassManager>(
Name, Callbacks);
1209template <
typename CallbacksT>
1212 StringRef NameNoBracket =
Name.take_until([](
char C) {
return C ==
'<'; });
1213 if (
Name ==
"cgscc")
1215 if (NameNoBracket ==
"function")
1224#define CGSCC_PASS(NAME, CREATE_PASS) \
1227#define CGSCC_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1228 if (PassBuilder::checkParametrizedPassName(Name, NAME)) \
1230#define CGSCC_ANALYSIS(NAME, CREATE_PASS) \
1231 if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
1233#include "PassRegistry.def"
1235 return callbacksAcceptPassName<CGSCCPassManager>(
Name, Callbacks);
1238template <
typename CallbacksT>
1241 StringRef NameNoBracket =
Name.take_until([](
char C) {
return C ==
'<'; });
1242 if (NameNoBracket ==
"function")
1244 if (
Name ==
"loop" ||
Name ==
"loop-mssa" ||
Name ==
"machine-function")
1251#define FUNCTION_PASS(NAME, CREATE_PASS) \
1254#define FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1255 if (PassBuilder::checkParametrizedPassName(Name, NAME)) \
1257#define FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
1258 if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
1260#include "PassRegistry.def"
1262 return callbacksAcceptPassName<FunctionPassManager>(
Name, Callbacks);
1265template <
typename CallbacksT>
1268 if (
Name ==
"machine-function")
1275#define MACHINE_FUNCTION_PASS(NAME, CREATE_PASS) \
1278#define MACHINE_FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
1279 if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
1282#include "llvm/Passes/MachinePassRegistry.def"
1284 return callbacksAcceptPassName<MachineFunctionPassManager>(
Name, Callbacks);
1287template <
typename CallbacksT>
1289 bool &UseMemorySSA) {
1290 UseMemorySSA =
false;
1297 UseMemorySSA =
true;
1301#define LOOPNEST_PASS(NAME, CREATE_PASS) \
1304#include "PassRegistry.def"
1306 return callbacksAcceptPassName<LoopPassManager>(
Name, Callbacks);
1309template <
typename CallbacksT>
1311 bool &UseMemorySSA) {
1312 UseMemorySSA =
false;
1319 UseMemorySSA =
true;
1323#define LOOP_PASS(NAME, CREATE_PASS) \
1326#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1327 if (PassBuilder::checkParametrizedPassName(Name, NAME)) \
1329#define LOOP_ANALYSIS(NAME, CREATE_PASS) \
1330 if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
1332#include "PassRegistry.def"
1334 return callbacksAcceptPassName<LoopPassManager>(
Name, Callbacks);
1337std::optional<std::vector<PassBuilder::PipelineElement>>
1338PassBuilder::parsePipelineText(
StringRef Text) {
1339 std::vector<PipelineElement> ResultPipeline;
1344 std::vector<PipelineElement> &Pipeline = *PipelineStack.
back();
1345 size_t Pos =
Text.find_first_of(
",()");
1346 Pipeline.push_back({
Text.substr(0, Pos), {}});
1349 if (Pos ==
Text.npos)
1352 char Sep =
Text[Pos];
1360 PipelineStack.
push_back(&Pipeline.back().InnerPipeline);
1364 assert(Sep ==
')' &&
"Bogus separator!");
1369 if (PipelineStack.
size() == 1)
1370 return std::nullopt;
1373 }
while (
Text.consume_front(
")"));
1381 if (!
Text.consume_front(
","))
1382 return std::nullopt;
1385 if (PipelineStack.
size() > 1)
1387 return std::nullopt;
1389 assert(PipelineStack.
back() == &ResultPipeline &&
1390 "Wrong pipeline at the bottom of the stack!");
1391 return {std::move(ResultPipeline)};
1395 const PipelineElement &E) {
1396 auto &
Name = E.Name;
1397 auto &InnerPipeline = E.InnerPipeline;
1400 if (!InnerPipeline.empty()) {
1401 if (
Name ==
"module") {
1403 if (
auto Err = parseModulePassPipeline(NestedMPM, InnerPipeline))
1408 if (
Name ==
"coro-cond") {
1410 if (
auto Err = parseModulePassPipeline(NestedMPM, InnerPipeline))
1415 if (
Name ==
"cgscc") {
1417 if (
auto Err = parseCGSCCPassPipeline(CGPM, InnerPipeline))
1424 return make_error<StringError>(
1425 "cannot have a no-rerun module to function adaptor",
1428 if (
auto Err = parseFunctionPassPipeline(FPM, InnerPipeline))
1436 if (
auto Err = parseModulePassPipeline(NestedMPM, InnerPipeline))
1442 for (
auto &
C : ModulePipelineParsingCallbacks)
1447 return make_error<StringError>(
1448 formatv(
"invalid use of '{0}' pass as module pipeline",
Name).str(),
1457 return make_error<StringError>(
1458 formatv(
"unknown default pipeline alias '{0}'",
Name).str(),
1461 assert(Matches.
size() == 3 &&
"Must capture two matched strings!");
1473 if (Matches[1] ==
"default") {
1475 }
else if (Matches[1] ==
"thinlto-pre-link") {
1477 }
else if (Matches[1] ==
"thinlto") {
1479 }
else if (Matches[1] ==
"lto-pre-link") {
1488 assert(Matches[1] ==
"lto" &&
"Not one of the matched options!");
1495#define MODULE_PASS(NAME, CREATE_PASS) \
1496 if (Name == NAME) { \
1497 MPM.addPass(CREATE_PASS); \
1498 return Error::success(); \
1500#define MODULE_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1501 if (checkParametrizedPassName(Name, NAME)) { \
1502 auto Params = parsePassParameters(PARSER, Name, NAME); \
1504 return Params.takeError(); \
1505 MPM.addPass(CREATE_PASS(Params.get())); \
1506 return Error::success(); \
1508#define MODULE_ANALYSIS(NAME, CREATE_PASS) \
1509 if (Name == "require<" NAME ">") { \
1511 RequireAnalysisPass< \
1512 std::remove_reference_t<decltype(CREATE_PASS)>, Module>()); \
1513 return Error::success(); \
1515 if (Name == "invalidate<" NAME ">") { \
1516 MPM.addPass(InvalidateAnalysisPass< \
1517 std::remove_reference_t<decltype(CREATE_PASS)>>()); \
1518 return Error::success(); \
1520#define CGSCC_PASS(NAME, CREATE_PASS) \
1521 if (Name == NAME) { \
1522 MPM.addPass(createModuleToPostOrderCGSCCPassAdaptor(CREATE_PASS)); \
1523 return Error::success(); \
1525#define CGSCC_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1526 if (checkParametrizedPassName(Name, NAME)) { \
1527 auto Params = parsePassParameters(PARSER, Name, NAME); \
1529 return Params.takeError(); \
1531 createModuleToPostOrderCGSCCPassAdaptor(CREATE_PASS(Params.get()))); \
1532 return Error::success(); \
1534#define FUNCTION_PASS(NAME, CREATE_PASS) \
1535 if (Name == NAME) { \
1536 MPM.addPass(createModuleToFunctionPassAdaptor(CREATE_PASS)); \
1537 return Error::success(); \
1539#define FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1540 if (checkParametrizedPassName(Name, NAME)) { \
1541 auto Params = parsePassParameters(PARSER, Name, NAME); \
1543 return Params.takeError(); \
1544 MPM.addPass(createModuleToFunctionPassAdaptor(CREATE_PASS(Params.get()))); \
1545 return Error::success(); \
1547#define LOOPNEST_PASS(NAME, CREATE_PASS) \
1548 if (Name == NAME) { \
1549 MPM.addPass(createModuleToFunctionPassAdaptor( \
1550 createFunctionToLoopPassAdaptor(CREATE_PASS, false, false))); \
1551 return Error::success(); \
1553#define LOOP_PASS(NAME, CREATE_PASS) \
1554 if (Name == NAME) { \
1555 MPM.addPass(createModuleToFunctionPassAdaptor( \
1556 createFunctionToLoopPassAdaptor(CREATE_PASS, false, false))); \
1557 return Error::success(); \
1559#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1560 if (checkParametrizedPassName(Name, NAME)) { \
1561 auto Params = parsePassParameters(PARSER, Name, NAME); \
1563 return Params.takeError(); \
1565 createModuleToFunctionPassAdaptor(createFunctionToLoopPassAdaptor( \
1566 CREATE_PASS(Params.get()), false, false))); \
1567 return Error::success(); \
1569#include "PassRegistry.def"
1571 for (
auto &
C : ModulePipelineParsingCallbacks)
1574 return make_error<StringError>(
1580 const PipelineElement &E) {
1581 auto &
Name = E.Name;
1582 auto &InnerPipeline = E.InnerPipeline;
1585 if (!InnerPipeline.empty()) {
1586 if (
Name ==
"cgscc") {
1588 if (
auto Err = parseCGSCCPassPipeline(NestedCGPM, InnerPipeline))
1591 CGPM.
addPass(std::move(NestedCGPM));
1596 if (
auto Err = parseFunctionPassPipeline(FPM, InnerPipeline))
1600 std::move(FPM), Params->first, Params->second));
1605 if (
auto Err = parseCGSCCPassPipeline(NestedCGPM, InnerPipeline))
1612 if (
auto Err = parseCGSCCPassPipeline(NestedCGPM, InnerPipeline))
1619 for (
auto &
C : CGSCCPipelineParsingCallbacks)
1620 if (
C(
Name, CGPM, InnerPipeline))
1624 return make_error<StringError>(
1625 formatv(
"invalid use of '{0}' pass as cgscc pipeline",
Name).str(),
1630#define CGSCC_PASS(NAME, CREATE_PASS) \
1631 if (Name == NAME) { \
1632 CGPM.addPass(CREATE_PASS); \
1633 return Error::success(); \
1635#define CGSCC_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1636 if (checkParametrizedPassName(Name, NAME)) { \
1637 auto Params = parsePassParameters(PARSER, Name, NAME); \
1639 return Params.takeError(); \
1640 CGPM.addPass(CREATE_PASS(Params.get())); \
1641 return Error::success(); \
1643#define CGSCC_ANALYSIS(NAME, CREATE_PASS) \
1644 if (Name == "require<" NAME ">") { \
1645 CGPM.addPass(RequireAnalysisPass< \
1646 std::remove_reference_t<decltype(CREATE_PASS)>, \
1647 LazyCallGraph::SCC, CGSCCAnalysisManager, LazyCallGraph &, \
1648 CGSCCUpdateResult &>()); \
1649 return Error::success(); \
1651 if (Name == "invalidate<" NAME ">") { \
1652 CGPM.addPass(InvalidateAnalysisPass< \
1653 std::remove_reference_t<decltype(CREATE_PASS)>>()); \
1654 return Error::success(); \
1656#define FUNCTION_PASS(NAME, CREATE_PASS) \
1657 if (Name == NAME) { \
1658 CGPM.addPass(createCGSCCToFunctionPassAdaptor(CREATE_PASS)); \
1659 return Error::success(); \
1661#define FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1662 if (checkParametrizedPassName(Name, NAME)) { \
1663 auto Params = parsePassParameters(PARSER, Name, NAME); \
1665 return Params.takeError(); \
1666 CGPM.addPass(createCGSCCToFunctionPassAdaptor(CREATE_PASS(Params.get()))); \
1667 return Error::success(); \
1669#define LOOPNEST_PASS(NAME, CREATE_PASS) \
1670 if (Name == NAME) { \
1671 CGPM.addPass(createCGSCCToFunctionPassAdaptor( \
1672 createFunctionToLoopPassAdaptor(CREATE_PASS, false, false))); \
1673 return Error::success(); \
1675#define LOOP_PASS(NAME, CREATE_PASS) \
1676 if (Name == NAME) { \
1677 CGPM.addPass(createCGSCCToFunctionPassAdaptor( \
1678 createFunctionToLoopPassAdaptor(CREATE_PASS, false, false))); \
1679 return Error::success(); \
1681#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1682 if (checkParametrizedPassName(Name, NAME)) { \
1683 auto Params = parsePassParameters(PARSER, Name, NAME); \
1685 return Params.takeError(); \
1687 createCGSCCToFunctionPassAdaptor(createFunctionToLoopPassAdaptor( \
1688 CREATE_PASS(Params.get()), false, false))); \
1689 return Error::success(); \
1691#include "PassRegistry.def"
1693 for (
auto &
C : CGSCCPipelineParsingCallbacks)
1694 if (
C(
Name, CGPM, InnerPipeline))
1696 return make_error<StringError>(
1702 const PipelineElement &E) {
1703 auto &
Name = E.Name;
1704 auto &InnerPipeline = E.InnerPipeline;
1707 if (!InnerPipeline.empty()) {
1708 if (
Name ==
"function") {
1710 if (
auto Err = parseFunctionPassPipeline(NestedFPM, InnerPipeline))
1713 FPM.
addPass(std::move(NestedFPM));
1716 if (
Name ==
"loop" ||
Name ==
"loop-mssa") {
1718 if (
auto Err = parseLoopPassPipeline(LPM, InnerPipeline))
1721 bool UseMemorySSA = (
Name ==
"loop-mssa");
1723 return Pipeline.Name.contains(
"simple-loop-unswitch");
1725 bool UseBPI =
llvm::any_of(InnerPipeline, [](
auto Pipeline) {
1726 return Pipeline.Name ==
"loop-predication";
1734 if (
auto Err = parseFunctionPassPipeline(NestedFPM, InnerPipeline))
1739 if (
Name ==
"machine-function") {
1741 if (
auto Err = parseMachinePassPipeline(MFPM, InnerPipeline))
1747 for (
auto &
C : FunctionPipelineParsingCallbacks)
1748 if (
C(
Name, FPM, InnerPipeline))
1752 return make_error<StringError>(
1753 formatv(
"invalid use of '{0}' pass as function pipeline",
Name).str(),
1758#define FUNCTION_PASS(NAME, CREATE_PASS) \
1759 if (Name == NAME) { \
1760 FPM.addPass(CREATE_PASS); \
1761 return Error::success(); \
1763#define FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1764 if (checkParametrizedPassName(Name, NAME)) { \
1765 auto Params = parsePassParameters(PARSER, Name, NAME); \
1767 return Params.takeError(); \
1768 FPM.addPass(CREATE_PASS(Params.get())); \
1769 return Error::success(); \
1771#define FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
1772 if (Name == "require<" NAME ">") { \
1774 RequireAnalysisPass< \
1775 std::remove_reference_t<decltype(CREATE_PASS)>, Function>()); \
1776 return Error::success(); \
1778 if (Name == "invalidate<" NAME ">") { \
1779 FPM.addPass(InvalidateAnalysisPass< \
1780 std::remove_reference_t<decltype(CREATE_PASS)>>()); \
1781 return Error::success(); \
1787#define LOOPNEST_PASS(NAME, CREATE_PASS) \
1788 if (Name == NAME) { \
1789 FPM.addPass(createFunctionToLoopPassAdaptor(CREATE_PASS, false, false)); \
1790 return Error::success(); \
1792#define LOOP_PASS(NAME, CREATE_PASS) \
1793 if (Name == NAME) { \
1794 FPM.addPass(createFunctionToLoopPassAdaptor(CREATE_PASS, false, false)); \
1795 return Error::success(); \
1797#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1798 if (checkParametrizedPassName(Name, NAME)) { \
1799 auto Params = parsePassParameters(PARSER, Name, NAME); \
1801 return Params.takeError(); \
1802 FPM.addPass(createFunctionToLoopPassAdaptor(CREATE_PASS(Params.get()), \
1804 return Error::success(); \
1806#include "PassRegistry.def"
1808 for (
auto &
C : FunctionPipelineParsingCallbacks)
1809 if (
C(
Name, FPM, InnerPipeline))
1811 return make_error<StringError>(
1812 formatv(
"unknown function pass '{0}'",
Name).str(),
1817 const PipelineElement &E) {
1819 auto &InnerPipeline = E.InnerPipeline;
1822 if (!InnerPipeline.empty()) {
1823 if (
Name ==
"loop") {
1825 if (
auto Err = parseLoopPassPipeline(NestedLPM, InnerPipeline))
1828 LPM.
addPass(std::move(NestedLPM));
1833 if (
auto Err = parseLoopPassPipeline(NestedLPM, InnerPipeline))
1839 for (
auto &
C : LoopPipelineParsingCallbacks)
1840 if (
C(
Name, LPM, InnerPipeline))
1844 return make_error<StringError>(
1845 formatv(
"invalid use of '{0}' pass as loop pipeline",
Name).str(),
1850#define LOOPNEST_PASS(NAME, CREATE_PASS) \
1851 if (Name == NAME) { \
1852 LPM.addPass(CREATE_PASS); \
1853 return Error::success(); \
1855#define LOOP_PASS(NAME, CREATE_PASS) \
1856 if (Name == NAME) { \
1857 LPM.addPass(CREATE_PASS); \
1858 return Error::success(); \
1860#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1861 if (checkParametrizedPassName(Name, NAME)) { \
1862 auto Params = parsePassParameters(PARSER, Name, NAME); \
1864 return Params.takeError(); \
1865 LPM.addPass(CREATE_PASS(Params.get())); \
1866 return Error::success(); \
1868#define LOOP_ANALYSIS(NAME, CREATE_PASS) \
1869 if (Name == "require<" NAME ">") { \
1870 LPM.addPass(RequireAnalysisPass< \
1871 std::remove_reference_t<decltype(CREATE_PASS)>, Loop, \
1872 LoopAnalysisManager, LoopStandardAnalysisResults &, \
1874 return Error::success(); \
1876 if (Name == "invalidate<" NAME ">") { \
1877 LPM.addPass(InvalidateAnalysisPass< \
1878 std::remove_reference_t<decltype(CREATE_PASS)>>()); \
1879 return Error::success(); \
1881#include "PassRegistry.def"
1883 for (
auto &
C : LoopPipelineParsingCallbacks)
1884 if (
C(
Name, LPM, InnerPipeline))
1886 return make_error<StringError>(
formatv(
"unknown loop pass '{0}'",
Name).str(),
1891 const PipelineElement &E) {
1893 if (!E.InnerPipeline.empty())
1894 return make_error<StringError>(
"invalid pipeline",
1897#define MACHINE_MODULE_PASS(NAME, CREATE_PASS) \
1898 if (Name == NAME) { \
1899 MFPM.addPass(CREATE_PASS); \
1900 return Error::success(); \
1902#define MACHINE_FUNCTION_PASS(NAME, CREATE_PASS) \
1903 if (Name == NAME) { \
1904 MFPM.addPass(CREATE_PASS); \
1905 return Error::success(); \
1907#include "llvm/Passes/MachinePassRegistry.def"
1909 for (
auto &
C : MachineFunctionPipelineParsingCallbacks)
1910 if (
C(
Name, MFPM, E.InnerPipeline))
1912 return make_error<StringError>(
1913 formatv(
"unknown machine pass '{0}'",
Name).str(),
1918#define MODULE_ALIAS_ANALYSIS(NAME, CREATE_PASS) \
1919 if (Name == NAME) { \
1920 AA.registerModuleAnalysis< \
1921 std::remove_reference_t<decltype(CREATE_PASS)>>(); \
1924#define FUNCTION_ALIAS_ANALYSIS(NAME, CREATE_PASS) \
1925 if (Name == NAME) { \
1926 AA.registerFunctionAnalysis< \
1927 std::remove_reference_t<decltype(CREATE_PASS)>>(); \
1930#include "PassRegistry.def"
1932 for (
auto &
C : AAParsingCallbacks)
1938Error PassBuilder::parseMachinePassPipeline(
1940 for (
const auto &Element : Pipeline) {
1941 if (
auto Err = parseMachinePass(MFPM, Element))
1949 for (
const auto &Element : Pipeline) {
1950 if (
auto Err = parseLoopPass(LPM, Element))
1956Error PassBuilder::parseFunctionPassPipeline(
1958 for (
const auto &Element : Pipeline) {
1959 if (
auto Err = parseFunctionPass(FPM, Element))
1967 for (
const auto &Element : Pipeline) {
1968 if (
auto Err = parseCGSCCPass(CGPM, Element))
2000 for (
const auto &Element : Pipeline) {
2001 if (
auto Err = parseModulePass(
MPM, Element))
2012 auto Pipeline = parsePipelineText(PipelineText);
2013 if (!Pipeline || Pipeline->empty())
2014 return make_error<StringError>(
2015 formatv(
"invalid pipeline '{0}'", PipelineText).str(),
2025 Pipeline = {{
"cgscc", std::move(*Pipeline)}};
2027 FunctionPipelineParsingCallbacks)) {
2028 Pipeline = {{
"function", std::move(*Pipeline)}};
2031 Pipeline = {{
"function", {{UseMemorySSA ?
"loop-mssa" :
"loop",
2032 std::move(*Pipeline)}}}};
2033 }
else if (
isLoopPassName(FirstName, LoopPipelineParsingCallbacks,
2035 Pipeline = {{
"function", {{UseMemorySSA ?
"loop-mssa" :
"loop",
2036 std::move(*Pipeline)}}}};
2038 FirstName, MachineFunctionPipelineParsingCallbacks)) {
2039 Pipeline = {{
"function", {{
"machine-function", std::move(*Pipeline)}}}};
2041 for (
auto &
C : TopLevelPipelineParsingCallbacks)
2042 if (
C(
MPM, *Pipeline))
2046 auto &InnerPipeline = Pipeline->front().InnerPipeline;
2047 return make_error<StringError>(
2048 formatv(
"unknown {0} name '{1}'",
2049 (InnerPipeline.empty() ?
"pass" :
"pipeline"), FirstName)
2055 if (
auto Err = parseModulePassPipeline(
MPM, *Pipeline))
2063 auto Pipeline = parsePipelineText(PipelineText);
2064 if (!Pipeline || Pipeline->empty())
2065 return make_error<StringError>(
2066 formatv(
"invalid pipeline '{0}'", PipelineText).str(),
2071 return make_error<StringError>(
2072 formatv(
"unknown cgscc pass '{0}' in pipeline '{1}'", FirstName,
2077 if (
auto Err = parseCGSCCPassPipeline(CGPM, *Pipeline))
2086 auto Pipeline = parsePipelineText(PipelineText);
2087 if (!Pipeline || Pipeline->empty())
2088 return make_error<StringError>(
2089 formatv(
"invalid pipeline '{0}'", PipelineText).str(),
2094 return make_error<StringError>(
2095 formatv(
"unknown function pass '{0}' in pipeline '{1}'", FirstName,
2100 if (
auto Err = parseFunctionPassPipeline(FPM, *Pipeline))
2108 auto Pipeline = parsePipelineText(PipelineText);
2109 if (!Pipeline || Pipeline->empty())
2110 return make_error<StringError>(
2111 formatv(
"invalid pipeline '{0}'", PipelineText).str(),
2114 if (
auto Err = parseLoopPassPipeline(CGPM, *Pipeline))
2122 auto Pipeline = parsePipelineText(PipelineText);
2123 if (!Pipeline || Pipeline->empty())
2124 return make_error<StringError>(
2125 formatv(
"invalid machine pass pipeline '{0}'", PipelineText).str(),
2128 if (
auto Err = parseMachinePassPipeline(MFPM, *Pipeline))
2137 if (PipelineText ==
"default") {
2142 while (!PipelineText.
empty()) {
2144 std::tie(
Name, PipelineText) = PipelineText.
split(
',');
2145 if (!parseAAPassName(AA,
Name))
2146 return make_error<StringError>(
2147 formatv(
"unknown alias analysis name '{0}'",
Name).str(),
2159 OS <<
" " <<
PassName <<
"<" << Params <<
">\n";
2165 OS <<
"Module passes:\n";
2166#define MODULE_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2167#include "PassRegistry.def"
2169 OS <<
"Module passes with params:\n";
2170#define MODULE_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
2171 printPassName(NAME, PARAMS, OS);
2172#include "PassRegistry.def"
2174 OS <<
"Module analyses:\n";
2175#define MODULE_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2176#include "PassRegistry.def"
2178 OS <<
"Module alias analyses:\n";
2179#define MODULE_ALIAS_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2180#include "PassRegistry.def"
2182 OS <<
"CGSCC passes:\n";
2183#define CGSCC_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2184#include "PassRegistry.def"
2186 OS <<
"CGSCC passes with params:\n";
2187#define CGSCC_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
2188 printPassName(NAME, PARAMS, OS);
2189#include "PassRegistry.def"
2191 OS <<
"CGSCC analyses:\n";
2192#define CGSCC_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2193#include "PassRegistry.def"
2195 OS <<
"Function passes:\n";
2196#define FUNCTION_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2197#include "PassRegistry.def"
2199 OS <<
"Function passes with params:\n";
2200#define FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
2201 printPassName(NAME, PARAMS, OS);
2202#include "PassRegistry.def"
2204 OS <<
"Function analyses:\n";
2205#define FUNCTION_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2206#include "PassRegistry.def"
2208 OS <<
"Function alias analyses:\n";
2209#define FUNCTION_ALIAS_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2210#include "PassRegistry.def"
2212 OS <<
"LoopNest passes:\n";
2213#define LOOPNEST_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2214#include "PassRegistry.def"
2216 OS <<
"Loop passes:\n";
2217#define LOOP_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2218#include "PassRegistry.def"
2220 OS <<
"Loop passes with params:\n";
2221#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
2222 printPassName(NAME, PARAMS, OS);
2223#include "PassRegistry.def"
2225 OS <<
"Loop analyses:\n";
2226#define LOOP_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2227#include "PassRegistry.def"
2229 OS <<
"Machine module passes (WIP):\n";
2230#define MACHINE_MODULE_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2231#include "llvm/Passes/MachinePassRegistry.def"
2233 OS <<
"Machine function passes (WIP):\n";
2234#define MACHINE_FUNCTION_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2235#include "llvm/Passes/MachinePassRegistry.def"
2237 OS <<
"Machine function analyses (WIP):\n";
2238#define MACHINE_FUNCTION_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2239#include "llvm/Passes/MachinePassRegistry.def"
2245 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.