303 "^(default|thinlto-pre-link|thinlto|lto-pre-link|lto)<(O[0123sz])>$");
307 "print-pipeline-passes",
308 cl::desc(
"Print a '-passes' compatible string describing the pipeline "
309 "(best-effort only)."));
325bool shouldPopulateClassToPassNames() {
333class TriggerCrashPass :
public PassInfoMixin<TriggerCrashPass> {
344class TriggerVerifierErrorPass
352 GlobalValue::LinkageTypes::InternalLinkage,
353 "__bad_alias",
nullptr, &M);
365 static StringRef name() {
return "TriggerVerifierErrorPass"; }
370class RequireAllMachineFunctionPropertiesPass
371 :
public PassInfoMixin<RequireAllMachineFunctionPropertiesPass> {
379 MFProps.
set(MachineFunctionProperties::Property::FailedISel);
380 MFProps.
set(MachineFunctionProperties::Property::FailsVerification);
381 MFProps.
set(MachineFunctionProperties::Property::IsSSA);
382 MFProps.
set(MachineFunctionProperties::Property::Legalized);
383 MFProps.
set(MachineFunctionProperties::Property::NoPHIs);
384 MFProps.
set(MachineFunctionProperties::Property::NoVRegs);
385 MFProps.
set(MachineFunctionProperties::Property::RegBankSelected);
386 MFProps.
set(MachineFunctionProperties::Property::Selected);
387 MFProps.
set(MachineFunctionProperties::Property::TiedOpsRewritten);
388 MFProps.
set(MachineFunctionProperties::Property::TracksDebugUserValues);
389 MFProps.
set(MachineFunctionProperties::Property::TracksLiveness);
392 static StringRef name() {
return "RequireAllMachineFunctionPropertiesPass"; }
398 std::optional<PGOOptions> PGOOpt,
400 :
TM(
TM), PTO(PTO), PGOOpt(PGOOpt),
PIC(
PIC) {
401 bool ShouldPopulateClassToPassNames =
PIC && shouldPopulateClassToPassNames();
403 TM->registerPassBuilderCallbacks(*
this, ShouldPopulateClassToPassNames);
404 if (ShouldPopulateClassToPassNames) {
405#define MODULE_PASS(NAME, CREATE_PASS) \
406 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
407#define MODULE_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
408 PIC->addClassToPassName(CLASS, NAME);
409#define MODULE_ANALYSIS(NAME, CREATE_PASS) \
410 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
411#define FUNCTION_PASS(NAME, CREATE_PASS) \
412 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
413#define FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
414 PIC->addClassToPassName(CLASS, NAME);
415#define FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
416 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
417#define LOOPNEST_PASS(NAME, CREATE_PASS) \
418 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
419#define LOOP_PASS(NAME, CREATE_PASS) \
420 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
421#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
422 PIC->addClassToPassName(CLASS, NAME);
423#define LOOP_ANALYSIS(NAME, CREATE_PASS) \
424 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
425#define CGSCC_PASS(NAME, CREATE_PASS) \
426 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
427#define CGSCC_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
428 PIC->addClassToPassName(CLASS, NAME);
429#define CGSCC_ANALYSIS(NAME, CREATE_PASS) \
430 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
431#include "PassRegistry.def"
433#define MACHINE_FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
434 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
435#define MACHINE_FUNCTION_PASS(NAME, CREATE_PASS) \
436 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
437#include "llvm/Passes/MachinePassRegistry.def"
442#define MODULE_ANALYSIS(NAME, CREATE_PASS) \
443 MAM.registerPass([&] { return CREATE_PASS; });
444#include "PassRegistry.def"
446 for (
auto &
C : ModuleAnalysisRegistrationCallbacks)
451#define CGSCC_ANALYSIS(NAME, CREATE_PASS) \
452 CGAM.registerPass([&] { return CREATE_PASS; });
453#include "PassRegistry.def"
455 for (
auto &
C : CGSCCAnalysisRegistrationCallbacks)
465#define FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
466 FAM.registerPass([&] { return CREATE_PASS; });
467#include "PassRegistry.def"
469 for (
auto &
C : FunctionAnalysisRegistrationCallbacks)
476#define MACHINE_FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
477 MFAM.registerPass([&] { return CREATE_PASS; });
478#include "llvm/Passes/MachinePassRegistry.def"
480 for (
auto &
C : MachineFunctionAnalysisRegistrationCallbacks)
485#define LOOP_ANALYSIS(NAME, CREATE_PASS) \
486 LAM.registerPass([&] { return CREATE_PASS; });
487#include "PassRegistry.def"
489 for (
auto &
C : LoopAnalysisRegistrationCallbacks)
494 if (!
Name.consume_front(
"repeat<") || !
Name.consume_back(
">"))
497 if (
Name.getAsInteger(0, Count) || Count <= 0)
502static std::optional<std::pair<bool, bool>>
504 std::pair<bool, bool> Params;
505 if (!
Name.consume_front(
"function"))
509 if (!
Name.consume_front(
"<") || !
Name.consume_back(
">"))
511 while (!
Name.empty()) {
512 auto [Front, Back] =
Name.split(
';');
514 if (Front ==
"eager-inv")
516 else if (Front ==
"no-rerun")
517 Params.second =
true;
525 if (!
Name.consume_front(
"devirt<") || !
Name.consume_back(
">"))
528 if (
Name.getAsInteger(0, Count) || Count < 0)
548 while (!Params.
empty()) {
550 std::tie(ParamName, Params) = Params.
split(
';');
552 if (ParamName == OptionName) {
555 return make_error<StringError>(
570 while (!Params.
empty()) {
572 std::tie(ParamName, Params) = Params.
split(
';');
576 return make_error<StringError>(
577 formatv(
"invalid HardwareLoopPass parameter '{0}' ", ParamName).str(),
582 if (ParamName.
consume_front(
"hardware-loop-counter-bitwidth=")) {
585 return make_error<StringError>(
586 formatv(
"invalid HardwareLoopPass parameter '{0}' ", ParamName).str(),
591 if (ParamName ==
"force-hardware-loops") {
593 }
else if (ParamName ==
"force-hardware-loop-phi") {
595 }
else if (ParamName ==
"force-nested-hardware-loop") {
597 }
else if (ParamName ==
"force-hardware-loop-guard") {
600 return make_error<StringError>(
601 formatv(
"invalid HardwarePass parameter '{0}' ", ParamName).str(),
605 return HardwareLoopOpts;
611 while (!Params.
empty()) {
613 std::tie(ParamName, Params) = Params.
split(
';');
614 std::optional<OptimizationLevel> OptLevel =
parseOptLevel(ParamName);
616 if (OptLevel && !OptLevel->isOptimizingForSize()) {
617 UnrollOpts.
setOptLevel(OptLevel->getSpeedupLevel());
623 return make_error<StringError>(
624 formatv(
"invalid LoopUnrollPass parameter '{0}' ", ParamName).str(),
631 if (ParamName ==
"partial") {
633 }
else if (ParamName ==
"peeling") {
635 }
else if (ParamName ==
"profile-peeling") {
637 }
else if (ParamName ==
"runtime") {
639 }
else if (ParamName ==
"upperbound") {
642 return make_error<StringError>(
643 formatv(
"invalid LoopUnrollPass parameter '{0}' ", ParamName).str(),
652 Params,
"vfe-linkage-unit-visibility",
"GlobalDCE");
672 Params,
"skip-non-recursive-function-attrs",
"PostOrderFunctionAttrs");
681 return make_error<StringError>(
682 formatv(
"too many CFGuardPass parameters '{0}' ", Params).str(),
685 if (Param ==
"check")
687 if (Param ==
"dispatch")
690 return make_error<StringError>(
691 formatv(
"invalid CFGuardPass mechanism: '{0}' ", Param).str(),
701 "EntryExitInstrumenter");
710 "LowerMatrixIntrinsics");
715 while (!Params.
empty()) {
717 std::tie(ParamName, Params) = Params.
split(
';');
719 if (ParamName ==
"kernel") {
720 Result.CompileKernel =
true;
722 return make_error<StringError>(
723 formatv(
"invalid AddressSanitizer pass parameter '{0}' ", ParamName)
733 while (!Params.
empty()) {
735 std::tie(ParamName, Params) = Params.
split(
';');
737 if (ParamName ==
"recover") {
739 }
else if (ParamName ==
"kernel") {
740 Result.CompileKernel =
true;
742 return make_error<StringError>(
743 formatv(
"invalid HWAddressSanitizer pass parameter '{0}' ", ParamName)
753 while (!Params.
empty()) {
755 std::tie(ParamName, Params) = Params.
split(
';');
757 if (ParamName ==
"thinlto") {
759 }
else if (ParamName ==
"emit-summary") {
760 Result.EmitLTOSummary =
true;
762 return make_error<StringError>(
763 formatv(
"invalid EmbedBitcode pass parameter '{0}' ", ParamName)
773 while (!Params.
empty()) {
775 std::tie(ParamName, Params) = Params.
split(
';');
777 if (ParamName ==
"recover") {
779 }
else if (ParamName ==
"kernel") {
783 return make_error<StringError>(
784 formatv(
"invalid argument to MemorySanitizer pass track-origins "
789 }
else if (ParamName ==
"eager-checks") {
790 Result.EagerChecks =
true;
792 return make_error<StringError>(
793 formatv(
"invalid MemorySanitizer pass parameter '{0}' ", ParamName)
804 while (!Params.
empty()) {
806 std::tie(ParamName, Params) = Params.
split(
';');
809 if (ParamName ==
"speculate-blocks") {
811 }
else if (ParamName ==
"simplify-cond-branch") {
813 }
else if (ParamName ==
"forward-switch-cond") {
815 }
else if (ParamName ==
"switch-range-to-icmp") {
817 }
else if (ParamName ==
"switch-to-lookup") {
819 }
else if (ParamName ==
"keep-loops") {
821 }
else if (ParamName ==
"hoist-common-insts") {
823 }
else if (ParamName ==
"sink-common-insts") {
826 APInt BonusInstThreshold;
828 return make_error<StringError>(
829 formatv(
"invalid argument to SimplifyCFG pass bonus-threshold "
835 return make_error<StringError>(
836 formatv(
"invalid SimplifyCFG pass parameter '{0}' ", ParamName).str(),
847 Result.setVerifyFixpoint(
true);
848 while (!Params.
empty()) {
850 std::tie(ParamName, Params) = Params.
split(
';');
853 if (ParamName ==
"use-loop-info") {
855 }
else if (ParamName ==
"verify-fixpoint") {
860 return make_error<StringError>(
861 formatv(
"invalid argument to InstCombine pass max-iterations "
867 return make_error<StringError>(
868 formatv(
"invalid InstCombine pass parameter '{0}' ", ParamName).str(),
878 while (!Params.
empty()) {
880 std::tie(ParamName, Params) = Params.
split(
';');
883 if (ParamName ==
"interleave-forced-only") {
885 }
else if (ParamName ==
"vectorize-forced-only") {
888 return make_error<StringError>(
889 formatv(
"invalid LoopVectorize parameter '{0}' ", ParamName).str(),
897 std::pair<bool, bool>
Result = {
false,
true};
898 while (!Params.
empty()) {
900 std::tie(ParamName, Params) = Params.
split(
';');
903 if (ParamName ==
"nontrivial") {
905 }
else if (ParamName ==
"trivial") {
908 return make_error<StringError>(
909 formatv(
"invalid LoopUnswitch pass parameter '{0}' ", ParamName)
919 while (!Params.
empty()) {
921 std::tie(ParamName, Params) = Params.
split(
';');
924 if (ParamName ==
"allowspeculation") {
927 return make_error<StringError>(
928 formatv(
"invalid LICM pass parameter '{0}' ", ParamName).str(),
936 std::pair<bool, bool>
Result = {
true,
false};
937 while (!Params.
empty()) {
939 std::tie(ParamName, Params) = Params.
split(
';');
942 if (ParamName ==
"header-duplication") {
944 }
else if (ParamName ==
"prepare-for-lto") {
947 return make_error<StringError>(
948 formatv(
"invalid LoopRotate pass parameter '{0}' ", ParamName).str(),
957 while (!Params.
empty()) {
959 std::tie(ParamName, Params) = Params.
split(
';');
962 if (ParamName ==
"split-footer-bb") {
965 return make_error<StringError>(
966 formatv(
"invalid MergedLoadStoreMotion pass parameter '{0}' ",
977 while (!Params.
empty()) {
979 std::tie(ParamName, Params) = Params.
split(
';');
982 if (ParamName ==
"pre") {
984 }
else if (ParamName ==
"load-pre") {
986 }
else if (ParamName ==
"split-backedge-load-pre") {
988 }
else if (ParamName ==
"memdep") {
991 return make_error<StringError>(
992 formatv(
"invalid GVN pass parameter '{0}' ", ParamName).str(),
1001 while (!Params.
empty()) {
1003 std::tie(ParamName, Params) = Params.
split(
';');
1006 if (ParamName ==
"func-spec")
1009 return make_error<StringError>(
1010 formatv(
"invalid IPSCCP pass parameter '{0}' ", ParamName).str(),
1017 if (Params.
empty() || Params ==
"modify-cfg")
1019 if (Params ==
"preserve-cfg")
1021 return make_error<StringError>(
1022 formatv(
"invalid SROA pass parameter '{0}' (either preserve-cfg or "
1023 "modify-cfg can be specified)",
1030parseStackLifetimeOptions(
StringRef Params) {
1032 while (!Params.
empty()) {
1034 std::tie(ParamName, Params) = Params.
split(
';');
1036 if (ParamName ==
"may") {
1038 }
else if (ParamName ==
"must") {
1041 return make_error<StringError>(
1042 formatv(
"invalid StackLifetime parameter '{0}' ", ParamName).str(),
1051 "DependenceAnalysisPrinter");
1056 "SeparateConstOffsetFromGEP");
1060parseFunctionSimplificationPipelineOptions(
StringRef Params) {
1063 return make_error<StringError>(
1064 formatv(
"invalid function-simplification parameter '{0}' ", Params)
1073 "MemorySSAPrinterPass");
1078 "SpeculativeExecutionPass");
1083 while (!Params.
empty()) {
1085 std::tie(ParamName, Params) = Params.
split(
';');
1090 return make_error<StringError>(
1091 formatv(
"invalid MemProfUse pass parameter '{0}' ", ParamName).str(),
1100 "StructuralHashPrinterPass");
1105 "WinEHPreparePass");
1110 while (!Params.
empty()) {
1112 std::tie(ParamName, Params) = Params.
split(
';');
1115 if (ParamName ==
"group-by-use")
1117 else if (ParamName ==
"ignore-single-use")
1119 else if (ParamName ==
"merge-const")
1121 else if (ParamName ==
"merge-external")
1125 return make_error<StringError>(
1126 formatv(
"invalid GlobalMergePass parameter '{0}' ", ParamName)
1139 return Name.starts_with(
"default") ||
Name.starts_with(
"thinlto") ||
1140 Name.starts_with(
"lto");
1151template <
typename PassManagerT,
typename CallbacksT>
1153 if (!Callbacks.empty()) {
1154 PassManagerT DummyPM;
1155 for (
auto &CB : Callbacks)
1156 if (CB(
Name, DummyPM, {}))
1162template <
typename CallbacksT>
1168 StringRef NameNoBracket =
Name.take_until([](
char C) {
return C ==
'<'; });
1171 if (
Name ==
"module")
1173 if (
Name ==
"cgscc")
1175 if (NameNoBracket ==
"function")
1177 if (
Name ==
"coro-cond")
1184#define MODULE_PASS(NAME, CREATE_PASS) \
1187#define MODULE_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1188 if (PassBuilder::checkParametrizedPassName(Name, NAME)) \
1190#define MODULE_ANALYSIS(NAME, CREATE_PASS) \
1191 if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
1193#include "PassRegistry.def"
1195 return callbacksAcceptPassName<ModulePassManager>(
Name, Callbacks);
1198template <
typename CallbacksT>
1201 StringRef NameNoBracket =
Name.take_until([](
char C) {
return C ==
'<'; });
1202 if (
Name ==
"cgscc")
1204 if (NameNoBracket ==
"function")
1213#define CGSCC_PASS(NAME, CREATE_PASS) \
1216#define CGSCC_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1217 if (PassBuilder::checkParametrizedPassName(Name, NAME)) \
1219#define CGSCC_ANALYSIS(NAME, CREATE_PASS) \
1220 if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
1222#include "PassRegistry.def"
1224 return callbacksAcceptPassName<CGSCCPassManager>(
Name, Callbacks);
1227template <
typename CallbacksT>
1230 StringRef NameNoBracket =
Name.take_until([](
char C) {
return C ==
'<'; });
1231 if (NameNoBracket ==
"function")
1233 if (
Name ==
"loop" ||
Name ==
"loop-mssa" ||
Name ==
"machine-function")
1240#define FUNCTION_PASS(NAME, CREATE_PASS) \
1243#define FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1244 if (PassBuilder::checkParametrizedPassName(Name, NAME)) \
1246#define FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
1247 if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
1249#include "PassRegistry.def"
1251 return callbacksAcceptPassName<FunctionPassManager>(
Name, Callbacks);
1254template <
typename CallbacksT>
1257 if (
Name ==
"machine-function")
1264#define MACHINE_FUNCTION_PASS(NAME, CREATE_PASS) \
1267#define MACHINE_FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
1268 if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
1271#include "llvm/Passes/MachinePassRegistry.def"
1273 return callbacksAcceptPassName<MachineFunctionPassManager>(
Name, Callbacks);
1276template <
typename CallbacksT>
1278 bool &UseMemorySSA) {
1279 UseMemorySSA =
false;
1286 UseMemorySSA =
true;
1290#define LOOPNEST_PASS(NAME, CREATE_PASS) \
1293#include "PassRegistry.def"
1295 return callbacksAcceptPassName<LoopPassManager>(
Name, Callbacks);
1298template <
typename CallbacksT>
1300 bool &UseMemorySSA) {
1301 UseMemorySSA =
false;
1308 UseMemorySSA =
true;
1312#define LOOP_PASS(NAME, CREATE_PASS) \
1315#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1316 if (PassBuilder::checkParametrizedPassName(Name, NAME)) \
1318#define LOOP_ANALYSIS(NAME, CREATE_PASS) \
1319 if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \
1321#include "PassRegistry.def"
1323 return callbacksAcceptPassName<LoopPassManager>(
Name, Callbacks);
1326std::optional<std::vector<PassBuilder::PipelineElement>>
1327PassBuilder::parsePipelineText(
StringRef Text) {
1328 std::vector<PipelineElement> ResultPipeline;
1333 std::vector<PipelineElement> &Pipeline = *PipelineStack.
back();
1334 size_t Pos =
Text.find_first_of(
",()");
1335 Pipeline.push_back({
Text.substr(0, Pos), {}});
1338 if (Pos ==
Text.npos)
1341 char Sep =
Text[Pos];
1349 PipelineStack.
push_back(&Pipeline.back().InnerPipeline);
1353 assert(Sep ==
')' &&
"Bogus separator!");
1358 if (PipelineStack.
size() == 1)
1359 return std::nullopt;
1362 }
while (
Text.consume_front(
")"));
1370 if (!
Text.consume_front(
","))
1371 return std::nullopt;
1374 if (PipelineStack.
size() > 1)
1376 return std::nullopt;
1378 assert(PipelineStack.
back() == &ResultPipeline &&
1379 "Wrong pipeline at the bottom of the stack!");
1380 return {std::move(ResultPipeline)};
1384 const PipelineElement &E) {
1385 auto &
Name = E.Name;
1386 auto &InnerPipeline = E.InnerPipeline;
1389 if (!InnerPipeline.empty()) {
1390 if (
Name ==
"module") {
1392 if (
auto Err = parseModulePassPipeline(NestedMPM, InnerPipeline))
1397 if (
Name ==
"coro-cond") {
1399 if (
auto Err = parseModulePassPipeline(NestedMPM, InnerPipeline))
1404 if (
Name ==
"cgscc") {
1406 if (
auto Err = parseCGSCCPassPipeline(CGPM, InnerPipeline))
1413 return make_error<StringError>(
1414 "cannot have a no-rerun module to function adaptor",
1417 if (
auto Err = parseFunctionPassPipeline(FPM, InnerPipeline))
1425 if (
auto Err = parseModulePassPipeline(NestedMPM, InnerPipeline))
1431 for (
auto &
C : ModulePipelineParsingCallbacks)
1436 return make_error<StringError>(
1437 formatv(
"invalid use of '{0}' pass as module pipeline",
Name).str(),
1446 return make_error<StringError>(
1447 formatv(
"unknown default pipeline alias '{0}'",
Name).str(),
1450 assert(Matches.
size() == 3 &&
"Must capture two matched strings!");
1462 if (Matches[1] ==
"default") {
1464 }
else if (Matches[1] ==
"thinlto-pre-link") {
1466 }
else if (Matches[1] ==
"thinlto") {
1468 }
else if (Matches[1] ==
"lto-pre-link") {
1477 assert(Matches[1] ==
"lto" &&
"Not one of the matched options!");
1484#define MODULE_PASS(NAME, CREATE_PASS) \
1485 if (Name == NAME) { \
1486 MPM.addPass(CREATE_PASS); \
1487 return Error::success(); \
1489#define MODULE_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1490 if (checkParametrizedPassName(Name, NAME)) { \
1491 auto Params = parsePassParameters(PARSER, Name, NAME); \
1493 return Params.takeError(); \
1494 MPM.addPass(CREATE_PASS(Params.get())); \
1495 return Error::success(); \
1497#define MODULE_ANALYSIS(NAME, CREATE_PASS) \
1498 if (Name == "require<" NAME ">") { \
1500 RequireAnalysisPass< \
1501 std::remove_reference_t<decltype(CREATE_PASS)>, Module>()); \
1502 return Error::success(); \
1504 if (Name == "invalidate<" NAME ">") { \
1505 MPM.addPass(InvalidateAnalysisPass< \
1506 std::remove_reference_t<decltype(CREATE_PASS)>>()); \
1507 return Error::success(); \
1509#define CGSCC_PASS(NAME, CREATE_PASS) \
1510 if (Name == NAME) { \
1511 MPM.addPass(createModuleToPostOrderCGSCCPassAdaptor(CREATE_PASS)); \
1512 return Error::success(); \
1514#define CGSCC_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1515 if (checkParametrizedPassName(Name, NAME)) { \
1516 auto Params = parsePassParameters(PARSER, Name, NAME); \
1518 return Params.takeError(); \
1520 createModuleToPostOrderCGSCCPassAdaptor(CREATE_PASS(Params.get()))); \
1521 return Error::success(); \
1523#define FUNCTION_PASS(NAME, CREATE_PASS) \
1524 if (Name == NAME) { \
1525 MPM.addPass(createModuleToFunctionPassAdaptor(CREATE_PASS)); \
1526 return Error::success(); \
1528#define FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1529 if (checkParametrizedPassName(Name, NAME)) { \
1530 auto Params = parsePassParameters(PARSER, Name, NAME); \
1532 return Params.takeError(); \
1533 MPM.addPass(createModuleToFunctionPassAdaptor(CREATE_PASS(Params.get()))); \
1534 return Error::success(); \
1536#define LOOPNEST_PASS(NAME, CREATE_PASS) \
1537 if (Name == NAME) { \
1538 MPM.addPass(createModuleToFunctionPassAdaptor( \
1539 createFunctionToLoopPassAdaptor(CREATE_PASS, false, false))); \
1540 return Error::success(); \
1542#define LOOP_PASS(NAME, CREATE_PASS) \
1543 if (Name == NAME) { \
1544 MPM.addPass(createModuleToFunctionPassAdaptor( \
1545 createFunctionToLoopPassAdaptor(CREATE_PASS, false, false))); \
1546 return Error::success(); \
1548#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1549 if (checkParametrizedPassName(Name, NAME)) { \
1550 auto Params = parsePassParameters(PARSER, Name, NAME); \
1552 return Params.takeError(); \
1554 createModuleToFunctionPassAdaptor(createFunctionToLoopPassAdaptor( \
1555 CREATE_PASS(Params.get()), false, false))); \
1556 return Error::success(); \
1558#include "PassRegistry.def"
1560 for (
auto &
C : ModulePipelineParsingCallbacks)
1563 return make_error<StringError>(
1569 const PipelineElement &E) {
1570 auto &
Name = E.Name;
1571 auto &InnerPipeline = E.InnerPipeline;
1574 if (!InnerPipeline.empty()) {
1575 if (
Name ==
"cgscc") {
1577 if (
auto Err = parseCGSCCPassPipeline(NestedCGPM, InnerPipeline))
1580 CGPM.
addPass(std::move(NestedCGPM));
1585 if (
auto Err = parseFunctionPassPipeline(FPM, InnerPipeline))
1589 std::move(FPM), Params->first, Params->second));
1594 if (
auto Err = parseCGSCCPassPipeline(NestedCGPM, InnerPipeline))
1601 if (
auto Err = parseCGSCCPassPipeline(NestedCGPM, InnerPipeline))
1608 for (
auto &
C : CGSCCPipelineParsingCallbacks)
1609 if (
C(
Name, CGPM, InnerPipeline))
1613 return make_error<StringError>(
1614 formatv(
"invalid use of '{0}' pass as cgscc pipeline",
Name).str(),
1619#define CGSCC_PASS(NAME, CREATE_PASS) \
1620 if (Name == NAME) { \
1621 CGPM.addPass(CREATE_PASS); \
1622 return Error::success(); \
1624#define CGSCC_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1625 if (checkParametrizedPassName(Name, NAME)) { \
1626 auto Params = parsePassParameters(PARSER, Name, NAME); \
1628 return Params.takeError(); \
1629 CGPM.addPass(CREATE_PASS(Params.get())); \
1630 return Error::success(); \
1632#define CGSCC_ANALYSIS(NAME, CREATE_PASS) \
1633 if (Name == "require<" NAME ">") { \
1634 CGPM.addPass(RequireAnalysisPass< \
1635 std::remove_reference_t<decltype(CREATE_PASS)>, \
1636 LazyCallGraph::SCC, CGSCCAnalysisManager, LazyCallGraph &, \
1637 CGSCCUpdateResult &>()); \
1638 return Error::success(); \
1640 if (Name == "invalidate<" NAME ">") { \
1641 CGPM.addPass(InvalidateAnalysisPass< \
1642 std::remove_reference_t<decltype(CREATE_PASS)>>()); \
1643 return Error::success(); \
1645#define FUNCTION_PASS(NAME, CREATE_PASS) \
1646 if (Name == NAME) { \
1647 CGPM.addPass(createCGSCCToFunctionPassAdaptor(CREATE_PASS)); \
1648 return Error::success(); \
1650#define FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1651 if (checkParametrizedPassName(Name, NAME)) { \
1652 auto Params = parsePassParameters(PARSER, Name, NAME); \
1654 return Params.takeError(); \
1655 CGPM.addPass(createCGSCCToFunctionPassAdaptor(CREATE_PASS(Params.get()))); \
1656 return Error::success(); \
1658#define LOOPNEST_PASS(NAME, CREATE_PASS) \
1659 if (Name == NAME) { \
1660 CGPM.addPass(createCGSCCToFunctionPassAdaptor( \
1661 createFunctionToLoopPassAdaptor(CREATE_PASS, false, false))); \
1662 return Error::success(); \
1664#define LOOP_PASS(NAME, CREATE_PASS) \
1665 if (Name == NAME) { \
1666 CGPM.addPass(createCGSCCToFunctionPassAdaptor( \
1667 createFunctionToLoopPassAdaptor(CREATE_PASS, false, false))); \
1668 return Error::success(); \
1670#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1671 if (checkParametrizedPassName(Name, NAME)) { \
1672 auto Params = parsePassParameters(PARSER, Name, NAME); \
1674 return Params.takeError(); \
1676 createCGSCCToFunctionPassAdaptor(createFunctionToLoopPassAdaptor( \
1677 CREATE_PASS(Params.get()), false, false))); \
1678 return Error::success(); \
1680#include "PassRegistry.def"
1682 for (
auto &
C : CGSCCPipelineParsingCallbacks)
1683 if (
C(
Name, CGPM, InnerPipeline))
1685 return make_error<StringError>(
1691 const PipelineElement &E) {
1692 auto &
Name = E.Name;
1693 auto &InnerPipeline = E.InnerPipeline;
1696 if (!InnerPipeline.empty()) {
1697 if (
Name ==
"function") {
1699 if (
auto Err = parseFunctionPassPipeline(NestedFPM, InnerPipeline))
1702 FPM.
addPass(std::move(NestedFPM));
1705 if (
Name ==
"loop" ||
Name ==
"loop-mssa") {
1707 if (
auto Err = parseLoopPassPipeline(LPM, InnerPipeline))
1710 bool UseMemorySSA = (
Name ==
"loop-mssa");
1712 return Pipeline.Name.contains(
"simple-loop-unswitch");
1714 bool UseBPI =
llvm::any_of(InnerPipeline, [](
auto Pipeline) {
1715 return Pipeline.Name ==
"loop-predication";
1723 if (
auto Err = parseFunctionPassPipeline(NestedFPM, InnerPipeline))
1728 if (
Name ==
"machine-function") {
1730 if (
auto Err = parseMachinePassPipeline(MFPM, InnerPipeline))
1736 for (
auto &
C : FunctionPipelineParsingCallbacks)
1737 if (
C(
Name, FPM, InnerPipeline))
1741 return make_error<StringError>(
1742 formatv(
"invalid use of '{0}' pass as function pipeline",
Name).str(),
1747#define FUNCTION_PASS(NAME, CREATE_PASS) \
1748 if (Name == NAME) { \
1749 FPM.addPass(CREATE_PASS); \
1750 return Error::success(); \
1752#define FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1753 if (checkParametrizedPassName(Name, NAME)) { \
1754 auto Params = parsePassParameters(PARSER, Name, NAME); \
1756 return Params.takeError(); \
1757 FPM.addPass(CREATE_PASS(Params.get())); \
1758 return Error::success(); \
1760#define FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
1761 if (Name == "require<" NAME ">") { \
1763 RequireAnalysisPass< \
1764 std::remove_reference_t<decltype(CREATE_PASS)>, Function>()); \
1765 return Error::success(); \
1767 if (Name == "invalidate<" NAME ">") { \
1768 FPM.addPass(InvalidateAnalysisPass< \
1769 std::remove_reference_t<decltype(CREATE_PASS)>>()); \
1770 return Error::success(); \
1776#define LOOPNEST_PASS(NAME, CREATE_PASS) \
1777 if (Name == NAME) { \
1778 FPM.addPass(createFunctionToLoopPassAdaptor(CREATE_PASS, false, false)); \
1779 return Error::success(); \
1781#define LOOP_PASS(NAME, CREATE_PASS) \
1782 if (Name == NAME) { \
1783 FPM.addPass(createFunctionToLoopPassAdaptor(CREATE_PASS, false, false)); \
1784 return Error::success(); \
1786#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1787 if (checkParametrizedPassName(Name, NAME)) { \
1788 auto Params = parsePassParameters(PARSER, Name, NAME); \
1790 return Params.takeError(); \
1791 FPM.addPass(createFunctionToLoopPassAdaptor(CREATE_PASS(Params.get()), \
1793 return Error::success(); \
1795#include "PassRegistry.def"
1797 for (
auto &
C : FunctionPipelineParsingCallbacks)
1798 if (
C(
Name, FPM, InnerPipeline))
1800 return make_error<StringError>(
1801 formatv(
"unknown function pass '{0}'",
Name).str(),
1806 const PipelineElement &E) {
1808 auto &InnerPipeline = E.InnerPipeline;
1811 if (!InnerPipeline.empty()) {
1812 if (
Name ==
"loop") {
1814 if (
auto Err = parseLoopPassPipeline(NestedLPM, InnerPipeline))
1817 LPM.
addPass(std::move(NestedLPM));
1822 if (
auto Err = parseLoopPassPipeline(NestedLPM, InnerPipeline))
1828 for (
auto &
C : LoopPipelineParsingCallbacks)
1829 if (
C(
Name, LPM, InnerPipeline))
1833 return make_error<StringError>(
1834 formatv(
"invalid use of '{0}' pass as loop pipeline",
Name).str(),
1839#define LOOPNEST_PASS(NAME, CREATE_PASS) \
1840 if (Name == NAME) { \
1841 LPM.addPass(CREATE_PASS); \
1842 return Error::success(); \
1844#define LOOP_PASS(NAME, CREATE_PASS) \
1845 if (Name == NAME) { \
1846 LPM.addPass(CREATE_PASS); \
1847 return Error::success(); \
1849#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
1850 if (checkParametrizedPassName(Name, NAME)) { \
1851 auto Params = parsePassParameters(PARSER, Name, NAME); \
1853 return Params.takeError(); \
1854 LPM.addPass(CREATE_PASS(Params.get())); \
1855 return Error::success(); \
1857#define LOOP_ANALYSIS(NAME, CREATE_PASS) \
1858 if (Name == "require<" NAME ">") { \
1859 LPM.addPass(RequireAnalysisPass< \
1860 std::remove_reference_t<decltype(CREATE_PASS)>, Loop, \
1861 LoopAnalysisManager, LoopStandardAnalysisResults &, \
1863 return Error::success(); \
1865 if (Name == "invalidate<" NAME ">") { \
1866 LPM.addPass(InvalidateAnalysisPass< \
1867 std::remove_reference_t<decltype(CREATE_PASS)>>()); \
1868 return Error::success(); \
1870#include "PassRegistry.def"
1872 for (
auto &
C : LoopPipelineParsingCallbacks)
1873 if (
C(
Name, LPM, InnerPipeline))
1875 return make_error<StringError>(
formatv(
"unknown loop pass '{0}'",
Name).str(),
1880 const PipelineElement &E) {
1882 if (!E.InnerPipeline.empty())
1883 return make_error<StringError>(
"invalid pipeline",
1886#define MACHINE_MODULE_PASS(NAME, CREATE_PASS) \
1887 if (Name == NAME) { \
1888 MFPM.addPass(CREATE_PASS); \
1889 return Error::success(); \
1891#define MACHINE_FUNCTION_PASS(NAME, CREATE_PASS) \
1892 if (Name == NAME) { \
1893 MFPM.addPass(CREATE_PASS); \
1894 return Error::success(); \
1896#include "llvm/Passes/MachinePassRegistry.def"
1898 for (
auto &
C : MachineFunctionPipelineParsingCallbacks)
1899 if (
C(
Name, MFPM, E.InnerPipeline))
1901 return make_error<StringError>(
1902 formatv(
"unknown machine pass '{0}'",
Name).str(),
1907#define MODULE_ALIAS_ANALYSIS(NAME, CREATE_PASS) \
1908 if (Name == NAME) { \
1909 AA.registerModuleAnalysis< \
1910 std::remove_reference_t<decltype(CREATE_PASS)>>(); \
1913#define FUNCTION_ALIAS_ANALYSIS(NAME, CREATE_PASS) \
1914 if (Name == NAME) { \
1915 AA.registerFunctionAnalysis< \
1916 std::remove_reference_t<decltype(CREATE_PASS)>>(); \
1919#include "PassRegistry.def"
1921 for (
auto &
C : AAParsingCallbacks)
1927Error PassBuilder::parseMachinePassPipeline(
1929 for (
const auto &Element : Pipeline) {
1930 if (
auto Err = parseMachinePass(MFPM, Element))
1938 for (
const auto &Element : Pipeline) {
1939 if (
auto Err = parseLoopPass(LPM, Element))
1945Error PassBuilder::parseFunctionPassPipeline(
1947 for (
const auto &Element : Pipeline) {
1948 if (
auto Err = parseFunctionPass(FPM, Element))
1956 for (
const auto &Element : Pipeline) {
1957 if (
auto Err = parseCGSCCPass(CGPM, Element))
1989 for (
const auto &Element : Pipeline) {
1990 if (
auto Err = parseModulePass(
MPM, Element))
2001 auto Pipeline = parsePipelineText(PipelineText);
2002 if (!Pipeline || Pipeline->empty())
2003 return make_error<StringError>(
2004 formatv(
"invalid pipeline '{0}'", PipelineText).str(),
2014 Pipeline = {{
"cgscc", std::move(*Pipeline)}};
2016 FunctionPipelineParsingCallbacks)) {
2017 Pipeline = {{
"function", std::move(*Pipeline)}};
2020 Pipeline = {{
"function", {{UseMemorySSA ?
"loop-mssa" :
"loop",
2021 std::move(*Pipeline)}}}};
2022 }
else if (
isLoopPassName(FirstName, LoopPipelineParsingCallbacks,
2024 Pipeline = {{
"function", {{UseMemorySSA ?
"loop-mssa" :
"loop",
2025 std::move(*Pipeline)}}}};
2027 FirstName, MachineFunctionPipelineParsingCallbacks)) {
2028 Pipeline = {{
"function", {{
"machine-function", std::move(*Pipeline)}}}};
2030 for (
auto &
C : TopLevelPipelineParsingCallbacks)
2031 if (
C(
MPM, *Pipeline))
2035 auto &InnerPipeline = Pipeline->front().InnerPipeline;
2036 return make_error<StringError>(
2037 formatv(
"unknown {0} name '{1}'",
2038 (InnerPipeline.empty() ?
"pass" :
"pipeline"), FirstName)
2044 if (
auto Err = parseModulePassPipeline(
MPM, *Pipeline))
2052 auto Pipeline = parsePipelineText(PipelineText);
2053 if (!Pipeline || Pipeline->empty())
2054 return make_error<StringError>(
2055 formatv(
"invalid pipeline '{0}'", PipelineText).str(),
2060 return make_error<StringError>(
2061 formatv(
"unknown cgscc pass '{0}' in pipeline '{1}'", FirstName,
2066 if (
auto Err = parseCGSCCPassPipeline(CGPM, *Pipeline))
2075 auto Pipeline = parsePipelineText(PipelineText);
2076 if (!Pipeline || Pipeline->empty())
2077 return make_error<StringError>(
2078 formatv(
"invalid pipeline '{0}'", PipelineText).str(),
2083 return make_error<StringError>(
2084 formatv(
"unknown function pass '{0}' in pipeline '{1}'", FirstName,
2089 if (
auto Err = parseFunctionPassPipeline(FPM, *Pipeline))
2097 auto Pipeline = parsePipelineText(PipelineText);
2098 if (!Pipeline || Pipeline->empty())
2099 return make_error<StringError>(
2100 formatv(
"invalid pipeline '{0}'", PipelineText).str(),
2103 if (
auto Err = parseLoopPassPipeline(CGPM, *Pipeline))
2111 auto Pipeline = parsePipelineText(PipelineText);
2112 if (!Pipeline || Pipeline->empty())
2113 return make_error<StringError>(
2114 formatv(
"invalid machine pass pipeline '{0}'", PipelineText).str(),
2117 if (
auto Err = parseMachinePassPipeline(MFPM, *Pipeline))
2126 if (PipelineText ==
"default") {
2131 while (!PipelineText.
empty()) {
2133 std::tie(
Name, PipelineText) = PipelineText.
split(
',');
2134 if (!parseAAPassName(AA,
Name))
2135 return make_error<StringError>(
2136 formatv(
"unknown alias analysis name '{0}'",
Name).str(),
2148 OS <<
" " <<
PassName <<
"<" << Params <<
">\n";
2154 OS <<
"Module passes:\n";
2155#define MODULE_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2156#include "PassRegistry.def"
2158 OS <<
"Module passes with params:\n";
2159#define MODULE_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
2160 printPassName(NAME, PARAMS, OS);
2161#include "PassRegistry.def"
2163 OS <<
"Module analyses:\n";
2164#define MODULE_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2165#include "PassRegistry.def"
2167 OS <<
"Module alias analyses:\n";
2168#define MODULE_ALIAS_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2169#include "PassRegistry.def"
2171 OS <<
"CGSCC passes:\n";
2172#define CGSCC_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2173#include "PassRegistry.def"
2175 OS <<
"CGSCC passes with params:\n";
2176#define CGSCC_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
2177 printPassName(NAME, PARAMS, OS);
2178#include "PassRegistry.def"
2180 OS <<
"CGSCC analyses:\n";
2181#define CGSCC_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2182#include "PassRegistry.def"
2184 OS <<
"Function passes:\n";
2185#define FUNCTION_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2186#include "PassRegistry.def"
2188 OS <<
"Function passes with params:\n";
2189#define FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
2190 printPassName(NAME, PARAMS, OS);
2191#include "PassRegistry.def"
2193 OS <<
"Function analyses:\n";
2194#define FUNCTION_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2195#include "PassRegistry.def"
2197 OS <<
"Function alias analyses:\n";
2198#define FUNCTION_ALIAS_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2199#include "PassRegistry.def"
2201 OS <<
"LoopNest passes:\n";
2202#define LOOPNEST_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2203#include "PassRegistry.def"
2205 OS <<
"Loop passes:\n";
2206#define LOOP_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2207#include "PassRegistry.def"
2209 OS <<
"Loop passes with params:\n";
2210#define LOOP_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
2211 printPassName(NAME, PARAMS, OS);
2212#include "PassRegistry.def"
2214 OS <<
"Loop analyses:\n";
2215#define LOOP_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2216#include "PassRegistry.def"
2218 OS <<
"Machine module passes (WIP):\n";
2219#define MACHINE_MODULE_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2220#include "llvm/Passes/MachinePassRegistry.def"
2222 OS <<
"Machine function passes (WIP):\n";
2223#define MACHINE_FUNCTION_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
2224#include "llvm/Passes/MachinePassRegistry.def"
2226 OS <<
"Machine function analyses (WIP):\n";
2227#define MACHINE_FUNCTION_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
2228#include "llvm/Passes/MachinePassRegistry.def"
2234 TopLevelPipelineParsingCallbacks.push_back(
C);
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...
Properties which a MachineFunction may have at a given point in time.
MachineFunctionProperties & set(Property P)
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.