329 "^(default|thinlto-pre-link|thinlto|lto-pre-link|lto)<(O[0123sz])>$");
333 "print-pipeline-passes",
334 cl::desc(
"Print a '-passes' compatible string describing the pipeline "
335 "(best-effort only)."));
347class TriggerCrashModulePass :
public PassInfoMixin<TriggerCrashModulePass> {
356class TriggerCrashFunctionPass
363 static StringRef name() {
return "TriggerCrashFunctionPass"; }
368class TriggerVerifierErrorPass
376 GlobalValue::LinkageTypes::InternalLinkage,
377 "__bad_alias",
nullptr, &M);
397 static StringRef name() {
return "TriggerVerifierErrorPass"; }
402class RequireAllMachineFunctionPropertiesPass
403 :
public PassInfoMixin<RequireAllMachineFunctionPropertiesPass> {
412 MFProps.
set(MachineFunctionProperties::Property::FailedISel);
413 MFProps.
set(MachineFunctionProperties::Property::FailsVerification);
414 MFProps.
set(MachineFunctionProperties::Property::IsSSA);
415 MFProps.
set(MachineFunctionProperties::Property::Legalized);
416 MFProps.
set(MachineFunctionProperties::Property::NoPHIs);
417 MFProps.
set(MachineFunctionProperties::Property::NoVRegs);
418 MFProps.
set(MachineFunctionProperties::Property::RegBankSelected);
419 MFProps.
set(MachineFunctionProperties::Property::Selected);
420 MFProps.
set(MachineFunctionProperties::Property::TiedOpsRewritten);
421 MFProps.
set(MachineFunctionProperties::Property::TracksDebugUserValues);
422 MFProps.
set(MachineFunctionProperties::Property::TracksLiveness);
425 static StringRef name() {
return "RequireAllMachineFunctionPropertiesPass"; }
431 std::optional<PGOOptions> PGOOpt,
433 : TM(TM), PTO(PTO), PGOOpt(PGOOpt),
PIC(
PIC) {
435 TM->registerPassBuilderCallbacks(*
this);
441#define MODULE_PASS(NAME, CREATE_PASS) \
442 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
443#define MODULE_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
444 PIC->addClassToPassName(CLASS, NAME);
445#define MODULE_ANALYSIS(NAME, CREATE_PASS) \
446 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
447#define FUNCTION_PASS(NAME, CREATE_PASS) \
448 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
449#define FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
450 PIC->addClassToPassName(CLASS, NAME);
451#define FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
452 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
453#define LOOPNEST_PASS(NAME, CREATE_PASS) \
454 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
455#define LOOP_PASS(NAME, CREATE_PASS) \
456 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
457#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
458 PIC->addClassToPassName(CLASS, NAME);
459#define LOOP_ANALYSIS(NAME, CREATE_PASS) \
460 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
461#define CGSCC_PASS(NAME, CREATE_PASS) \
462 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
463#define CGSCC_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
464 PIC->addClassToPassName(CLASS, NAME);
465#define CGSCC_ANALYSIS(NAME, CREATE_PASS) \
466 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
467#include "PassRegistry.def"
469#define MACHINE_FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
470 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
471#define MACHINE_FUNCTION_PASS(NAME, CREATE_PASS) \
472 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
473#include "llvm/Passes/MachinePassRegistry.def"
479#define MODULE_ANALYSIS(NAME, CREATE_PASS) \
480 MAM.registerPass([&] { return CREATE_PASS; });
481#include "PassRegistry.def"
483 for (
auto &
C : ModuleAnalysisRegistrationCallbacks)
488#define CGSCC_ANALYSIS(NAME, CREATE_PASS) \
489 CGAM.registerPass([&] { return CREATE_PASS; });
490#include "PassRegistry.def"
492 for (
auto &
C : CGSCCAnalysisRegistrationCallbacks)
502#define FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
503 FAM.registerPass([&] { return CREATE_PASS; });
504#include "PassRegistry.def"
506 for (
auto &
C : FunctionAnalysisRegistrationCallbacks)
513#define MACHINE_FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
514 MFAM.registerPass([&] { return CREATE_PASS; });
515#include "llvm/Passes/MachinePassRegistry.def"
517 for (
auto &
C : MachineFunctionAnalysisRegistrationCallbacks)
522#define LOOP_ANALYSIS(NAME, CREATE_PASS) \
523 LAM.registerPass([&] { return CREATE_PASS; });
524#include "PassRegistry.def"
526 for (
auto &
C : LoopAnalysisRegistrationCallbacks)
530static std::optional<std::pair<bool, bool>>
532 std::pair<bool, bool> Params;
533 if (!
Name.consume_front(
"function"))
537 if (!
Name.consume_front(
"<") || !
Name.consume_back(
">"))
539 while (!
Name.empty()) {
540 auto [Front, Back] =
Name.split(
';');
542 if (Front ==
"eager-inv")
544 else if (Front ==
"no-rerun")
545 Params.second =
true;
553 if (!
Name.consume_front(
"devirt<") || !
Name.consume_back(
">"))
556 if (
Name.getAsInteger(0, Count) || Count < 0)
576 while (!Params.
empty()) {
578 std::tie(ParamName, Params) = Params.
split(
';');
580 if (ParamName == OptionName) {
583 return make_error<StringError>(
598 while (!Params.
empty()) {
600 std::tie(ParamName, Params) = Params.
split(
';');
604 return make_error<StringError>(
605 formatv(
"invalid HardwareLoopPass parameter '{0}' ", ParamName).str(),
610 if (ParamName.
consume_front(
"hardware-loop-counter-bitwidth=")) {
613 return make_error<StringError>(
614 formatv(
"invalid HardwareLoopPass parameter '{0}' ", ParamName).str(),
619 if (ParamName ==
"force-hardware-loops") {
621 }
else if (ParamName ==
"force-hardware-loop-phi") {
623 }
else if (ParamName ==
"force-nested-hardware-loop") {
625 }
else if (ParamName ==
"force-hardware-loop-guard") {
628 return make_error<StringError>(
629 formatv(
"invalid HardwarePass parameter '{0}' ", ParamName).str(),
633 return HardwareLoopOpts;
639 while (!Params.
empty()) {
641 std::tie(ParamName, Params) = Params.
split(
';');
642 std::optional<OptimizationLevel> OptLevel =
parseOptLevel(ParamName);
644 if (OptLevel && !OptLevel->isOptimizingForSize()) {
645 UnrollOpts.
setOptLevel(OptLevel->getSpeedupLevel());
651 return make_error<StringError>(
652 formatv(
"invalid LoopUnrollPass parameter '{0}' ", ParamName).str(),
659 if (ParamName ==
"partial") {
661 }
else if (ParamName ==
"peeling") {
663 }
else if (ParamName ==
"profile-peeling") {
665 }
else if (ParamName ==
"runtime") {
667 }
else if (ParamName ==
"upperbound") {
670 return make_error<StringError>(
671 formatv(
"invalid LoopUnrollPass parameter '{0}' ", ParamName).str(),
680 Params,
"vfe-linkage-unit-visibility",
"GlobalDCE");
700 Params,
"skip-non-recursive-function-attrs",
"PostOrderFunctionAttrs");
709 return make_error<StringError>(
710 formatv(
"too many CFGuardPass parameters '{0}' ", Params).str(),
713 if (Param ==
"check")
715 if (Param ==
"dispatch")
718 return make_error<StringError>(
719 formatv(
"invalid CFGuardPass mechanism: '{0}' ", Param).str(),
729 "EntryExitInstrumenter");
738 "LowerMatrixIntrinsics");
743 while (!Params.
empty()) {
745 std::tie(ParamName, Params) = Params.
split(
';');
747 if (ParamName ==
"kernel") {
748 Result.CompileKernel =
true;
750 return make_error<StringError>(
751 formatv(
"invalid AddressSanitizer pass parameter '{0}' ", ParamName)
761 while (!Params.
empty()) {
763 std::tie(ParamName, Params) = Params.
split(
';');
765 if (ParamName ==
"recover") {
767 }
else if (ParamName ==
"kernel") {
768 Result.CompileKernel =
true;
770 return make_error<StringError>(
771 formatv(
"invalid HWAddressSanitizer pass parameter '{0}' ", ParamName)
781 while (!Params.
empty()) {
783 std::tie(ParamName, Params) = Params.
split(
';');
785 if (ParamName ==
"thinlto") {
787 }
else if (ParamName ==
"emit-summary") {
788 Result.EmitLTOSummary =
true;
790 return make_error<StringError>(
791 formatv(
"invalid EmbedBitcode pass parameter '{0}' ", ParamName)
801 while (!Params.
empty()) {
803 std::tie(ParamName, Params) = Params.
split(
';');
805 if (ParamName ==
"recover") {
807 }
else if (ParamName ==
"kernel") {
811 return make_error<StringError>(
812 formatv(
"invalid argument to MemorySanitizer pass track-origins "
817 }
else if (ParamName ==
"eager-checks") {
818 Result.EagerChecks =
true;
820 return make_error<StringError>(
821 formatv(
"invalid MemorySanitizer pass parameter '{0}' ", ParamName)
832 while (!Params.
empty()) {
834 std::tie(ParamName, Params) = Params.
split(
';');
837 if (ParamName ==
"speculate-blocks") {
839 }
else if (ParamName ==
"simplify-cond-branch") {
841 }
else if (ParamName ==
"forward-switch-cond") {
843 }
else if (ParamName ==
"switch-range-to-icmp") {
845 }
else if (ParamName ==
"switch-to-lookup") {
847 }
else if (ParamName ==
"keep-loops") {
849 }
else if (ParamName ==
"hoist-common-insts") {
851 }
else if (ParamName ==
"sink-common-insts") {
853 }
else if (ParamName ==
"speculate-unpredictables") {
856 APInt BonusInstThreshold;
858 return make_error<StringError>(
859 formatv(
"invalid argument to SimplifyCFG pass bonus-threshold "
865 return make_error<StringError>(
866 formatv(
"invalid SimplifyCFG pass parameter '{0}' ", ParamName).str(),
877 Result.setVerifyFixpoint(
true);
878 while (!Params.
empty()) {
880 std::tie(ParamName, Params) = Params.
split(
';');
883 if (ParamName ==
"use-loop-info") {
885 }
else if (ParamName ==
"verify-fixpoint") {
890 return make_error<StringError>(
891 formatv(
"invalid argument to InstCombine pass max-iterations "
897 return make_error<StringError>(
898 formatv(
"invalid InstCombine pass parameter '{0}' ", ParamName).str(),
908 while (!Params.
empty()) {
910 std::tie(ParamName, Params) = Params.
split(
';');
913 if (ParamName ==
"interleave-forced-only") {
915 }
else if (ParamName ==
"vectorize-forced-only") {
918 return make_error<StringError>(
919 formatv(
"invalid LoopVectorize parameter '{0}' ", ParamName).str(),
927 std::pair<bool, bool>
Result = {
false,
true};
928 while (!Params.
empty()) {
930 std::tie(ParamName, Params) = Params.
split(
';');
933 if (ParamName ==
"nontrivial") {
935 }
else if (ParamName ==
"trivial") {
938 return make_error<StringError>(
939 formatv(
"invalid LoopUnswitch pass parameter '{0}' ", ParamName)
949 while (!Params.
empty()) {
951 std::tie(ParamName, Params) = Params.
split(
';');
954 if (ParamName ==
"allowspeculation") {
957 return make_error<StringError>(
958 formatv(
"invalid LICM pass parameter '{0}' ", ParamName).str(),
966 std::pair<bool, bool>
Result = {
true,
false};
967 while (!Params.
empty()) {
969 std::tie(ParamName, Params) = Params.
split(
';');
972 if (ParamName ==
"header-duplication") {
974 }
else if (ParamName ==
"prepare-for-lto") {
977 return make_error<StringError>(
978 formatv(
"invalid LoopRotate pass parameter '{0}' ", ParamName).str(),
987 while (!Params.
empty()) {
989 std::tie(ParamName, Params) = Params.
split(
';');
992 if (ParamName ==
"split-footer-bb") {
995 return make_error<StringError>(
996 formatv(
"invalid MergedLoadStoreMotion pass parameter '{0}' ",
1007 while (!Params.
empty()) {
1009 std::tie(ParamName, Params) = Params.
split(
';');
1012 if (ParamName ==
"pre") {
1014 }
else if (ParamName ==
"load-pre") {
1016 }
else if (ParamName ==
"split-backedge-load-pre") {
1018 }
else if (ParamName ==
"memdep") {
1021 return make_error<StringError>(
1022 formatv(
"invalid GVN pass parameter '{0}' ", ParamName).str(),
1031 while (!Params.
empty()) {
1033 std::tie(ParamName, Params) = Params.
split(
';');
1036 if (ParamName ==
"func-spec")
1039 return make_error<StringError>(
1040 formatv(
"invalid IPSCCP pass parameter '{0}' ", ParamName).str(),
1047 if (Params.
empty() || Params ==
"modify-cfg")
1049 if (Params ==
"preserve-cfg")
1051 return make_error<StringError>(
1052 formatv(
"invalid SROA pass parameter '{0}' (either preserve-cfg or "
1053 "modify-cfg can be specified)",
1060parseStackLifetimeOptions(
StringRef Params) {
1062 while (!Params.
empty()) {
1064 std::tie(ParamName, Params) = Params.
split(
';');
1066 if (ParamName ==
"may") {
1068 }
else if (ParamName ==
"must") {
1071 return make_error<StringError>(
1072 formatv(
"invalid StackLifetime parameter '{0}' ", ParamName).str(),
1081 "DependenceAnalysisPrinter");
1086 "SeparateConstOffsetFromGEP");
1095parseFunctionSimplificationPipelineOptions(
StringRef Params) {
1098 return make_error<StringError>(
1099 formatv(
"invalid function-simplification parameter '{0}' ", Params)
1108 "MemorySSAPrinterPass");
1113 "SpeculativeExecutionPass");
1118 while (!Params.
empty()) {
1120 std::tie(ParamName, Params) = Params.
split(
';');
1125 return make_error<StringError>(
1126 formatv(
"invalid MemProfUse pass parameter '{0}' ", ParamName).str(),
1135 "StructuralHashPrinterPass");
1140 "WinEHPreparePass");
1145 while (!Params.
empty()) {
1147 std::tie(ParamName, Params) = Params.
split(
';');
1150 if (ParamName ==
"group-by-use")
1152 else if (ParamName ==
"ignore-single-use")
1154 else if (ParamName ==
"merge-const")
1156 else if (ParamName ==
"merge-external")
1160 return make_error<StringError>(
1161 formatv(
"invalid GlobalMergePass parameter '{0}' ", ParamName)
1171 while (!Params.
empty()) {
1173 std::tie(ParamName, Params) = Params.
split(
';');
1178 return make_error<StringError>(
1179 formatv(
"invalid Internalize pass parameter '{0}' ", ParamName).str(),
1190 while (!Params.
empty()) {
1192 std::tie(ParamName, Params) = Params.
split(
';');
1195 std::optional<RegAllocFilterFunc>
Filter =
1198 return make_error<StringError>(
1199 formatv(
"invalid regallocfast register filter '{0}' ", ParamName)
1208 if (ParamName ==
"no-clear-vregs") {
1213 return make_error<StringError>(
1214 formatv(
"invalid regallocfast pass parameter '{0}' ", ParamName).str(),
1230 return Name.starts_with(
"default") ||
Name.starts_with(
"thinlto") ||
1231 Name.starts_with(
"lto");
1242template <
typename PassManagerT,
typename CallbacksT>
1244 if (!Callbacks.empty()) {
1245 PassManagerT DummyPM;
1246 for (
auto &CB : Callbacks)
1247 if (CB(
Name, DummyPM, {}))
1253template <
typename CallbacksT>
1259 StringRef NameNoBracket =
Name.take_until([](
char C) {
return C ==
'<'; });
1262 if (
Name ==
"module")
1264 if (
Name ==
"cgscc")
1266 if (NameNoBracket ==
"function")
1268 if (
Name ==
"coro-cond")
1271#define MODULE_PASS(NAME, CREATE_PASS) \
1274#define MODULE_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1275 if (PassBuilder::checkParametrizedPassName(Name, NAME)) \
1277#define MODULE_ANALYSIS(NAME, CREATE_PASS) \
1278 if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
1280#include "PassRegistry.def"
1282 return callbacksAcceptPassName<ModulePassManager>(
Name, Callbacks);
1285template <
typename CallbacksT>
1288 StringRef NameNoBracket =
Name.take_until([](
char C) {
return C ==
'<'; });
1289 if (
Name ==
"cgscc")
1291 if (NameNoBracket ==
"function")
1298#define CGSCC_PASS(NAME, CREATE_PASS) \
1301#define CGSCC_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1302 if (PassBuilder::checkParametrizedPassName(Name, NAME)) \
1304#define CGSCC_ANALYSIS(NAME, CREATE_PASS) \
1305 if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
1307#include "PassRegistry.def"
1309 return callbacksAcceptPassName<CGSCCPassManager>(
Name, Callbacks);
1312template <
typename CallbacksT>
1315 StringRef NameNoBracket =
Name.take_until([](
char C) {
return C ==
'<'; });
1316 if (NameNoBracket ==
"function")
1318 if (
Name ==
"loop" ||
Name ==
"loop-mssa" ||
Name ==
"machine-function")
1321#define FUNCTION_PASS(NAME, CREATE_PASS) \
1324#define FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1325 if (PassBuilder::checkParametrizedPassName(Name, NAME)) \
1327#define FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
1328 if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
1330#include "PassRegistry.def"
1332 return callbacksAcceptPassName<FunctionPassManager>(
Name, Callbacks);
1335template <
typename CallbacksT>
1338 if (
Name ==
"machine-function")
1341#define MACHINE_FUNCTION_PASS(NAME, CREATE_PASS) \
1344#define MACHINE_FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, \
1346 if (PassBuilder::checkParametrizedPassName(Name, NAME)) \
1349#define MACHINE_FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
1350 if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
1353#include "llvm/Passes/MachinePassRegistry.def"
1355 return callbacksAcceptPassName<MachineFunctionPassManager>(
Name, Callbacks);
1358template <
typename CallbacksT>
1360 bool &UseMemorySSA) {
1361 UseMemorySSA =
false;
1364 UseMemorySSA =
true;
1368#define LOOPNEST_PASS(NAME, CREATE_PASS) \
1371#include "PassRegistry.def"
1373 return callbacksAcceptPassName<LoopPassManager>(
Name, Callbacks);
1376template <
typename CallbacksT>
1378 bool &UseMemorySSA) {
1379 UseMemorySSA =
false;
1382 UseMemorySSA =
true;
1386#define LOOP_PASS(NAME, CREATE_PASS) \
1389#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1390 if (PassBuilder::checkParametrizedPassName(Name, NAME)) \
1392#define LOOP_ANALYSIS(NAME, CREATE_PASS) \
1393 if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
1395#include "PassRegistry.def"
1397 return callbacksAcceptPassName<LoopPassManager>(
Name, Callbacks);
1400std::optional<std::vector<PassBuilder::PipelineElement>>
1401PassBuilder::parsePipelineText(
StringRef Text) {
1402 std::vector<PipelineElement> ResultPipeline;
1407 std::vector<PipelineElement> &Pipeline = *PipelineStack.
back();
1408 size_t Pos =
Text.find_first_of(
",()");
1409 Pipeline.push_back({
Text.substr(0, Pos), {}});
1412 if (Pos ==
Text.npos)
1415 char Sep =
Text[Pos];
1423 PipelineStack.
push_back(&Pipeline.back().InnerPipeline);
1427 assert(Sep ==
')' &&
"Bogus separator!");
1432 if (PipelineStack.
size() == 1)
1433 return std::nullopt;
1436 }
while (
Text.consume_front(
")"));
1444 if (!
Text.consume_front(
","))
1445 return std::nullopt;
1448 if (PipelineStack.
size() > 1)
1450 return std::nullopt;
1452 assert(PipelineStack.
back() == &ResultPipeline &&
1453 "Wrong pipeline at the bottom of the stack!");
1454 return {std::move(ResultPipeline)};
1458 const PipelineElement &E) {
1459 auto &
Name = E.Name;
1460 auto &InnerPipeline = E.InnerPipeline;
1463 if (!InnerPipeline.empty()) {
1464 if (
Name ==
"module") {
1466 if (
auto Err = parseModulePassPipeline(NestedMPM, InnerPipeline))
1468 MPM.
addPass(std::move(NestedMPM));
1471 if (
Name ==
"coro-cond") {
1473 if (
auto Err = parseModulePassPipeline(NestedMPM, InnerPipeline))
1478 if (
Name ==
"cgscc") {
1480 if (
auto Err = parseCGSCCPassPipeline(CGPM, InnerPipeline))
1487 return make_error<StringError>(
1488 "cannot have a no-rerun module to function adaptor",
1491 if (
auto Err = parseFunctionPassPipeline(FPM, InnerPipeline))
1498 for (
auto &
C : ModulePipelineParsingCallbacks)
1499 if (
C(
Name, MPM, InnerPipeline))
1503 return make_error<StringError>(
1504 formatv(
"invalid use of '{0}' pass as module pipeline",
Name).str(),
1513 return make_error<StringError>(
1514 formatv(
"unknown default pipeline alias '{0}'",
Name).str(),
1517 assert(Matches.
size() == 3 &&
"Must capture two matched strings!");
1529 if (Matches[1] ==
"default") {
1531 }
else if (Matches[1] ==
"thinlto-pre-link") {
1533 }
else if (Matches[1] ==
"thinlto") {
1535 }
else if (Matches[1] ==
"lto-pre-link") {
1544 assert(Matches[1] ==
"lto" &&
"Not one of the matched options!");
1551#define MODULE_PASS(NAME, CREATE_PASS) \
1552 if (Name == NAME) { \
1553 MPM.addPass(CREATE_PASS); \
1554 return Error::success(); \
1556#define MODULE_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1557 if (checkParametrizedPassName(Name, NAME)) { \
1558 auto Params = parsePassParameters(PARSER, Name, NAME); \
1560 return Params.takeError(); \
1561 MPM.addPass(CREATE_PASS(Params.get())); \
1562 return Error::success(); \
1564#define MODULE_ANALYSIS(NAME, CREATE_PASS) \
1565 if (Name == "require<" NAME ">") { \
1567 RequireAnalysisPass< \
1568 std::remove_reference_t<decltype(CREATE_PASS)>, Module>()); \
1569 return Error::success(); \
1571 if (Name == "invalidate<" NAME ">") { \
1572 MPM.addPass(InvalidateAnalysisPass< \
1573 std::remove_reference_t<decltype(CREATE_PASS)>>()); \
1574 return Error::success(); \
1576#define CGSCC_PASS(NAME, CREATE_PASS) \
1577 if (Name == NAME) { \
1578 MPM.addPass(createModuleToPostOrderCGSCCPassAdaptor(CREATE_PASS)); \
1579 return Error::success(); \
1581#define CGSCC_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1582 if (checkParametrizedPassName(Name, NAME)) { \
1583 auto Params = parsePassParameters(PARSER, Name, NAME); \
1585 return Params.takeError(); \
1587 createModuleToPostOrderCGSCCPassAdaptor(CREATE_PASS(Params.get()))); \
1588 return Error::success(); \
1590#define FUNCTION_PASS(NAME, CREATE_PASS) \
1591 if (Name == NAME) { \
1592 MPM.addPass(createModuleToFunctionPassAdaptor(CREATE_PASS)); \
1593 return Error::success(); \
1595#define FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1596 if (checkParametrizedPassName(Name, NAME)) { \
1597 auto Params = parsePassParameters(PARSER, Name, NAME); \
1599 return Params.takeError(); \
1600 MPM.addPass(createModuleToFunctionPassAdaptor(CREATE_PASS(Params.get()))); \
1601 return Error::success(); \
1603#define LOOPNEST_PASS(NAME, CREATE_PASS) \
1604 if (Name == NAME) { \
1605 MPM.addPass(createModuleToFunctionPassAdaptor( \
1606 createFunctionToLoopPassAdaptor(CREATE_PASS, false, false))); \
1607 return Error::success(); \
1609#define LOOP_PASS(NAME, CREATE_PASS) \
1610 if (Name == NAME) { \
1611 MPM.addPass(createModuleToFunctionPassAdaptor( \
1612 createFunctionToLoopPassAdaptor(CREATE_PASS, false, false))); \
1613 return Error::success(); \
1615#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1616 if (checkParametrizedPassName(Name, NAME)) { \
1617 auto Params = parsePassParameters(PARSER, Name, NAME); \
1619 return Params.takeError(); \
1621 createModuleToFunctionPassAdaptor(createFunctionToLoopPassAdaptor( \
1622 CREATE_PASS(Params.get()), false, false))); \
1623 return Error::success(); \
1625#include "PassRegistry.def"
1627 for (
auto &
C : ModulePipelineParsingCallbacks)
1628 if (
C(
Name, MPM, InnerPipeline))
1630 return make_error<StringError>(
1636 const PipelineElement &E) {
1637 auto &
Name = E.Name;
1638 auto &InnerPipeline = E.InnerPipeline;
1641 if (!InnerPipeline.empty()) {
1642 if (
Name ==
"cgscc") {
1644 if (
auto Err = parseCGSCCPassPipeline(NestedCGPM, InnerPipeline))
1647 CGPM.
addPass(std::move(NestedCGPM));
1652 if (
auto Err = parseFunctionPassPipeline(FPM, InnerPipeline))
1656 std::move(FPM), Params->first, Params->second));
1661 if (
auto Err = parseCGSCCPassPipeline(NestedCGPM, InnerPipeline))
1668 for (
auto &
C : CGSCCPipelineParsingCallbacks)
1669 if (
C(
Name, CGPM, InnerPipeline))
1673 return make_error<StringError>(
1674 formatv(
"invalid use of '{0}' pass as cgscc pipeline",
Name).str(),
1679#define CGSCC_PASS(NAME, CREATE_PASS) \
1680 if (Name == NAME) { \
1681 CGPM.addPass(CREATE_PASS); \
1682 return Error::success(); \
1684#define CGSCC_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1685 if (checkParametrizedPassName(Name, NAME)) { \
1686 auto Params = parsePassParameters(PARSER, Name, NAME); \
1688 return Params.takeError(); \
1689 CGPM.addPass(CREATE_PASS(Params.get())); \
1690 return Error::success(); \
1692#define CGSCC_ANALYSIS(NAME, CREATE_PASS) \
1693 if (Name == "require<" NAME ">") { \
1694 CGPM.addPass(RequireAnalysisPass< \
1695 std::remove_reference_t<decltype(CREATE_PASS)>, \
1696 LazyCallGraph::SCC, CGSCCAnalysisManager, LazyCallGraph &, \
1697 CGSCCUpdateResult &>()); \
1698 return Error::success(); \
1700 if (Name == "invalidate<" NAME ">") { \
1701 CGPM.addPass(InvalidateAnalysisPass< \
1702 std::remove_reference_t<decltype(CREATE_PASS)>>()); \
1703 return Error::success(); \
1705#define FUNCTION_PASS(NAME, CREATE_PASS) \
1706 if (Name == NAME) { \
1707 CGPM.addPass(createCGSCCToFunctionPassAdaptor(CREATE_PASS)); \
1708 return Error::success(); \
1710#define FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1711 if (checkParametrizedPassName(Name, NAME)) { \
1712 auto Params = parsePassParameters(PARSER, Name, NAME); \
1714 return Params.takeError(); \
1715 CGPM.addPass(createCGSCCToFunctionPassAdaptor(CREATE_PASS(Params.get()))); \
1716 return Error::success(); \
1718#define LOOPNEST_PASS(NAME, CREATE_PASS) \
1719 if (Name == NAME) { \
1720 CGPM.addPass(createCGSCCToFunctionPassAdaptor( \
1721 createFunctionToLoopPassAdaptor(CREATE_PASS, false, false))); \
1722 return Error::success(); \
1724#define LOOP_PASS(NAME, CREATE_PASS) \
1725 if (Name == NAME) { \
1726 CGPM.addPass(createCGSCCToFunctionPassAdaptor( \
1727 createFunctionToLoopPassAdaptor(CREATE_PASS, false, false))); \
1728 return Error::success(); \
1730#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1731 if (checkParametrizedPassName(Name, NAME)) { \
1732 auto Params = parsePassParameters(PARSER, Name, NAME); \
1734 return Params.takeError(); \
1736 createCGSCCToFunctionPassAdaptor(createFunctionToLoopPassAdaptor( \
1737 CREATE_PASS(Params.get()), false, false))); \
1738 return Error::success(); \
1740#include "PassRegistry.def"
1742 for (
auto &
C : CGSCCPipelineParsingCallbacks)
1743 if (
C(
Name, CGPM, InnerPipeline))
1745 return make_error<StringError>(
1751 const PipelineElement &E) {
1752 auto &
Name = E.Name;
1753 auto &InnerPipeline = E.InnerPipeline;
1756 if (!InnerPipeline.empty()) {
1757 if (
Name ==
"function") {
1759 if (
auto Err = parseFunctionPassPipeline(NestedFPM, InnerPipeline))
1762 FPM.
addPass(std::move(NestedFPM));
1765 if (
Name ==
"loop" ||
Name ==
"loop-mssa") {
1767 if (
auto Err = parseLoopPassPipeline(LPM, InnerPipeline))
1770 bool UseMemorySSA = (
Name ==
"loop-mssa");
1772 return Pipeline.Name.contains(
"simple-loop-unswitch");
1774 bool UseBPI =
llvm::any_of(InnerPipeline, [](
auto Pipeline) {
1775 return Pipeline.Name ==
"loop-predication";
1781 if (
Name ==
"machine-function") {
1783 if (
auto Err = parseMachinePassPipeline(MFPM, InnerPipeline))
1789 for (
auto &
C : FunctionPipelineParsingCallbacks)
1790 if (
C(
Name, FPM, InnerPipeline))
1794 return make_error<StringError>(
1795 formatv(
"invalid use of '{0}' pass as function pipeline",
Name).str(),
1800#define FUNCTION_PASS(NAME, CREATE_PASS) \
1801 if (Name == NAME) { \
1802 FPM.addPass(CREATE_PASS); \
1803 return Error::success(); \
1805#define FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1806 if (checkParametrizedPassName(Name, NAME)) { \
1807 auto Params = parsePassParameters(PARSER, Name, NAME); \
1809 return Params.takeError(); \
1810 FPM.addPass(CREATE_PASS(Params.get())); \
1811 return Error::success(); \
1813#define FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
1814 if (Name == "require<" NAME ">") { \
1816 RequireAnalysisPass< \
1817 std::remove_reference_t<decltype(CREATE_PASS)>, Function>()); \
1818 return Error::success(); \
1820 if (Name == "invalidate<" NAME ">") { \
1821 FPM.addPass(InvalidateAnalysisPass< \
1822 std::remove_reference_t<decltype(CREATE_PASS)>>()); \
1823 return Error::success(); \
1829#define LOOPNEST_PASS(NAME, CREATE_PASS) \
1830 if (Name == NAME) { \
1831 FPM.addPass(createFunctionToLoopPassAdaptor(CREATE_PASS, false, false)); \
1832 return Error::success(); \
1834#define LOOP_PASS(NAME, CREATE_PASS) \
1835 if (Name == NAME) { \
1836 FPM.addPass(createFunctionToLoopPassAdaptor(CREATE_PASS, false, false)); \
1837 return Error::success(); \
1839#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1840 if (checkParametrizedPassName(Name, NAME)) { \
1841 auto Params = parsePassParameters(PARSER, Name, NAME); \
1843 return Params.takeError(); \
1844 FPM.addPass(createFunctionToLoopPassAdaptor(CREATE_PASS(Params.get()), \
1846 return Error::success(); \
1848#include "PassRegistry.def"
1850 for (
auto &
C : FunctionPipelineParsingCallbacks)
1851 if (
C(
Name, FPM, InnerPipeline))
1853 return make_error<StringError>(
1854 formatv(
"unknown function pass '{0}'",
Name).str(),
1859 const PipelineElement &E) {
1861 auto &InnerPipeline = E.InnerPipeline;
1864 if (!InnerPipeline.empty()) {
1865 if (
Name ==
"loop") {
1867 if (
auto Err = parseLoopPassPipeline(NestedLPM, InnerPipeline))
1870 LPM.
addPass(std::move(NestedLPM));
1874 for (
auto &
C : LoopPipelineParsingCallbacks)
1875 if (
C(
Name, LPM, InnerPipeline))
1879 return make_error<StringError>(
1880 formatv(
"invalid use of '{0}' pass as loop pipeline",
Name).str(),
1885#define LOOPNEST_PASS(NAME, CREATE_PASS) \
1886 if (Name == NAME) { \
1887 LPM.addPass(CREATE_PASS); \
1888 return Error::success(); \
1890#define LOOP_PASS(NAME, CREATE_PASS) \
1891 if (Name == NAME) { \
1892 LPM.addPass(CREATE_PASS); \
1893 return Error::success(); \
1895#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1896 if (checkParametrizedPassName(Name, NAME)) { \
1897 auto Params = parsePassParameters(PARSER, Name, NAME); \
1899 return Params.takeError(); \
1900 LPM.addPass(CREATE_PASS(Params.get())); \
1901 return Error::success(); \
1903#define LOOP_ANALYSIS(NAME, CREATE_PASS) \
1904 if (Name == "require<" NAME ">") { \
1905 LPM.addPass(RequireAnalysisPass< \
1906 std::remove_reference_t<decltype(CREATE_PASS)>, Loop, \
1907 LoopAnalysisManager, LoopStandardAnalysisResults &, \
1909 return Error::success(); \
1911 if (Name == "invalidate<" NAME ">") { \
1912 LPM.addPass(InvalidateAnalysisPass< \
1913 std::remove_reference_t<decltype(CREATE_PASS)>>()); \
1914 return Error::success(); \
1916#include "PassRegistry.def"
1918 for (
auto &
C : LoopPipelineParsingCallbacks)
1919 if (
C(
Name, LPM, InnerPipeline))
1921 return make_error<StringError>(
formatv(
"unknown loop pass '{0}'",
Name).str(),
1926 const PipelineElement &E) {
1928 if (!E.InnerPipeline.empty())
1929 return make_error<StringError>(
"invalid pipeline",
1932#define MACHINE_MODULE_PASS(NAME, CREATE_PASS) \
1933 if (Name == NAME) { \
1934 MFPM.addPass(CREATE_PASS); \
1935 return Error::success(); \
1937#define MACHINE_FUNCTION_PASS(NAME, CREATE_PASS) \
1938 if (Name == NAME) { \
1939 MFPM.addPass(CREATE_PASS); \
1940 return Error::success(); \
1942#define MACHINE_FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, \
1944 if (checkParametrizedPassName(Name, NAME)) { \
1945 auto Params = parsePassParameters(PARSER, Name, NAME); \
1947 return Params.takeError(); \
1948 MFPM.addPass(CREATE_PASS(Params.get())); \
1949 return Error::success(); \
1951#define MACHINE_FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
1952 if (Name == "require<" NAME ">") { \
1954 RequireAnalysisPass<std::remove_reference_t<decltype(CREATE_PASS)>, \
1955 MachineFunction>()); \
1956 return Error::success(); \
1958 if (Name == "invalidate<" NAME ">") { \
1959 MFPM.addPass(InvalidateAnalysisPass< \
1960 std::remove_reference_t<decltype(CREATE_PASS)>>()); \
1961 return Error::success(); \
1963#include "llvm/Passes/MachinePassRegistry.def"
1965 for (
auto &
C : MachineFunctionPipelineParsingCallbacks)
1966 if (
C(
Name, MFPM, E.InnerPipeline))
1968 return make_error<StringError>(
1969 formatv(
"unknown machine pass '{0}'",
Name).str(),
1974#define MODULE_ALIAS_ANALYSIS(NAME, CREATE_PASS) \
1975 if (Name == NAME) { \
1976 AA.registerModuleAnalysis< \
1977 std::remove_reference_t<decltype(CREATE_PASS)>>(); \
1980#define FUNCTION_ALIAS_ANALYSIS(NAME, CREATE_PASS) \
1981 if (Name == NAME) { \
1982 AA.registerFunctionAnalysis< \
1983 std::remove_reference_t<decltype(CREATE_PASS)>>(); \
1986#include "PassRegistry.def"
1988 for (
auto &
C : AAParsingCallbacks)
1994Error PassBuilder::parseMachinePassPipeline(
1996 for (
const auto &Element : Pipeline) {
1997 if (
auto Err = parseMachinePass(MFPM, Element))
2005 for (
const auto &Element : Pipeline) {
2006 if (
auto Err = parseLoopPass(LPM, Element))
2012Error PassBuilder::parseFunctionPassPipeline(
2014 for (
const auto &Element : Pipeline) {
2015 if (
auto Err = parseFunctionPass(FPM, Element))
2023 for (
const auto &Element : Pipeline) {
2024 if (
auto Err = parseCGSCCPass(CGPM, Element))
2056 for (
const auto &Element : Pipeline) {
2057 if (
auto Err = parseModulePass(MPM, Element))
2068 auto Pipeline = parsePipelineText(PipelineText);
2069 if (!Pipeline || Pipeline->empty())
2070 return make_error<StringError>(
2071 formatv(
"invalid pipeline '{0}'", PipelineText).str(),
2081 Pipeline = {{
"cgscc", std::move(*Pipeline)}};
2083 FunctionPipelineParsingCallbacks)) {
2084 Pipeline = {{
"function", std::move(*Pipeline)}};
2087 Pipeline = {{
"function", {{UseMemorySSA ?
"loop-mssa" :
"loop",
2088 std::move(*Pipeline)}}}};
2089 }
else if (
isLoopPassName(FirstName, LoopPipelineParsingCallbacks,
2091 Pipeline = {{
"function", {{UseMemorySSA ?
"loop-mssa" :
"loop",
2092 std::move(*Pipeline)}}}};
2094 FirstName, MachineFunctionPipelineParsingCallbacks)) {
2095 Pipeline = {{
"function", {{
"machine-function", std::move(*Pipeline)}}}};
2097 for (
auto &
C : TopLevelPipelineParsingCallbacks)
2098 if (
C(MPM, *Pipeline))
2102 auto &InnerPipeline = Pipeline->front().InnerPipeline;
2103 return make_error<StringError>(
2104 formatv(
"unknown {0} name '{1}'",
2105 (InnerPipeline.empty() ?
"pass" :
"pipeline"), FirstName)
2111 if (
auto Err = parseModulePassPipeline(MPM, *Pipeline))
2119 auto Pipeline = parsePipelineText(PipelineText);
2120 if (!Pipeline || Pipeline->empty())
2121 return make_error<StringError>(
2122 formatv(
"invalid pipeline '{0}'", PipelineText).str(),
2127 return make_error<StringError>(
2128 formatv(
"unknown cgscc pass '{0}' in pipeline '{1}'", FirstName,
2133 if (
auto Err = parseCGSCCPassPipeline(CGPM, *Pipeline))
2142 auto Pipeline = parsePipelineText(PipelineText);
2143 if (!Pipeline || Pipeline->empty())
2144 return make_error<StringError>(
2145 formatv(
"invalid pipeline '{0}'", PipelineText).str(),
2150 return make_error<StringError>(
2151 formatv(
"unknown function pass '{0}' in pipeline '{1}'", FirstName,
2156 if (
auto Err = parseFunctionPassPipeline(FPM, *Pipeline))
2164 auto Pipeline = parsePipelineText(PipelineText);
2165 if (!Pipeline || Pipeline->empty())
2166 return make_error<StringError>(
2167 formatv(
"invalid pipeline '{0}'", PipelineText).str(),
2170 if (
auto Err = parseLoopPassPipeline(CGPM, *Pipeline))
2178 auto Pipeline = parsePipelineText(PipelineText);
2179 if (!Pipeline || Pipeline->empty())
2180 return make_error<StringError>(
2181 formatv(
"invalid machine pass pipeline '{0}'", PipelineText).str(),
2184 if (
auto Err = parseMachinePassPipeline(MFPM, *Pipeline))
2193 if (PipelineText ==
"default") {
2198 while (!PipelineText.
empty()) {
2200 std::tie(
Name, PipelineText) = PipelineText.
split(
',');
2201 if (!parseAAPassName(AA,
Name))
2202 return make_error<StringError>(
2203 formatv(
"unknown alias analysis name '{0}'",
Name).str(),
2210std::optional<RegAllocFilterFunc>
2212 if (FilterName ==
"all")
2214 for (
auto &
C : RegClassFilterParsingCallbacks)
2215 if (
auto F =
C(FilterName))
2217 return std::nullopt;
2225 OS <<
" " <<
PassName <<
"<" << Params <<
">\n";
2231 OS <<
"Module passes:\n";
2232#define MODULE_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2233#include "PassRegistry.def"
2235 OS <<
"Module passes with params:\n";
2236#define MODULE_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
2237 printPassName(NAME, PARAMS, OS);
2238#include "PassRegistry.def"
2240 OS <<
"Module analyses:\n";
2241#define MODULE_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2242#include "PassRegistry.def"
2244 OS <<
"Module alias analyses:\n";
2245#define MODULE_ALIAS_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2246#include "PassRegistry.def"
2248 OS <<
"CGSCC passes:\n";
2249#define CGSCC_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2250#include "PassRegistry.def"
2252 OS <<
"CGSCC passes with params:\n";
2253#define CGSCC_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
2254 printPassName(NAME, PARAMS, OS);
2255#include "PassRegistry.def"
2257 OS <<
"CGSCC analyses:\n";
2258#define CGSCC_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2259#include "PassRegistry.def"
2261 OS <<
"Function passes:\n";
2262#define FUNCTION_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2263#include "PassRegistry.def"
2265 OS <<
"Function passes with params:\n";
2266#define FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
2267 printPassName(NAME, PARAMS, OS);
2268#include "PassRegistry.def"
2270 OS <<
"Function analyses:\n";
2271#define FUNCTION_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2272#include "PassRegistry.def"
2274 OS <<
"Function alias analyses:\n";
2275#define FUNCTION_ALIAS_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2276#include "PassRegistry.def"
2278 OS <<
"LoopNest passes:\n";
2279#define LOOPNEST_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2280#include "PassRegistry.def"
2282 OS <<
"Loop passes:\n";
2283#define LOOP_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2284#include "PassRegistry.def"
2286 OS <<
"Loop passes with params:\n";
2287#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
2288 printPassName(NAME, PARAMS, OS);
2289#include "PassRegistry.def"
2291 OS <<
"Loop analyses:\n";
2292#define LOOP_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2293#include "PassRegistry.def"
2295 OS <<
"Machine module passes (WIP):\n";
2296#define MACHINE_MODULE_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2297#include "llvm/Passes/MachinePassRegistry.def"
2299 OS <<
"Machine function passes (WIP):\n";
2300#define MACHINE_FUNCTION_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2301#include "llvm/Passes/MachinePassRegistry.def"
2303 OS <<
"Machine function analyses (WIP):\n";
2304#define MACHINE_FUNCTION_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2305#include "llvm/Passes/MachinePassRegistry.def"
2311 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
PassInstrumentationCallbacks PIC
PassBuilder PB(Machine, PassOpts->PTO, std::nullopt, &PIC)
static bool isModulePassName(StringRef Name, CallbacksT &Callbacks)
static bool callbacksAcceptPassName(StringRef Name, CallbacksT &Callbacks)
Tests whether registered callbacks will accept a given pass name.
static std::optional< int > parseDevirtPassName(StringRef Name)
static bool startsWithDefaultPipelineAliasPrefix(StringRef Name)
Tests whether a pass name starts with a valid prefix for a default pipeline alias.
static bool isLoopNestPassName(StringRef Name, CallbacksT &Callbacks, bool &UseMemorySSA)
static bool isMachineFunctionPassName(StringRef Name, CallbacksT &Callbacks)
static std::optional< OptimizationLevel > parseOptLevel(StringRef S)
static bool isLoopPassName(StringRef Name, CallbacksT &Callbacks, bool &UseMemorySSA)
static std::optional< std::pair< bool, bool > > parseFunctionPipelineName(StringRef Name)
static bool isCGSCCPassName(StringRef Name, CallbacksT &Callbacks)
static void printPassName(StringRef PassName, raw_ostream &OS)
static bool isFunctionPassName(StringRef Name, CallbacksT &Callbacks)
static const Regex DefaultAliasRegex("^(default|thinlto-pre-link|thinlto|lto-pre-link|lto)<(O[0123sz])>$")
This header defines various interfaces for pass management in LLVM.
This file implements the PredicateInfo analysis, which creates an Extended SSA form for operations us...
This file implements relative lookup table converter that converts lookup tables to relative lookup t...
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file provides the interface for LLVM's Scalar Replacement of Aggregates pass.
This file provides the interface for the pseudo probe implementation for AutoFDO.
This file provides the interface for the sampled PGO loader pass.
This is the interface for a SCEV-based alias analysis.
This pass converts vector operations into scalar operations (or, optionally, operations on smaller ve...
This is the interface for a metadata-based scoped no-alias analysis.
This file contains the declaration of the SelectOptimizePass class, its corresponding pass name is se...
This file provides the interface for the pass responsible for both simplifying and canonicalizing the...
This file implements the StringSwitch template, which mimics a switch() statement whose cases are str...
Target-Independent Code Generator Pass Configuration Options pass.
This is the interface for a metadata-based TBAA.
static const char PassName[]
A manager for alias analyses.
Class for arbitrary precision integers.
uint64_t getZExtValue() const
Get zero extended value.
int64_t getSExtValue() const
Get sign extended value.
A container for analyses that lazily runs them and caches their results.
bool registerPass(PassBuilderT &&PassBuilder)
Register an analysis pass with the manager.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
LLVM Basic Block Representation.
const Instruction * getTerminator() const LLVM_READONLY
Returns the terminator instruction if the block is well formed or null if the block is not well forme...
Lightweight error class with error context and mandatory checking.
static ErrorSuccess success()
Create a success value.
Tagged union holding either a T or a Error.
static GlobalAlias * create(Type *Ty, unsigned AddressSpace, LinkageTypes Linkage, const Twine &Name, Constant *Aliasee, Module *Parent)
If a parent module is specified, the alias is automatically inserted into the end of the specified mo...
An analysis over an "outer" IR unit that provides access to an analysis manager over an "inner" IR un...
static constexpr LLT scalar(unsigned SizeInBits)
Get a low-level scalar or aggregate "bag of bits".
An RAII based helper class to modify MachineFunctionProperties when running pass.
Properties which a MachineFunction may have at a given point in time.
MachineFunctionProperties & set(Property P)
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
const MachineFunctionProperties & getProperties() const
Get the function properties.
A Module instance is used to store all the information related to an LLVM module.
static const OptimizationLevel O3
Optimize for fast execution as much as possible.
static const OptimizationLevel Oz
A very specialized mode that will optimize for code size at any and all costs.
static const OptimizationLevel O0
Disable as many optimizations as possible.
static const OptimizationLevel Os
Similar to O2 but tries to optimize for small code size instead of fast execution without triggering ...
static const OptimizationLevel O2
Optimize for fast execution as much as possible without triggering significant incremental compile ti...
static const OptimizationLevel O1
Optimize quickly without destroying debuggability.
This class provides access to building LLVM's passes.
void printPassNames(raw_ostream &OS)
Print pass names.
static bool checkParametrizedPassName(StringRef Name, StringRef PassName)
AAManager buildDefaultAAPipeline()
Build the default AAManager with the default alias analysis pipeline registered.
Error parseAAPipeline(AAManager &AA, StringRef PipelineText)
Parse a textual alias analysis pipeline into the provided AA manager.
ModulePassManager buildThinLTOPreLinkDefaultPipeline(OptimizationLevel Level)
Build a pre-link, ThinLTO-targeting default optimization pipeline to a pass manager.
PassBuilder(TargetMachine *TM=nullptr, PipelineTuningOptions PTO=PipelineTuningOptions(), std::optional< PGOOptions > PGOOpt=std::nullopt, PassInstrumentationCallbacks *PIC=nullptr)
void registerLoopAnalyses(LoopAnalysisManager &LAM)
Registers all available loop analysis passes.
std::optional< RegAllocFilterFunc > parseRegAllocFilter(StringRef RegAllocFilterName)
Parse RegAllocFilterName to get RegAllocFilterFunc.
void crossRegisterProxies(LoopAnalysisManager &LAM, FunctionAnalysisManager &FAM, CGSCCAnalysisManager &CGAM, ModuleAnalysisManager &MAM, MachineFunctionAnalysisManager *MFAM=nullptr)
Cross register the analysis managers through their proxies.
ModulePassManager buildPerModuleDefaultPipeline(OptimizationLevel Level, bool LTOPreLink=false)
Build a per-module default optimization pipeline.
Error parsePassPipeline(ModulePassManager &MPM, StringRef PipelineText)
Parse a textual pass pipeline description into a ModulePassManager.
ModulePassManager buildLTODefaultPipeline(OptimizationLevel Level, ModuleSummaryIndex *ExportSummary)
Build an LTO default optimization pipeline to a pass manager.
ModulePassManager buildThinLTODefaultPipeline(OptimizationLevel Level, const ModuleSummaryIndex *ImportSummary)
Build a ThinLTO default optimization pipeline to a pass manager.
void registerModuleAnalyses(ModuleAnalysisManager &MAM)
Registers all available module analysis passes.
void registerCGSCCAnalyses(CGSCCAnalysisManager &CGAM)
Registers all available CGSCC analysis passes.
static Expected< bool > parseSinglePassOption(StringRef Params, StringRef OptionName, StringRef PassName)
Handle passes only accept one bool-valued parameter.
void registerMachineFunctionAnalyses(MachineFunctionAnalysisManager &MFAM)
Registers all available machine function analysis passes.
void registerParseTopLevelPipelineCallback(const std::function< bool(ModulePassManager &, ArrayRef< PipelineElement >)> &C)
Register a callback for a top-level pipeline entry.
ModulePassManager buildLTOPreLinkDefaultPipeline(OptimizationLevel Level)
Build a pre-link, LTO-targeting default optimization pipeline to a pass manager.
void registerFunctionAnalyses(FunctionAnalysisManager &FAM)
Registers all available function analysis passes.
This class manages callbacks registration, as well as provides a way for PassInstrumentation to pass ...
void registerClassToPassNameCallback(CallableT C)
LLVM_ATTRIBUTE_MINSIZE std::enable_if_t< is_detected< HasRunOnLoopT, PassT >::value > addPass(PassT &&Pass)
LLVM_ATTRIBUTE_MINSIZE std::enable_if_t<!std::is_same_v< PassT, PassManager > > addPass(PassT &&Pass)
Tunable parameters for passes in the default pipelines.
bool SLPVectorization
Tuning option to enable/disable slp loop vectorization, set based on opt level.
bool LoopVectorization
Tuning option to enable/disable loop vectorization, set based on opt level.
static PointerType * getUnqual(Type *ElementType)
This constructs a pointer to an object of the specified type in the default address space (address sp...
A set of analyses that are preserved following a run of a transformation pass.
static PreservedAnalyses none()
Convenience factory function for the empty preserved set.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
bool match(StringRef String, SmallVectorImpl< StringRef > *Matches=nullptr, std::string *Error=nullptr) const
matches - Match the regex against a given String.
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringRef - Represent a constant reference to a string, i.e.
std::pair< StringRef, StringRef > split(char Separator) const
Split into two substrings around the first occurrence of a separator character.
bool getAsInteger(unsigned Radix, T &Result) const
Parse the current string as an integer of the specified radix.
std::string str() const
str - Get the contents as an std::string.
constexpr bool empty() const
empty - Check if the string is empty.
char front() const
front - Get the first character in the string.
bool consume_front(StringRef Prefix)
Returns true if this StringRef has the given prefix and removes that prefix.
A switch()-like statement whose cases are string literals.
StringSwitch & Case(StringLiteral S, T Value)
Primary interface to the complete machine description for the target machine.
This function has undefined behavior.
self_iterator getIterator()
This class implements an extremely fast bulk output stream that can only output to a stream.
Interfaces for registering analysis passes, producing common pass manager configurations,...
@ C
The default llvm calling convention, compatible with C.
PointerTypeMap run(const Module &M)
Compute the PointerTypeMap for the module M.
This is an optimization pass for GlobalISel generic memory operations.
ModuleToFunctionPassAdaptor createModuleToFunctionPassAdaptor(FunctionPassT &&Pass, bool EagerlyInvalidate=false)
A function to deduce a function pass type and wrap it in the templated adaptor.
DevirtSCCRepeatedPass createDevirtSCCRepeatedPass(CGSCCPassT &&Pass, int MaxIterations)
A function to deduce a function pass type and wrap it in the templated adaptor.
std::error_code inconvertibleErrorCode()
The value returned by this function can be returned from convertToErrorCode for Error values where no...
auto formatv(const char *Fmt, Ts &&...Vals) -> formatv_object< decltype(std::make_tuple(support::detail::build_format_adapter(std::forward< Ts >(Vals))...))>
OuterAnalysisManagerProxy< ModuleAnalysisManager, MachineFunction > ModuleAnalysisManagerMachineFunctionProxy
Provide the ModuleAnalysisManager to Function proxy.
OuterAnalysisManagerProxy< ModuleAnalysisManager, Function > ModuleAnalysisManagerFunctionProxy
Provide the ModuleAnalysisManager to Function proxy.
InnerAnalysisManagerProxy< MachineFunctionAnalysisManager, Module > MachineFunctionAnalysisManagerModuleProxy
OuterAnalysisManagerProxy< ModuleAnalysisManager, LazyCallGraph::SCC, LazyCallGraph & > ModuleAnalysisManagerCGSCCProxy
A proxy from a ModuleAnalysisManager to an SCC.
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly.
ModuleToPostOrderCGSCCPassAdaptor createModuleToPostOrderCGSCCPassAdaptor(CGSCCPassT &&Pass)
A function to deduce a function pass type and wrap it in the templated adaptor.
CGSCCToFunctionPassAdaptor createCGSCCToFunctionPassAdaptor(FunctionPassT &&Pass, bool EagerlyInvalidate=false, bool NoRerun=false)
A function to deduce a function pass type and wrap it in the templated adaptor.
InnerAnalysisManagerProxy< FunctionAnalysisManager, Module > FunctionAnalysisManagerModuleProxy
Provide the FunctionAnalysisManager to Module proxy.
FunctionToMachineFunctionPassAdaptor createFunctionToMachineFunctionPassAdaptor(MachineFunctionPassT &&Pass)
InnerAnalysisManagerProxy< MachineFunctionAnalysisManager, Function > MachineFunctionAnalysisManagerFunctionProxy
OuterAnalysisManagerProxy< FunctionAnalysisManager, Loop, LoopStandardAnalysisResults & > FunctionAnalysisManagerLoopProxy
A proxy from a FunctionAnalysisManager to a Loop.
cl::opt< bool > PrintPipelinePasses
Common option used by multiple tools to print pipeline passes.
OuterAnalysisManagerProxy< CGSCCAnalysisManager, Function > CGSCCAnalysisManagerFunctionProxy
A proxy from a CGSCCAnalysisManager to a Function.
std::enable_if_t< is_detected< HasRunOnLoopT, LoopPassT >::value, FunctionToLoopPassAdaptor > createFunctionToLoopPassAdaptor(LoopPassT &&Pass, bool UseMemorySSA=false, bool UseBlockFrequencyInfo=false, bool UseBranchProbabilityInfo=false)
A function to deduce a loop pass type and wrap it in the templated adaptor.
A special type used by analysis passes to provide an address that identifies that particular analysis...
A set of parameters to control various transforms performed by GVN pass.
HardwareLoopOptions & setForceNested(bool Force)
HardwareLoopOptions & setDecrement(unsigned Count)
HardwareLoopOptions & setForceGuard(bool Force)
HardwareLoopOptions & setForce(bool Force)
HardwareLoopOptions & setCounterBitwidth(unsigned Width)
HardwareLoopOptions & setForcePhi(bool Force)
A set of parameters to control various transforms performed by IPSCCP pass.
A set of parameters used to control various transforms performed by the LoopUnroll pass.
LoopUnrollOptions & setPeeling(bool Peeling)
Enables or disables loop peeling.
LoopUnrollOptions & setOptLevel(int O)
LoopUnrollOptions & setPartial(bool Partial)
Enables or disables partial unrolling.
LoopUnrollOptions & setFullUnrollMaxCount(unsigned O)
LoopUnrollOptions & setUpperBound(bool UpperBound)
Enables or disables the use of trip count upper bound in loop unrolling.
LoopUnrollOptions & setRuntime(bool Runtime)
Enables or disables unrolling of loops with runtime trip count.
LoopUnrollOptions & setProfileBasedPeeling(int O)
LoopVectorizeOptions & setVectorizeOnlyWhenForced(bool Value)
LoopVectorizeOptions & setInterleaveOnlyWhenForced(bool Value)
A CRTP mix-in to automatically provide informational APIs needed for passes.
static StringRef name()
Gets the name of the pass we are mixed into.
RegAllocFilterFunc Filter