170 using namespace llvm;
177 cl::desc(
"Run Partial inlinining pass"));
182 cl::desc(
"Run NewGVN instead of GVN"));
186 cl::desc(
"Enable the EarlyCSE w/ MemorySSA pass for the new PM (default = on)"));
190 cl::desc(
"Enable the GVN hoisting pass for the new PM (default = off)"));
194 cl::desc(
"Enable the GVN hoisting pass for the new PM (default = off)"));
198 cl::desc(
"Enable the Unroll and Jam pass for the new PM (default = off)"));
202 cl::desc(
"Run synthetic function entry count generation " 206 "^(default|thinlto-pre-link|thinlto|lto-pre-link|lto)<(O[0123sz])>$");
210 cl::desc(
"Enable control height reduction optimization (CHR)"));
232 struct NoOpModulePass {
251 struct NoOpCGSCCPass {
273 struct NoOpFunctionPass {
292 struct NoOpLoopPass {
320 void PassBuilder::invokePeepholeEPCallbacks(
322 for (
auto &
C : PeepholeEPCallbacks)
327 #define MODULE_ANALYSIS(NAME, CREATE_PASS) \ 328 MAM.registerPass([&] { return CREATE_PASS; }); 329 #include "PassRegistry.def" 331 for (
auto &
C : ModuleAnalysisRegistrationCallbacks)
336 #define CGSCC_ANALYSIS(NAME, CREATE_PASS) \ 337 CGAM.registerPass([&] { return CREATE_PASS; }); 338 #include "PassRegistry.def" 340 for (
auto &
C : CGSCCAnalysisRegistrationCallbacks)
345 #define FUNCTION_ANALYSIS(NAME, CREATE_PASS) \ 346 FAM.registerPass([&] { return CREATE_PASS; }); 347 #include "PassRegistry.def" 349 for (
auto &
C : FunctionAnalysisRegistrationCallbacks)
354 #define LOOP_ANALYSIS(NAME, CREATE_PASS) \ 355 LAM.registerPass([&] { return CREATE_PASS; }); 356 #include "PassRegistry.def" 358 for (
auto &
C : LoopAnalysisRegistrationCallbacks)
366 assert(Level != O0 &&
"Must request optimizations!");
400 invokePeepholeEPCallbacks(FPM, Level);
404 if (PGOOpt && !PGOOpt->ProfileUseFile.empty() &&
440 for (
auto &
C : LateLoopOptimizationsEPCallbacks)
447 if (Phase != ThinLTOPhase::PreLink ||
448 !PGOOpt || PGOOpt->SampleProfileFile.empty())
451 for (
auto &
C : LoopOptimizerEndEPCallbacks)
488 invokePeepholeEPCallbacks(FPM, Level);
497 for (
auto &
C : ScalarOptimizerLateEPCallbacks)
505 invokePeepholeEPCallbacks(FPM, Level);
507 if (
EnableCHR && Level == O3 && PGOOpt &&
508 (!PGOOpt->ProfileUseFile.empty() || !PGOOpt->SampleProfileFile.empty()))
517 std::string ProfileGenFile,
518 std::string ProfileUseFile,
519 std::string ProfileRemappingFile) {
544 invokePeepholeEPCallbacks(FPM, Level);
566 if (!ProfileGenFile.empty())
572 if (!ProfileUseFile.empty())
579 unsigned OptLevel = Level > O3 ? 2 :
Level;
580 unsigned SizeLevel = Level > O3 ? Level - O3 : 0;
610 if (PGOOpt && !PGOOpt->SampleProfileFile.empty() &&
611 Phase == ThinLTOPhase::PostLink)
615 if (PGOOpt && !PGOOpt->SampleProfileFile.empty()) {
619 PGOOpt->ProfileRemappingFile,
620 Phase == ThinLTOPhase::PreLink));
623 if (Phase != ThinLTOPhase::PreLink)
660 invokePeepholeEPCallbacks(GlobalCleanupPM, Level);
666 if (PGOOpt && Phase != ThinLTOPhase::PostLink &&
667 (!PGOOpt->ProfileGenFile.empty() || !PGOOpt->ProfileUseFile.empty())) {
668 addPGOInstrPasses(MPM, DebugLogging, Level, PGOOpt->RunProfileGen,
669 PGOOpt->ProfileGenFile, PGOOpt->ProfileUseFile,
670 PGOOpt->ProfileRemappingFile);
703 if (Phase == ThinLTOPhase::PreLink &&
704 PGOOpt && !PGOOpt->SampleProfileFile.empty())
719 buildFunctionSimplificationPipeline(Level, Phase, DebugLogging)));
723 if (EnableHotColdSplit && Phase != ThinLTOPhase::PreLink)
726 for (
auto &
C : CGSCCOptimizerLateEPCallbacks)
727 C(MainCGPipeline, Level);
788 for (
auto &
C : VectorizerStartEPCallbacks)
789 C(OptimizePM, Level);
821 forwardSwitchCondToPhi(
true).
822 convertSwitchToLookupTable(
true).
823 needCanonicalLoops(
false).
824 sinkCommonInsts(
true)));
875 for (
auto &
C : OptimizerLastEPCallbacks)
876 C(OptimizePM, Level);
896 assert(Level != O0 &&
"Must request optimizations for the default pipeline!");
904 for (
auto &
C : PipelineStartEPCallbacks)
907 if (PGOOpt && PGOOpt->SamplePGOSupport)
915 MPM.
addPass(buildModuleOptimizationPipeline(Level, DebugLogging));
923 assert(Level != O0 &&
"Must request optimizations for the default pipeline!");
930 if (PGOOpt && PGOOpt->SamplePGOSupport)
934 for (
auto &
C : PipelineStartEPCallbacks)
940 MPM.
addPass(buildModuleSimplificationPipeline(Level, ThinLTOPhase::PreLink,
989 if (!PGOOpt || PGOOpt->SampleProfileFile.empty())
994 MPM.
addPass(buildModuleSimplificationPipeline(Level, ThinLTOPhase::PostLink,
998 MPM.
addPass(buildModuleOptimizationPipeline(Level, DebugLogging));
1005 bool DebugLogging) {
1006 assert(Level != O0 &&
"Must request optimizations for the default pipeline!");
1008 return buildPerModuleDefaultPipeline(Level, DebugLogging);
1014 assert(Level != O0 &&
"Must request optimizations for the default pipeline!");
1017 if (PGOOpt && !PGOOpt->SampleProfileFile.empty()) {
1020 PGOOpt->ProfileRemappingFile,
1045 true , PGOOpt && !PGOOpt->SampleProfileFile.empty()));
1101 invokePeepholeEPCallbacks(PeepholeFPM, Level);
1123 invokePeepholeEPCallbacks(FPM, Level);
1175 invokePeepholeEPCallbacks(MainFPM, Level);
1272 template <
typename ParametersParseCallableT>
1273 auto parsePassParameters(ParametersParseCallableT &&Parser,
StringRef Name,
1275 using ParametersT =
typename decltype(Parser(
StringRef{}))::value_type;
1280 "unable to strip pass name from parametrized pass specification");
1283 return ParametersT{};
1285 assert(
false &&
"invalid format for parametrized pass name");
1289 assert((Result || Result.template errorIsA<StringError>()) &&
1290 "Pass parameter parser can only return StringErrors.");
1291 return std::move(Result);
1297 while (!Params.
empty()) {
1299 std::tie(ParamName, Params) = Params.
split(
';');
1306 if (OptLevel >= 0) {
1312 if (ParamName ==
"partial") {
1314 }
else if (ParamName ==
"peeling") {
1316 }
else if (ParamName ==
"runtime") {
1318 }
else if (ParamName ==
"upperbound") {
1321 return make_error<StringError>(
1322 formatv(
"invalid LoopUnrollPass parameter '{0}' ", ParamName).str(),
1346 template <
typename PassManagerT,
typename CallbacksT>
1348 if (!Callbacks.empty()) {
1349 PassManagerT DummyPM;
1350 for (
auto &CB : Callbacks)
1351 if (CB(Name, DummyPM, {}))
1357 template <
typename CallbacksT>
1364 if (Name ==
"module")
1366 if (Name ==
"cgscc")
1368 if (Name ==
"function")
1375 #define MODULE_PASS(NAME, CREATE_PASS) \ 1378 #define MODULE_ANALYSIS(NAME, CREATE_PASS) \ 1379 if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \ 1381 #include "PassRegistry.def" 1383 return callbacksAcceptPassName<ModulePassManager>(
Name, Callbacks);
1386 template <
typename CallbacksT>
1389 if (Name ==
"cgscc")
1391 if (Name ==
"function")
1400 #define CGSCC_PASS(NAME, CREATE_PASS) \ 1403 #define CGSCC_ANALYSIS(NAME, CREATE_PASS) \ 1404 if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \ 1406 #include "PassRegistry.def" 1408 return callbacksAcceptPassName<CGSCCPassManager>(
Name, Callbacks);
1411 template <
typename CallbacksT>
1414 if (Name ==
"function")
1423 #define FUNCTION_PASS(NAME, CREATE_PASS) \ 1426 #define FUNCTION_PASS_WITH_PARAMS(NAME, CREATE_PASS, PARSER) \ 1427 if (checkParametrizedPassName(Name, NAME)) \ 1429 #define FUNCTION_ANALYSIS(NAME, CREATE_PASS) \ 1430 if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \ 1432 #include "PassRegistry.def" 1434 return callbacksAcceptPassName<FunctionPassManager>(
Name, Callbacks);
1437 template <
typename CallbacksT>
1447 #define LOOP_PASS(NAME, CREATE_PASS) \ 1450 #define LOOP_ANALYSIS(NAME, CREATE_PASS) \ 1451 if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \ 1453 #include "PassRegistry.def" 1455 return callbacksAcceptPassName<LoopPassManager>(
Name, Callbacks);
1459 PassBuilder::parsePipelineText(
StringRef Text) {
1460 std::vector<PipelineElement> ResultPipeline;
1465 std::vector<PipelineElement> &Pipeline = *PipelineStack.
back();
1467 Pipeline.push_back({Text.
substr(0, Pos), {}});
1470 if (Pos == Text.
npos)
1473 char Sep = Text[Pos];
1474 Text = Text.
substr(Pos + 1);
1481 PipelineStack.
push_back(&Pipeline.back().InnerPipeline);
1485 assert(Sep ==
')' &&
"Bogus separator!");
1490 if (PipelineStack.
size() == 1)
1506 if (PipelineStack.
size() > 1)
1510 assert(PipelineStack.
back() == &ResultPipeline &&
1511 "Wrong pipeline at the bottom of the stack!");
1512 return {std::move(ResultPipeline)};
1516 const PipelineElement &
E,
1517 bool VerifyEachPass,
bool DebugLogging) {
1518 auto &
Name = E.Name;
1519 auto &InnerPipeline = E.InnerPipeline;
1522 if (!InnerPipeline.empty()) {
1523 if (
Name ==
"module") {
1525 if (
auto Err = parseModulePassPipeline(NestedMPM, InnerPipeline,
1526 VerifyEachPass, DebugLogging))
1528 MPM.
addPass(std::move(NestedMPM));
1531 if (
Name ==
"cgscc") {
1533 if (
auto Err = parseCGSCCPassPipeline(CGPM, InnerPipeline, VerifyEachPass,
1539 if (
Name ==
"function") {
1541 if (
auto Err = parseFunctionPassPipeline(FPM, InnerPipeline,
1542 VerifyEachPass, DebugLogging))
1549 if (
auto Err = parseModulePassPipeline(NestedMPM, InnerPipeline,
1550 VerifyEachPass, DebugLogging))
1556 for (
auto &
C : ModulePipelineParsingCallbacks)
1557 if (
C(
Name, MPM, InnerPipeline))
1561 return make_error<StringError>(
1562 formatv(
"invalid use of '{0}' pass as module pipeline",
Name).str(),
1571 return make_error<StringError>(
1572 formatv(
"unknown default pipeline alias '{0}'",
Name).str(),
1575 assert(Matches.
size() == 3 &&
"Must capture two matched strings!");
1588 if (Matches[1] ==
"default") {
1589 MPM.
addPass(buildPerModuleDefaultPipeline(L, DebugLogging));
1590 }
else if (Matches[1] ==
"thinlto-pre-link") {
1591 MPM.
addPass(buildThinLTOPreLinkDefaultPipeline(L, DebugLogging));
1592 }
else if (Matches[1] ==
"thinlto") {
1593 MPM.
addPass(buildThinLTODefaultPipeline(L, DebugLogging,
nullptr));
1594 }
else if (Matches[1] ==
"lto-pre-link") {
1595 MPM.
addPass(buildLTOPreLinkDefaultPipeline(L, DebugLogging));
1597 assert(Matches[1] ==
"lto" &&
"Not one of the matched options!");
1598 MPM.
addPass(buildLTODefaultPipeline(L, DebugLogging,
nullptr));
1604 #define MODULE_PASS(NAME, CREATE_PASS) \ 1605 if (Name == NAME) { \ 1606 MPM.addPass(CREATE_PASS); \ 1607 return Error::success(); \ 1609 #define MODULE_ANALYSIS(NAME, CREATE_PASS) \ 1610 if (Name == "require<" NAME ">") { \ 1612 RequireAnalysisPass< \ 1613 std::remove_reference<decltype(CREATE_PASS)>::type, Module>()); \ 1614 return Error::success(); \ 1616 if (Name == "invalidate<" NAME ">") { \ 1617 MPM.addPass(InvalidateAnalysisPass< \ 1618 std::remove_reference<decltype(CREATE_PASS)>::type>()); \ 1619 return Error::success(); \ 1621 #include "PassRegistry.def" 1623 for (
auto &
C : ModulePipelineParsingCallbacks)
1624 if (
C(
Name, MPM, InnerPipeline))
1626 return make_error<StringError>(
1632 const PipelineElement &E,
bool VerifyEachPass,
1633 bool DebugLogging) {
1634 auto &
Name = E.Name;
1635 auto &InnerPipeline = E.InnerPipeline;
1638 if (!InnerPipeline.empty()) {
1639 if (
Name ==
"cgscc") {
1641 if (
auto Err = parseCGSCCPassPipeline(NestedCGPM, InnerPipeline,
1642 VerifyEachPass, DebugLogging))
1645 CGPM.
addPass(std::move(NestedCGPM));
1648 if (
Name ==
"function") {
1650 if (
auto Err = parseFunctionPassPipeline(FPM, InnerPipeline,
1651 VerifyEachPass, DebugLogging))
1659 if (
auto Err = parseCGSCCPassPipeline(NestedCGPM, InnerPipeline,
1660 VerifyEachPass, DebugLogging))
1667 if (
auto Err = parseCGSCCPassPipeline(NestedCGPM, InnerPipeline,
1668 VerifyEachPass, DebugLogging))
1675 for (
auto &
C : CGSCCPipelineParsingCallbacks)
1676 if (
C(
Name, CGPM, InnerPipeline))
1680 return make_error<StringError>(
1681 formatv(
"invalid use of '{0}' pass as cgscc pipeline",
Name).str(),
1686 #define CGSCC_PASS(NAME, CREATE_PASS) \ 1687 if (Name == NAME) { \ 1688 CGPM.addPass(CREATE_PASS); \ 1689 return Error::success(); \ 1691 #define CGSCC_ANALYSIS(NAME, CREATE_PASS) \ 1692 if (Name == "require<" NAME ">") { \ 1693 CGPM.addPass(RequireAnalysisPass< \ 1694 std::remove_reference<decltype(CREATE_PASS)>::type, \ 1695 LazyCallGraph::SCC, CGSCCAnalysisManager, LazyCallGraph &, \ 1696 CGSCCUpdateResult &>()); \ 1697 return Error::success(); \ 1699 if (Name == "invalidate<" NAME ">") { \ 1700 CGPM.addPass(InvalidateAnalysisPass< \ 1701 std::remove_reference<decltype(CREATE_PASS)>::type>()); \ 1702 return Error::success(); \ 1704 #include "PassRegistry.def" 1706 for (
auto &
C : CGSCCPipelineParsingCallbacks)
1707 if (
C(
Name, CGPM, InnerPipeline))
1709 return make_error<StringError>(
1715 const PipelineElement &E,
1716 bool VerifyEachPass,
bool DebugLogging) {
1717 auto &
Name = E.Name;
1718 auto &InnerPipeline = E.InnerPipeline;
1721 if (!InnerPipeline.empty()) {
1722 if (
Name ==
"function") {
1724 if (
auto Err = parseFunctionPassPipeline(NestedFPM, InnerPipeline,
1725 VerifyEachPass, DebugLogging))
1728 FPM.
addPass(std::move(NestedFPM));
1731 if (
Name ==
"loop") {
1733 if (
auto Err = parseLoopPassPipeline(LPM, InnerPipeline, VerifyEachPass,
1743 if (
auto Err = parseFunctionPassPipeline(NestedFPM, InnerPipeline,
1744 VerifyEachPass, DebugLogging))
1750 for (
auto &
C : FunctionPipelineParsingCallbacks)
1751 if (
C(
Name, FPM, InnerPipeline))
1755 return make_error<StringError>(
1756 formatv(
"invalid use of '{0}' pass as function pipeline",
Name).str(),
1761 #define FUNCTION_PASS(NAME, CREATE_PASS) \ 1762 if (Name == NAME) { \ 1763 FPM.addPass(CREATE_PASS); \ 1764 return Error::success(); \ 1766 #define FUNCTION_PASS_WITH_PARAMS(NAME, CREATE_PASS, PARSER) \ 1767 if (checkParametrizedPassName(Name, NAME)) { \ 1768 auto Params = parsePassParameters(PARSER, Name, NAME); \ 1770 return Params.takeError(); \ 1771 FPM.addPass(CREATE_PASS(Params.get())); \ 1772 return Error::success(); \ 1774 #define FUNCTION_ANALYSIS(NAME, CREATE_PASS) \ 1775 if (Name == "require<" NAME ">") { \ 1777 RequireAnalysisPass< \ 1778 std::remove_reference<decltype(CREATE_PASS)>::type, Function>()); \ 1779 return Error::success(); \ 1781 if (Name == "invalidate<" NAME ">") { \ 1782 FPM.addPass(InvalidateAnalysisPass< \ 1783 std::remove_reference<decltype(CREATE_PASS)>::type>()); \ 1784 return Error::success(); \ 1786 #include "PassRegistry.def" 1788 for (
auto &
C : FunctionPipelineParsingCallbacks)
1789 if (
C(
Name, FPM, InnerPipeline))
1791 return make_error<StringError>(
1792 formatv(
"unknown function pass '{0}'",
Name).str(),
1797 bool VerifyEachPass,
bool DebugLogging) {
1799 auto &InnerPipeline = E.InnerPipeline;
1802 if (!InnerPipeline.empty()) {
1803 if (Name ==
"loop") {
1805 if (
auto Err = parseLoopPassPipeline(NestedLPM, InnerPipeline,
1806 VerifyEachPass, DebugLogging))
1809 LPM.
addPass(std::move(NestedLPM));
1814 if (
auto Err = parseLoopPassPipeline(NestedLPM, InnerPipeline,
1815 VerifyEachPass, DebugLogging))
1821 for (
auto &
C : LoopPipelineParsingCallbacks)
1822 if (
C(Name, LPM, InnerPipeline))
1826 return make_error<StringError>(
1827 formatv(
"invalid use of '{0}' pass as loop pipeline", Name).str(),
1832 #define LOOP_PASS(NAME, CREATE_PASS) \ 1833 if (Name == NAME) { \ 1834 LPM.addPass(CREATE_PASS); \ 1835 return Error::success(); \ 1837 #define LOOP_ANALYSIS(NAME, CREATE_PASS) \ 1838 if (Name == "require<" NAME ">") { \ 1839 LPM.addPass(RequireAnalysisPass< \ 1840 std::remove_reference<decltype(CREATE_PASS)>::type, Loop, \ 1841 LoopAnalysisManager, LoopStandardAnalysisResults &, \ 1843 return Error::success(); \ 1845 if (Name == "invalidate<" NAME ">") { \ 1846 LPM.addPass(InvalidateAnalysisPass< \ 1847 std::remove_reference<decltype(CREATE_PASS)>::type>()); \ 1848 return Error::success(); \ 1850 #include "PassRegistry.def" 1852 for (
auto &
C : LoopPipelineParsingCallbacks)
1853 if (
C(Name, LPM, InnerPipeline))
1855 return make_error<StringError>(
formatv(
"unknown loop pass '{0}'", Name).str(),
1860 #define MODULE_ALIAS_ANALYSIS(NAME, CREATE_PASS) \ 1861 if (Name == NAME) { \ 1862 AA.registerModuleAnalysis< \ 1863 std::remove_reference<decltype(CREATE_PASS)>::type>(); \ 1866 #define FUNCTION_ALIAS_ANALYSIS(NAME, CREATE_PASS) \ 1867 if (Name == NAME) { \ 1868 AA.registerFunctionAnalysis< \ 1869 std::remove_reference<decltype(CREATE_PASS)>::type>(); \ 1872 #include "PassRegistry.def" 1874 for (
auto &
C : AAParsingCallbacks)
1882 bool VerifyEachPass,
1883 bool DebugLogging) {
1884 for (
const auto &Element : Pipeline) {
1885 if (
auto Err = parseLoopPass(LPM, Element, VerifyEachPass, DebugLogging))
1894 bool VerifyEachPass,
1895 bool DebugLogging) {
1896 for (
const auto &Element : Pipeline) {
1898 parseFunctionPass(FPM, Element, VerifyEachPass, DebugLogging))
1908 bool VerifyEachPass,
1909 bool DebugLogging) {
1910 for (
const auto &Element : Pipeline) {
1911 if (
auto Err = parseCGSCCPass(CGPM, Element, VerifyEachPass, DebugLogging))
1933 bool VerifyEachPass,
1934 bool DebugLogging) {
1935 for (
const auto &Element : Pipeline) {
1936 if (
auto Err = parseModulePass(MPM, Element, VerifyEachPass, DebugLogging))
1949 bool VerifyEachPass,
bool DebugLogging) {
1950 auto Pipeline = parsePipelineText(PipelineText);
1951 if (!Pipeline || Pipeline->
empty())
1952 return make_error<StringError>(
1953 formatv(
"invalid pipeline '{0}'", PipelineText).str(),
1962 Pipeline = {{
"cgscc", std::move(*Pipeline)}};
1964 FunctionPipelineParsingCallbacks)) {
1965 Pipeline = {{
"function", std::move(*Pipeline)}};
1966 }
else if (
isLoopPassName(FirstName, LoopPipelineParsingCallbacks)) {
1967 Pipeline = {{
"function", {{
"loop", std::move(*Pipeline)}}}};
1969 for (
auto &
C : TopLevelPipelineParsingCallbacks)
1970 if (
C(MPM, *Pipeline, VerifyEachPass, DebugLogging))
1974 auto &InnerPipeline = Pipeline->
front().InnerPipeline;
1975 return make_error<StringError>(
1976 formatv(
"unknown {0} name '{1}'",
1977 (InnerPipeline.empty() ?
"pass" :
"pipeline"), FirstName)
1984 parseModulePassPipeline(MPM, *Pipeline, VerifyEachPass, DebugLogging))
1992 bool VerifyEachPass,
bool DebugLogging) {
1993 auto Pipeline = parsePipelineText(PipelineText);
1994 if (!Pipeline || Pipeline->
empty())
1995 return make_error<StringError>(
1996 formatv(
"invalid pipeline '{0}'", PipelineText).str(),
2001 return make_error<StringError>(
2002 formatv(
"unknown cgscc pass '{0}' in pipeline '{1}'", FirstName,
2008 parseCGSCCPassPipeline(CGPM, *Pipeline, VerifyEachPass, DebugLogging))
2017 bool VerifyEachPass,
bool DebugLogging) {
2018 auto Pipeline = parsePipelineText(PipelineText);
2019 if (!Pipeline || Pipeline->
empty())
2020 return make_error<StringError>(
2021 formatv(
"invalid pipeline '{0}'", PipelineText).str(),
2026 return make_error<StringError>(
2027 formatv(
"unknown function pass '{0}' in pipeline '{1}'", FirstName,
2032 if (
auto Err = parseFunctionPassPipeline(FPM, *Pipeline, VerifyEachPass,
2041 bool VerifyEachPass,
bool DebugLogging) {
2042 auto Pipeline = parsePipelineText(PipelineText);
2043 if (!Pipeline || Pipeline->
empty())
2044 return make_error<StringError>(
2045 formatv(
"invalid pipeline '{0}'", PipelineText).str(),
2049 parseLoopPassPipeline(CGPM, *Pipeline, VerifyEachPass, DebugLogging))
2058 if (PipelineText ==
"default") {
2059 AA = buildDefaultAAPipeline();
2063 while (!PipelineText.
empty()) {
2065 std::tie(Name, PipelineText) = PipelineText.
split(
',');
2066 if (!parseAAPassName(AA, Name))
2067 return make_error<StringError>(
2068 formatv(
"unknown alias analysis name '{0}'", Name).str(),
Super simple passes to force specific function attrs from the commandline into the IR for debugging p...
Defines passes for running instruction simplification across chunks of IR.
This file provides the interface for the pass responsible for both simplifying and canonicalizing the...
const T & front() const
front - Get the first element.
Analysis pass providing a never-invalidated alias analysis result.
A set of parameters used to control various transforms performed by the LoopUnroll pass...
Computes function attributes in post-order over the call graph.
A simple loop rotation transformation.
A simple and fast domtree-based CSE pass.
The profile annotation (profile-instr-use) pass for IR based PGO.
Thresholds to tune inline cost analysis.
Interfaces for registering analysis passes, producing common pass manager configurations, and parsing of pass pipelines.
AAManager buildDefaultAAPipeline()
Build the default AAManager with the default alias analysis pipeline registered.
Eliminate dead arguments (and return values) from functions.
This is the interface for LLVM's inclusion-based alias analysis implemented with CFL graph reachabili...
This class represents lattice values for constants.
static Optional< int > parseRepeatPassName(StringRef Name)
This header provides classes for managing a pipeline of passes over loops in LLVM IR...
This is the interface for a simple mod/ref and alias analysis over globals.
A Module instance is used to store all the information related to an LLVM module. ...
Error parseAAPipeline(AAManager &AA, StringRef PipelineText)
Parse a textual alias analysis pipeline into the provided AA manager.
This is the interface to build a ModuleSummaryIndex for a module.
Uses an "inverted" value numbering to decide the similarity of expressions and sinks similar expressi...
InnerAnalysisManagerProxy< LoopAnalysisManager, Function > LoopAnalysisManagerFunctionProxy
A proxy from a LoopAnalysisManager to a Function.
Performs basic CFG simplifications to assist other loop passes.
This file provides the interface for LLVM's Scalar Replacement of Aggregates pass.
void push_back(const T &Elt)
This file implements a simple N^2 alias analysis accuracy evaluator.
InnerAnalysisManagerProxy< CGSCCAnalysisManager, Module > CGSCCAnalysisManagerModuleProxy
A proxy from a CGSCCAnalysisManager to a Module.
Implements a lazy call graph analysis and related passes for the new pass manager.
RepeatedPass< PassT > createRepeatedPass(int Count, PassT P)
void registerModuleAnalyses(ModuleAnalysisManager &MAM)
Registers all available module analysis passes.
This is the interface for a metadata-based scoped no-alias analysis.
void registerModuleAnalysis()
Register a specific AA result.
LoopUnrollOptions & setUpperBound(bool UpperBound)
Enables or disables the use of trip count upper bound in loop unrolling.
ModuleToPostOrderCGSCCPassAdaptor< CGSCCPassT > createModuleToPostOrderCGSCCPassAdaptor(CGSCCPassT Pass)
A function to deduce a function pass type and wrap it in the templated adaptor.
CGSCCToFunctionPassAdaptor< FunctionPassT > createCGSCCToFunctionPassAdaptor(FunctionPassT Pass)
A function to deduce a function pass type and wrap it in the templated adaptor.
auto formatv(const char *Fmt, Ts &&... Vals) -> formatv_object< decltype(std::make_tuple(detail::build_format_adapter(std::forward< Ts >(Vals))...))>
Pass to remove unused function declarations.
OptimizationLevel
LLVM-provided high-level optimization levels.
ModulePassManager buildThinLTOPreLinkDefaultPipeline(OptimizationLevel Level, bool DebugLogging=false)
Build a pre-link, ThinLTO-targeting default optimization pipeline to a pass manager.
This file provides the interface for LLVM's PGO Instrumentation lowering pass.
OuterAnalysisManagerProxy< FunctionAnalysisManager, Loop, LoopStandardAnalysisResults & > FunctionAnalysisManagerLoopProxy
A proxy from a FunctionAnalysisManager to a Loop.
static cl::opt< bool > EnableEarlyCSEMemSSA("enable-npm-earlycse-memssa", cl::init(true), cl::Hidden, cl::desc("Enable the EarlyCSE w/ MemorySSA pass for the new PM (default = on)"))
The adaptor from a function pass to a loop pass computes these analyses and makes them available to t...
Loop unroll pass that only does full loop unrolling.
Loop unroll pass that will support both full and partial unrolling.
Pass to perform split of global variables.
This pass transforms loops that contain branches or switches on loop- invariant conditions to have mu...
A DCE pass that assumes instructions are dead until proven otherwise.
static cl::opt< bool > EnableSyntheticCounts("enable-npm-synthetic-counts", cl::init(false), cl::Hidden, cl::ZeroOrMore, cl::desc("Run synthetic function entry count generation " "pass"))
A utility pass template to force an analysis result to be available.
static cl::opt< bool > EnableGVNHoist("enable-npm-gvn-hoist", cl::init(false), cl::Hidden, cl::desc("Enable the GVN hoisting pass for the new PM (default = off)"))
Reassociate commutative expressions.
Support structure for SCC passes to communicate updates the call graph back to the CGSCC pass manager...
cl::opt< bool > EnableHotColdSplit
Run instruction simplification across each instruction in the function.
Pass to forward loads in a loop around the backedge to subsequent iterations.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool endswith(StringRef Suffix) const
Check if this string ends with the given Suffix.
A pass that transforms external global definitions into declarations.
This pass handles simple speculating of instructions around PHIs when doing so is profitable for a pa...
A simple and fast domtree-based GVN pass to hoist common expressions from sibling branches...
amdgpu Simplify well known AMD library false Value Value const Twine & Name
This is the interface for a SCEV-based alias analysis.
ModulePassManager buildModuleSimplificationPipeline(OptimizationLevel Level, ThinLTOPhase Phase, bool DebugLogging=false)
Construct the core LLVM module canonicalization and simplification pipeline.
A pass to do RPO deduction and propagation of function attributes.
Optional< int > HintThreshold
Threshold to use for callees with inline hint.
LLVM_ATTRIBUTE_ALWAYS_INLINE bool consume_back(StringRef Suffix)
Returns true if this StringRef has the given suffix and removes that suffix.
Similar to O2 but tries to optimize for small code size instead of fast execution without triggering ...
Instrumentation based profiling lowering pass.
bool registerPass(PassBuilderT &&PassBuilder)
Register an analysis pass with the manager.
static cl::opt< bool > EnableGVNSink("enable-npm-gvn-sink", cl::init(false), cl::Hidden, cl::desc("Enable the GVN hoisting pass for the new PM (default = off)"))
InnerAnalysisManagerProxy< FunctionAnalysisManager, Module > FunctionAnalysisManagerModuleProxy
Provide the FunctionAnalysisManager to Module proxy.
Hoist/decompose integer division and remainder instructions to enable CFG improvements and better cod...
Tagged union holding either a T or a Error.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE R Default(T Value)
OuterAnalysisManagerProxy< CGSCCAnalysisManager, Function > CGSCCAnalysisManagerFunctionProxy
A proxy from a CGSCCAnalysisManager to a Function.
void registerLoopAnalyses(LoopAnalysisManager &LAM)
Registers all available loop analysis passes.
A very specialized mode that will optimize for code size at any and all costs.
This file provides interfaces used to build and manipulate a call graph, which is a very useful tool ...
The sample profiler data loader pass.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool startswith(StringRef Prefix) const
Check if this string starts with the given Prefix.
FunctionToLoopPassAdaptor< LoopPassT > createFunctionToLoopPassAdaptor(LoopPassT Pass, bool DebugLogging=false)
A function to deduce a loop pass type and wrap it in the templated adaptor.
This file provides the interface for IR based instrumentation passes ( (profile-gen, and profile-use).
LLVM_ATTRIBUTE_ALWAYS_INLINE bool consume_front(StringRef Prefix)
Returns true if this StringRef has the given prefix and removes that prefix.
static bool isModulePassName(StringRef Name, CallbacksT &Callbacks)
falkor hwpf fix Falkor HW Prefetch Fix Late Phase
This file provides the interface for a simple, fast CSE pass.
This file provides the interface for the GCOV style profiler pass.
Performs Loop Invariant Code Motion Pass.
The core GVN pass object.
void crossRegisterProxies(LoopAnalysisManager &LAM, FunctionAnalysisManager &FAM, CGSCCAnalysisManager &CGAM, ModuleAnalysisManager &MAM)
Cross register the analysis managers through their proxies.
Pass to remove unused function declarations.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool empty() const
empty - Check if the string is empty.
A lazily constructed view of the call graph of a module.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
A pass that does profile-guided sinking of instructions into loops.
void registerFunctionAnalysis()
Register a specific AA result.
This class implements a trivial dead store elimination.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE StringRef substr(size_t Start, size_t N=npos) const
Return a reference to the substring from [Start, Start + N).
Class to hold module path string table and global value map, and encapsulate methods for operating on...
OuterAnalysisManagerProxy< ModuleAnalysisManager, LazyCallGraph::SCC, LazyCallGraph & > ModuleAnalysisManagerCGSCCProxy
A proxy from a ModuleAnalysisManager to an SCC.
LoopUnrollOptions & setPartial(bool Partial)
Enables or disables partial unrolling.
Pass to perform interprocedural constant propagation.
A pass which infers function attributes from the names and signatures of function declarations in a m...
static cl::opt< unsigned > MaxDevirtIterations("pm-max-devirt-iterations", cl::ReallyHidden, cl::init(4))
A switch()-like statement whose cases are string literals.
This is the interface for LLVM's unification-based alias analysis implemented with CFL graph reachabi...
initializer< Ty > init(const Ty &Val)
static bool isOptimizingForSize(PassBuilder::OptimizationLevel Level)
static bool checkParametrizedPassName(StringRef Name, StringRef PassName)
A set of analyses that are preserved following a run of a transformation pass.
This is the interface for a metadata-based TBAA.
static Regex DefaultAliasRegex("^(default|thinlto-pre-link|thinlto|lto-pre-link|lto)<(O[0123sz])>$")
ModuleToFunctionPassAdaptor< FunctionPassT > createModuleToFunctionPassAdaptor(FunctionPassT Pass)
A function to deduce a function pass type and wrap it in the templated adaptor.
This file provides the interface for LLVM's Global Value Numbering pass which eliminates fully redund...
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
Disable as many optimizations as possible.
FunctionPassManager buildFunctionSimplificationPipeline(OptimizationLevel Level, ThinLTOPhase Phase, bool DebugLogging=false)
Construct the core LLVM function canonicalization and simplification pipeline.
A manager for alias analyses.
ModulePassManager buildLTOPreLinkDefaultPipeline(OptimizationLevel Level, bool DebugLogging=false)
Build a pre-link, LTO-targeting default optimization pipeline to a pass manager.
A CRTP mix-in that provides informational APIs needed for analysis passes.
static bool isFunctionPassName(StringRef Name, CallbacksT &Callbacks)
The inliner pass for the new pass manager.
void registerFunctionAnalyses(FunctionAnalysisManager &FAM)
Registers all available function analysis passes.
Analysis pass providing a never-invalidated alias analysis result.
This file provides the interface for LLVM's Global Value Numbering pass.
ThinLTOPhase
ThinLTO phase.
Optimize for fast execution as much as possible.
ModulePassManager buildModuleOptimizationPipeline(OptimizationLevel Level, bool DebugLogging=false)
Construct the core LLVM module optimization pipeline.
static cl::opt< bool > EnableCHR("enable-chr-npm", cl::init(true), cl::Hidden, cl::desc("Enable control height reduction optimization (CHR)"))
DevirtSCCRepeatedPass< PassT > createDevirtSCCRepeatedPass(PassT Pass, int MaxIterations)
A function to deduce a function pass type and wrap it in the templated adaptor.
A simple loop rotation transformation.
static bool callbacksAcceptPassName(StringRef Name, CallbacksT &Callbacks)
Tests whether registered callbacks will accept a given pass name.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
std::string InstrProfileOutput
ModulePassManager buildThinLTODefaultPipeline(OptimizationLevel Level, bool DebugLogging, const ModuleSummaryIndex *ImportSummary)
Build an ThinLTO default optimization pipeline to a pass manager.
static cl::opt< bool > EnableUnrollAndJam("enable-npm-unroll-and-jam", cl::init(false), cl::Hidden, cl::desc("Enable the Unroll and Jam pass for the new PM (default = off)"))
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
std::enable_if< std::numeric_limits< T >::is_signed, bool >::type getAsInteger(unsigned Radix, T &Result) const
Parse the current string as an integer of the specified radix.
This file provides the interface for LLVM's Loop Data Prefetching Pass.
Provides passes to inlining "always_inline" functions.
LoopUnrollOptions & setOptLevel(int O)
This class provides an interface for updating the loop pass manager based on mutations to the loop ne...
This header defines the LoopLoadEliminationPass object.
static ErrorSuccess success()
Create a success value.
InlineParams getInlineParams()
Generate the parameters to tune the inline cost analysis based only on the commandline options...
static Optional< int > parseDevirtPassName(StringRef Name)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
Optimize for fast execution as much as possible without triggering significant incremental compile ti...
LLVM_NODISCARD std::pair< StringRef, StringRef > split(char Separator) const
Split into two substrings around the first occurrence of a separator character.
This pass performs 'jump threading', which looks at blocks that have multiple predecessors and multip...
A pass to simplify and canonicalize the CFG of a function.
Error parsePassPipeline(ModulePassManager &MPM, StringRef PipelineText, bool VerifyEachPass=true, bool DebugLogging=false)
Parse a textual pass pipeline description into a ModulePassManager.
static InlineParams getInlineParamsFromOptLevel(PassBuilder::OptimizationLevel Level)
The instrumentation (profile-instr-gen) pass for IR based PGO.
This pass converts vector operations into scalar operations, in order to expose optimization opportun...
A pass that merges duplicate global constants into a single constant.
Analysis pass providing a never-invalidated alias analysis result.
Options for the frontend instrumentation based profiling pass.
LLVM_ATTRIBUTE_ALWAYS_INLINE StringSwitch & Case(StringLiteral S, T Value)
This pass performs merges of loads and stores on both sides of a.
Interfaces for passes which infer implicit function attributes from the name and signature of functio...
Analysis pass providing a never-invalidated alias analysis result.
LoopUnrollOptions & setRuntime(bool Runtime)
Enables or disables unrolling of loops with runtime trip count.
Represents a single loop in the control flow graph.
Pass which forces specific function attributes into the IR, primarily as a debugging tool...
LLVM_NODISCARD size_t find_first_of(char C, size_t From=0) const
Find the first character in the string that is C, or npos if not found.
The header file for the LowerExpectIntrinsic pass as used by the new pass manager.
Pass to outline cold regions.
Provides passes for computing function attributes based on interprocedural analyses.
OuterAnalysisManagerProxy< ModuleAnalysisManager, Function > ModuleAnalysisManagerFunctionProxy
Provide the ModuleAnalysisManager to Function proxy.
This header provides classes for managing passes over SCCs of the call graph.
This file defines passes to print out IR in various granularities.
void registerCGSCCAnalyses(CGSCCAnalysisManager &CGAM)
Registers all available CGSCC analysis passes.
ModulePassManager buildLTODefaultPipeline(OptimizationLevel Level, bool DebugLogging, ModuleSummaryIndex *ExportSummary)
Build an LTO default optimization pipeline to a pass manager.
static bool startsWithDefaultPipelineAliasPrefix(StringRef Name)
Tests whether a pass name starts with a valid prefix for a default pipeline alias.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file provides the interface for LLVM's Call Graph Profile pass.
Optimize quickly without destroying debuggability.
The profile size based optimization pass for memory intrinsics.
See the comments on JumpThreadingPass.
An SCC of the call graph.
Performs Loop Inst Simplify Pass.
Lightweight error class with error context and mandatory checking.
static bool isCGSCCPassName(StringRef Name, CallbacksT &Callbacks)
bool match(StringRef String, SmallVectorImpl< StringRef > *Matches=nullptr)
matches - Match the regex against a given String.
An optimization pass providing Scalar Replacement of Aggregates.
This file exposes an interface to building/using memory SSA to walk memory instructions using a use/d...
StringRef - Represent a constant reference to a string, i.e.
This is the interface for LLVM's primary stateless and local alias analysis.
ModulePassManager buildPerModuleDefaultPipeline(OptimizationLevel Level, bool DebugLogging=false)
Build a per-module default optimization pipeline.
A container for analyses that lazily runs them and caches their results.
static cl::opt< bool > RunPartialInlining("enable-npm-partial-inlining", cl::init(false), cl::Hidden, cl::ZeroOrMore, cl::desc("Run Partial inlinining pass"))
A set of parameters used to control the transforms in the SimplifyCFG pass.
This pass performs function-level constant propagation and merging.
This header defines various interfaces for pass management in LLVM.
LoopUnrollOptions & setPeeling(bool Peeling)
Enables or disables loop peeling.
static cl::opt< bool > RunNewGVN("enable-npm-newgvn", cl::init(false), cl::Hidden, cl::ZeroOrMore, cl::desc("Run NewGVN instead of GVN"))
A special type used by analysis passes to provide an address that identifies that particular analysis...
This file provides the interface for the sampled PGO loader pass.
Optional< int > HotCallSiteThreshold
Threshold to use when the callsite is considered hot.
int DefaultThreshold
The default threshold to start with for a callee.
Optimize globals that never have their address taken.
bool empty() const
empty - Check if the array is empty.
Performs Loop Idiom Recognize Pass.
std::error_code inconvertibleErrorCode()
The value returned by this function can be returned from convertToErrorCode for Error values where no...
static bool isLoopPassName(StringRef Name, CallbacksT &Callbacks)