240 using namespace llvm;
246 cl::desc(
"Enable ML policy for inliner. Currently trained for -Oz only"),
248 "Heuristics-based inliner version."),
250 "Use development mode (runtime-loadable model)."),
252 "Use release mode (AOT-compiled model).")));
256 cl::desc(
"Run synthetic function entry count generation " 260 "^(default|thinlto-pre-link|thinlto|lto-pre-link|lto)<(O[0123sz])>$");
266 cl::desc(
"Enable inline deferral during PGO"));
270 cl::desc(
"Enable memory profiler"));
274 cl::desc(
"Perform mandatory inlinings module-wide, before performing " 432 bool shouldPopulateClassToPassNames() {
441 : DebugLogging(DebugLogging),
TM(
TM), PTO(PTO), PGOOpt(PGOOpt), PIC(PIC) {
443 TM->registerPassBuilderCallbacks(*
this, DebugLogging);
444 if (PIC && shouldPopulateClassToPassNames()) {
445 #define MODULE_PASS(NAME, CREATE_PASS) \ 446 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME); 447 #define MODULE_ANALYSIS(NAME, CREATE_PASS) \ 448 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME); 449 #define FUNCTION_PASS(NAME, CREATE_PASS) \ 450 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME); 451 #define FUNCTION_ANALYSIS(NAME, CREATE_PASS) \ 452 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME); 453 #define LOOP_PASS(NAME, CREATE_PASS) \ 454 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME); 455 #define LOOP_ANALYSIS(NAME, CREATE_PASS) \ 456 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME); 457 #define CGSCC_PASS(NAME, CREATE_PASS) \ 458 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME); 459 #define CGSCC_ANALYSIS(NAME, CREATE_PASS) \ 460 PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME); 461 #include "PassRegistry.def" 465 void PassBuilder::invokePeepholeEPCallbacks(
467 for (
auto &
C : PeepholeEPCallbacks)
472 #define MODULE_ANALYSIS(NAME, CREATE_PASS) \ 473 MAM.registerPass([&] { return CREATE_PASS; }); 474 #include "PassRegistry.def" 476 for (
auto &
C : ModuleAnalysisRegistrationCallbacks)
481 #define CGSCC_ANALYSIS(NAME, CREATE_PASS) \ 482 CGAM.registerPass([&] { return CREATE_PASS; }); 483 #include "PassRegistry.def" 485 for (
auto &
C : CGSCCAnalysisRegistrationCallbacks)
490 #define FUNCTION_ANALYSIS(NAME, CREATE_PASS) \ 491 FAM.registerPass([&] { return CREATE_PASS; }); 492 #include "PassRegistry.def" 494 for (
auto &
C : FunctionAnalysisRegistrationCallbacks)
499 #define LOOP_ANALYSIS(NAME, CREATE_PASS) \ 500 LAM.registerPass([&] { return CREATE_PASS; }); 501 #include "PassRegistry.def" 503 for (
auto &
C : LoopAnalysisRegistrationCallbacks)
516 PassBuilder::buildO1FunctionSimplificationPipeline(OptimizationLevel
Level,
534 invokePeepholeEPCallbacks(FPM,
Level);
568 for (
auto &
C : LateLoopOptimizationsEPCallbacks)
583 for (
auto &
C : LoopOptimizerEndEPCallbacks)
622 invokePeepholeEPCallbacks(FPM,
Level);
627 for (
auto &
C : ScalarOptimizerLateEPCallbacks)
636 invokePeepholeEPCallbacks(FPM,
Level);
648 if (
Level.getSpeedupLevel() == 1)
649 return buildO1FunctionSimplificationPipeline(
Level,
Phase);
687 if (!
Level.isOptimizingForSize())
690 invokePeepholeEPCallbacks(FPM,
Level);
695 !
Level.isOptimizingForSize())
732 for (
auto &
C : LateLoopOptimizationsEPCallbacks)
747 for (
auto &
C : LoopOptimizerEndEPCallbacks)
794 invokePeepholeEPCallbacks(FPM,
Level);
814 for (
auto &
C : ScalarOptimizerLateEPCallbacks)
819 invokePeepholeEPCallbacks(FPM,
Level);
836 bool RunProfileGen,
bool IsCS,
837 std::string ProfileFile,
838 std::string ProfileRemappingFile) {
858 invokePeepholeEPCallbacks(FPM,
Level);
870 if (!RunProfileGen) {
871 assert(!ProfileFile.empty() &&
"Profile use expecting a profile file!");
886 false, DebugLogging));
891 if (!ProfileFile.empty())
900 bool RunProfileGen,
bool IsCS,
901 std::string ProfileFile,
902 std::string ProfileRemappingFile) {
903 if (!RunProfileGen) {
904 assert(!ProfileFile.empty() &&
"Profile use expecting a profile file!");
916 if (!ProfileFile.empty())
985 for (
auto &
C : CGSCCOptimizerLateEPCallbacks)
1008 if (PGOOpt && PGOOpt->PseudoProbeForProfiling &&
1017 bool LoadSampleProfile =
1060 if (LoadSampleProfile)
1064 if (LoadSampleProfile) {
1068 PGOOpt->ProfileRemappingFile,
Phase));
1092 for (
auto &
C : PipelineEarlySimplificationEPCallbacks)
1123 invokePeepholeEPCallbacks(GlobalCleanupPM,
Level);
1132 addPGOInstrPasses(MPM,
Level,
1134 false, PGOOpt->ProfileFile,
1135 PGOOpt->ProfileRemappingFile);
1196 if (!LTOPreLink && PGOOpt) {
1198 addPGOInstrPasses(MPM,
Level,
true,
1199 true, PGOOpt->CSProfileGenFile,
1200 PGOOpt->ProfileRemappingFile);
1202 addPGOInstrPasses(MPM,
Level,
false,
1203 true, PGOOpt->ProfileFile,
1204 PGOOpt->ProfileRemappingFile);
1232 for (
auto &
C : VectorizerStartEPCallbacks)
1239 false, DebugLogging));
1274 .forwardSwitchCondToPhi(
true)
1275 .convertSwitchToLookupTable(
true)
1276 .needCanonicalLoops(
false)
1277 .hoistCommonInsts(
true)
1278 .sinkCommonInsts(
true)));
1358 for (
auto &
C : OptimizerLastEPCallbacks)
1378 "Must request optimizations for the default pipeline!");
1389 for (
auto &
C : PipelineStartEPCallbacks)
1392 if (PGOOpt && PGOOpt->DebugInfoForProfiling)
1407 addRequiredLTOPreLinkPasses(MPM);
1415 "Must request optimizations for the default pipeline!");
1425 if (PGOOpt && PGOOpt->DebugInfoForProfiling)
1429 for (
auto &
C : PipelineStartEPCallbacks)
1460 addRequiredLTOPreLinkPasses(MPM);
1472 if (ImportSummary) {
1514 "Must request optimizations for the default pipeline!");
1546 PGOOpt->ProfileRemappingFile,
1564 if (
Level.getSpeedupLevel() > 1) {
1638 invokePeepholeEPCallbacks(PeepholeFPM,
Level);
1663 invokePeepholeEPCallbacks(FPM,
Level);
1671 addPGOInstrPasses(MPM,
Level,
true,
1672 true, PGOOpt->CSProfileGenFile,
1673 PGOOpt->ProfileRemappingFile);
1675 addPGOInstrPasses(MPM,
Level,
false,
1676 true, PGOOpt->ProfileFile,
1677 PGOOpt->ProfileRemappingFile);
1731 invokePeepholeEPCallbacks(MainFPM,
Level);
1776 "buildO0DefaultPipeline should only be used with O0");
1790 false, PGOOpt->ProfileFile, PGOOpt->ProfileRemappingFile);
1792 for (
auto &
C : PipelineStartEPCallbacks)
1794 for (
auto &
C : PipelineEarlySimplificationEPCallbacks)
1813 if (!CGSCCOptimizerLateEPCallbacks.empty()) {
1815 for (
auto &
C : CGSCCOptimizerLateEPCallbacks)
1820 if (!LateLoopOptimizationsEPCallbacks.empty()) {
1822 for (
auto &
C : LateLoopOptimizationsEPCallbacks)
1829 if (!LoopOptimizerEndEPCallbacks.empty()) {
1831 for (
auto &
C : LoopOptimizerEndEPCallbacks)
1838 if (!ScalarOptimizerLateEPCallbacks.empty()) {
1840 for (
auto &
C : ScalarOptimizerLateEPCallbacks)
1845 if (!VectorizerStartEPCallbacks.empty()) {
1847 for (
auto &
C : VectorizerStartEPCallbacks)
1864 for (
auto &
C : OptimizerLastEPCallbacks)
1868 addRequiredLTOPreLinkPasses(MPM);
1903 if (!
Name.consume_front(
"repeat<") || !
Name.consume_back(
">"))
1906 if (
Name.getAsInteger(0, Count) || Count <= 0)
1912 if (!
Name.consume_front(
"devirt<") || !
Name.consume_back(
">"))
1915 if (
Name.getAsInteger(0, Count) || Count < 0)
1926 return Name.startswith(
"<") &&
Name.endswith(
">");
1946 template <
typename ParametersParseCallableT>
1947 auto parsePassParameters(ParametersParseCallableT &&Parser,
StringRef Name,
1949 using ParametersT =
typename decltype(Parser(
StringRef{}))::value_type;
1954 "unable to strip pass name from parametrized pass specification");
1957 return ParametersT{};
1959 assert(
false &&
"invalid format for parametrized pass name");
1963 assert((Result ||
Result.template errorIsA<StringError>()) &&
1964 "Pass parameter parser can only return StringErrors.");
1971 while (!Params.
empty()) {
1973 std::tie(ParamName, Params) = Params.
split(
';');
1980 if (OptLevel >= 0) {
1987 return make_error<StringError>(
1988 formatv(
"invalid LoopUnrollPass parameter '{0}' ", ParamName).str(),
1995 if (ParamName ==
"partial") {
1997 }
else if (ParamName ==
"peeling") {
1999 }
else if (ParamName ==
"profile-peeling") {
2001 }
else if (ParamName ==
"runtime") {
2003 }
else if (ParamName ==
"upperbound") {
2006 return make_error<StringError>(
2007 formatv(
"invalid LoopUnrollPass parameter '{0}' ", ParamName).str(),
2016 while (!Params.
empty()) {
2018 std::tie(ParamName, Params) = Params.
split(
';');
2020 if (ParamName ==
"recover") {
2022 }
else if (ParamName ==
"kernel") {
2026 return make_error<StringError>(
2027 formatv(
"invalid argument to MemorySanitizer pass track-origins " 2028 "parameter: '{0}' ",
2033 return make_error<StringError>(
2034 formatv(
"invalid MemorySanitizer pass parameter '{0}' ", ParamName)
2045 while (!Params.
empty()) {
2047 std::tie(ParamName, Params) = Params.
split(
';');
2050 if (ParamName ==
"forward-switch-cond") {
2051 Result.forwardSwitchCondToPhi(Enable);
2052 }
else if (ParamName ==
"switch-to-lookup") {
2053 Result.convertSwitchToLookupTable(Enable);
2054 }
else if (ParamName ==
"keep-loops") {
2055 Result.needCanonicalLoops(Enable);
2056 }
else if (ParamName ==
"hoist-common-insts") {
2057 Result.hoistCommonInsts(Enable);
2058 }
else if (ParamName ==
"sink-common-insts") {
2059 Result.sinkCommonInsts(Enable);
2060 }
else if (Enable && ParamName.
consume_front(
"bonus-inst-threshold=")) {
2061 APInt BonusInstThreshold;
2063 return make_error<StringError>(
2064 formatv(
"invalid argument to SimplifyCFG pass bonus-threshold " 2065 "parameter: '{0}' ",
2070 return make_error<StringError>(
2071 formatv(
"invalid SimplifyCFG pass parameter '{0}' ", ParamName).str(),
2081 while (!Params.
empty()) {
2083 std::tie(ParamName, Params) = Params.
split(
';');
2086 if (ParamName ==
"interleave-forced-only") {
2088 }
else if (ParamName ==
"vectorize-forced-only") {
2091 return make_error<StringError>(
2092 formatv(
"invalid LoopVectorize parameter '{0}' ", ParamName).str(),
2101 while (!Params.
empty()) {
2103 std::tie(ParamName, Params) = Params.
split(
';');
2106 if (ParamName ==
"nontrivial") {
2109 return make_error<StringError>(
2110 formatv(
"invalid LoopUnswitch pass parameter '{0}' ", ParamName)
2120 while (!Params.
empty()) {
2122 std::tie(ParamName, Params) = Params.
split(
';');
2125 if (ParamName ==
"split-footer-bb") {
2128 return make_error<StringError>(
2129 formatv(
"invalid MergedLoadStoreMotion pass parameter '{0}' ",
2140 while (!Params.
empty()) {
2142 std::tie(ParamName, Params) = Params.
split(
';');
2145 if (ParamName ==
"pre") {
2147 }
else if (ParamName ==
"load-pre") {
2148 Result.setLoadPRE(Enable);
2149 }
else if (ParamName ==
"split-backedge-load-pre") {
2150 Result.setLoadPRESplitBackedge(Enable);
2151 }
else if (ParamName ==
"memdep") {
2152 Result.setMemDep(Enable);
2154 return make_error<StringError>(
2155 formatv(
"invalid GVN pass parameter '{0}' ", ParamName).str(),
2163 parseStackLifetimeOptions(
StringRef Params) {
2165 while (!Params.
empty()) {
2167 std::tie(ParamName, Params) = Params.
split(
';');
2169 if (ParamName ==
"may") {
2171 }
else if (ParamName ==
"must") {
2174 return make_error<StringError>(
2175 formatv(
"invalid StackLifetime parameter '{0}' ", ParamName).str(),
2187 return Name.startswith(
"default") ||
Name.startswith(
"thinlto") ||
2188 Name.startswith(
"lto");
2199 template <
typename PassManagerT,
typename CallbacksT>
2201 if (!Callbacks.empty()) {
2202 PassManagerT DummyPM;
2203 for (
auto &CB : Callbacks)
2204 if (CB(
Name, DummyPM, {}))
2210 template <
typename CallbacksT>
2217 if (
Name ==
"module")
2219 if (
Name ==
"cgscc")
2221 if (
Name ==
"function")
2228 #define MODULE_PASS(NAME, CREATE_PASS) \ 2231 #define MODULE_ANALYSIS(NAME, CREATE_PASS) \ 2232 if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \ 2234 #include "PassRegistry.def" 2236 return callbacksAcceptPassName<ModulePassManager>(
Name, Callbacks);
2239 template <
typename CallbacksT>
2242 if (
Name ==
"cgscc")
2244 if (
Name ==
"function")
2253 #define CGSCC_PASS(NAME, CREATE_PASS) \ 2256 #define CGSCC_ANALYSIS(NAME, CREATE_PASS) \ 2257 if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \ 2259 #include "PassRegistry.def" 2261 return callbacksAcceptPassName<CGSCCPassManager>(
Name, Callbacks);
2264 template <
typename CallbacksT>
2267 if (
Name ==
"function")
2269 if (
Name ==
"loop" ||
Name ==
"loop-mssa")
2276 #define FUNCTION_PASS(NAME, CREATE_PASS) \ 2279 #define FUNCTION_PASS_WITH_PARAMS(NAME, CREATE_PASS, PARSER) \ 2280 if (checkParametrizedPassName(Name, NAME)) \ 2282 #define FUNCTION_ANALYSIS(NAME, CREATE_PASS) \ 2283 if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \ 2285 #include "PassRegistry.def" 2287 return callbacksAcceptPassName<FunctionPassManager>(
Name, Callbacks);
2290 template <
typename CallbacksT>
2293 if (
Name ==
"loop" ||
Name ==
"loop-mssa")
2300 #define LOOP_PASS(NAME, CREATE_PASS) \ 2303 #define LOOP_PASS_WITH_PARAMS(NAME, CREATE_PASS, PARSER) \ 2304 if (checkParametrizedPassName(Name, NAME)) \ 2306 #define LOOP_ANALYSIS(NAME, CREATE_PASS) \ 2307 if (Name == "require<" NAME ">" || Name == "invalidate<" NAME ">") \ 2309 #include "PassRegistry.def" 2311 return callbacksAcceptPassName<LoopPassManager>(
Name, Callbacks);
2315 PassBuilder::parsePipelineText(
StringRef Text) {
2316 std::vector<PipelineElement> ResultPipeline;
2321 std::vector<PipelineElement> &Pipeline = *PipelineStack.
back();
2323 Pipeline.push_back({Text.
substr(0, Pos), {}});
2326 if (Pos == Text.
npos)
2329 char Sep = Text[Pos];
2330 Text = Text.
substr(Pos + 1);
2337 PipelineStack.
push_back(&Pipeline.back().InnerPipeline);
2341 assert(Sep ==
')' &&
"Bogus separator!");
2346 if (PipelineStack.
size() == 1)
2362 if (PipelineStack.
size() > 1)
2366 assert(PipelineStack.
back() == &ResultPipeline &&
2367 "Wrong pipeline at the bottom of the stack!");
2372 const PipelineElement &
E) {
2373 auto &
Name =
E.Name;
2374 auto &InnerPipeline =
E.InnerPipeline;
2377 if (!InnerPipeline.empty()) {
2378 if (
Name ==
"module") {
2380 if (
auto Err = parseModulePassPipeline(NestedMPM, InnerPipeline))
2385 if (
Name ==
"cgscc") {
2387 if (
auto Err = parseCGSCCPassPipeline(CGPM, InnerPipeline))
2392 if (
Name ==
"function") {
2394 if (
auto Err = parseFunctionPassPipeline(FPM, InnerPipeline))
2401 if (
auto Err = parseModulePassPipeline(NestedMPM, InnerPipeline))
2407 for (
auto &
C : ModulePipelineParsingCallbacks)
2408 if (
C(
Name, MPM, InnerPipeline))
2412 return make_error<StringError>(
2413 formatv(
"invalid use of '{0}' pass as module pipeline",
Name).str(),
2422 return make_error<StringError>(
2423 formatv(
"unknown default pipeline alias '{0}'",
Name).str(),
2426 assert(Matches.
size() == 3 &&
"Must capture two matched strings!");
2436 Matches[1] !=
"lto") {
2438 Matches[1] ==
"lto-pre-link"));
2450 if (Matches[1] ==
"default") {
2452 }
else if (Matches[1] ==
"thinlto-pre-link") {
2454 }
else if (Matches[1] ==
"thinlto") {
2456 }
else if (Matches[1] ==
"lto-pre-link") {
2459 assert(Matches[1] ==
"lto" &&
"Not one of the matched options!");
2466 #define MODULE_PASS(NAME, CREATE_PASS) \ 2467 if (Name == NAME) { \ 2468 MPM.addPass(CREATE_PASS); \ 2469 return Error::success(); \ 2471 #define MODULE_ANALYSIS(NAME, CREATE_PASS) \ 2472 if (Name == "require<" NAME ">") { \ 2474 RequireAnalysisPass< \ 2475 std::remove_reference<decltype(CREATE_PASS)>::type, Module>()); \ 2476 return Error::success(); \ 2478 if (Name == "invalidate<" NAME ">") { \ 2479 MPM.addPass(InvalidateAnalysisPass< \ 2480 std::remove_reference<decltype(CREATE_PASS)>::type>()); \ 2481 return Error::success(); \ 2483 #define CGSCC_PASS(NAME, CREATE_PASS) \ 2484 if (Name == NAME) { \ 2485 MPM.addPass(createModuleToPostOrderCGSCCPassAdaptor(CREATE_PASS)); \ 2486 return Error::success(); \ 2488 #define FUNCTION_PASS(NAME, CREATE_PASS) \ 2489 if (Name == NAME) { \ 2490 MPM.addPass(createModuleToFunctionPassAdaptor(CREATE_PASS)); \ 2491 return Error::success(); \ 2493 #define FUNCTION_PASS_WITH_PARAMS(NAME, CREATE_PASS, PARSER) \ 2494 if (checkParametrizedPassName(Name, NAME)) { \ 2495 auto Params = parsePassParameters(PARSER, Name, NAME); \ 2497 return Params.takeError(); \ 2498 MPM.addPass(createModuleToFunctionPassAdaptor(CREATE_PASS(Params.get()))); \ 2499 return Error::success(); \ 2501 #define LOOP_PASS(NAME, CREATE_PASS) \ 2502 if (Name == NAME) { \ 2504 createModuleToFunctionPassAdaptor(createFunctionToLoopPassAdaptor( \ 2505 CREATE_PASS, false, false, DebugLogging))); \ 2506 return Error::success(); \ 2508 #define LOOP_PASS_WITH_PARAMS(NAME, CREATE_PASS, PARSER) \ 2509 if (checkParametrizedPassName(Name, NAME)) { \ 2510 auto Params = parsePassParameters(PARSER, Name, NAME); \ 2512 return Params.takeError(); \ 2514 createModuleToFunctionPassAdaptor(createFunctionToLoopPassAdaptor( \ 2515 CREATE_PASS(Params.get()), false, false, DebugLogging))); \ 2516 return Error::success(); \ 2518 #include "PassRegistry.def" 2520 for (
auto &
C : ModulePipelineParsingCallbacks)
2521 if (
C(
Name, MPM, InnerPipeline))
2523 return make_error<StringError>(
2529 const PipelineElement &
E) {
2530 auto &
Name =
E.Name;
2531 auto &InnerPipeline =
E.InnerPipeline;
2534 if (!InnerPipeline.empty()) {
2535 if (
Name ==
"cgscc") {
2537 if (
auto Err = parseCGSCCPassPipeline(NestedCGPM, InnerPipeline))
2543 if (
Name ==
"function") {
2545 if (
auto Err = parseFunctionPassPipeline(FPM, InnerPipeline))
2553 if (
auto Err = parseCGSCCPassPipeline(NestedCGPM, InnerPipeline))
2560 if (
auto Err = parseCGSCCPassPipeline(NestedCGPM, InnerPipeline))
2567 for (
auto &
C : CGSCCPipelineParsingCallbacks)
2568 if (
C(
Name, CGPM, InnerPipeline))
2572 return make_error<StringError>(
2573 formatv(
"invalid use of '{0}' pass as cgscc pipeline",
Name).str(),
2578 #define CGSCC_PASS(NAME, CREATE_PASS) \ 2579 if (Name == NAME) { \ 2580 CGPM.addPass(CREATE_PASS); \ 2581 return Error::success(); \ 2583 #define CGSCC_ANALYSIS(NAME, CREATE_PASS) \ 2584 if (Name == "require<" NAME ">") { \ 2585 CGPM.addPass(RequireAnalysisPass< \ 2586 std::remove_reference<decltype(CREATE_PASS)>::type, \ 2587 LazyCallGraph::SCC, CGSCCAnalysisManager, LazyCallGraph &, \ 2588 CGSCCUpdateResult &>()); \ 2589 return Error::success(); \ 2591 if (Name == "invalidate<" NAME ">") { \ 2592 CGPM.addPass(InvalidateAnalysisPass< \ 2593 std::remove_reference<decltype(CREATE_PASS)>::type>()); \ 2594 return Error::success(); \ 2596 #define FUNCTION_PASS(NAME, CREATE_PASS) \ 2597 if (Name == NAME) { \ 2598 CGPM.addPass(createCGSCCToFunctionPassAdaptor(CREATE_PASS)); \ 2599 return Error::success(); \ 2601 #define FUNCTION_PASS_WITH_PARAMS(NAME, CREATE_PASS, PARSER) \ 2602 if (checkParametrizedPassName(Name, NAME)) { \ 2603 auto Params = parsePassParameters(PARSER, Name, NAME); \ 2605 return Params.takeError(); \ 2606 CGPM.addPass(createCGSCCToFunctionPassAdaptor(CREATE_PASS(Params.get()))); \ 2607 return Error::success(); \ 2609 #define LOOP_PASS(NAME, CREATE_PASS) \ 2610 if (Name == NAME) { \ 2612 createCGSCCToFunctionPassAdaptor(createFunctionToLoopPassAdaptor( \ 2613 CREATE_PASS, false, false, DebugLogging))); \ 2614 return Error::success(); \ 2616 #define LOOP_PASS_WITH_PARAMS(NAME, CREATE_PASS, PARSER) \ 2617 if (checkParametrizedPassName(Name, NAME)) { \ 2618 auto Params = parsePassParameters(PARSER, Name, NAME); \ 2620 return Params.takeError(); \ 2622 createCGSCCToFunctionPassAdaptor(createFunctionToLoopPassAdaptor( \ 2623 CREATE_PASS(Params.get()), false, false, DebugLogging))); \ 2624 return Error::success(); \ 2626 #include "PassRegistry.def" 2628 for (
auto &
C : CGSCCPipelineParsingCallbacks)
2629 if (
C(
Name, CGPM, InnerPipeline))
2631 return make_error<StringError>(
2637 const PipelineElement &
E) {
2638 auto &
Name =
E.Name;
2639 auto &InnerPipeline =
E.InnerPipeline;
2642 if (!InnerPipeline.empty()) {
2643 if (
Name ==
"function") {
2645 if (
auto Err = parseFunctionPassPipeline(NestedFPM, InnerPipeline))
2651 if (
Name ==
"loop" ||
Name ==
"loop-mssa") {
2653 if (
auto Err = parseLoopPassPipeline(LPM, InnerPipeline))
2656 bool UseMemorySSA = (
Name ==
"loop-mssa");
2658 InnerPipeline, [](
auto Pipeline) {
return Pipeline.Name ==
"licm"; });
2665 if (
auto Err = parseFunctionPassPipeline(NestedFPM, InnerPipeline))
2671 for (
auto &
C : FunctionPipelineParsingCallbacks)
2672 if (
C(
Name, FPM, InnerPipeline))
2676 return make_error<StringError>(
2677 formatv(
"invalid use of '{0}' pass as function pipeline",
Name).str(),
2682 #define FUNCTION_PASS(NAME, CREATE_PASS) \ 2683 if (Name == NAME) { \ 2684 FPM.addPass(CREATE_PASS); \ 2685 return Error::success(); \ 2687 #define FUNCTION_PASS_WITH_PARAMS(NAME, CREATE_PASS, PARSER) \ 2688 if (checkParametrizedPassName(Name, NAME)) { \ 2689 auto Params = parsePassParameters(PARSER, Name, NAME); \ 2691 return Params.takeError(); \ 2692 FPM.addPass(CREATE_PASS(Params.get())); \ 2693 return Error::success(); \ 2695 #define FUNCTION_ANALYSIS(NAME, CREATE_PASS) \ 2696 if (Name == "require<" NAME ">") { \ 2698 RequireAnalysisPass< \ 2699 std::remove_reference<decltype(CREATE_PASS)>::type, Function>()); \ 2700 return Error::success(); \ 2702 if (Name == "invalidate<" NAME ">") { \ 2703 FPM.addPass(InvalidateAnalysisPass< \ 2704 std::remove_reference<decltype(CREATE_PASS)>::type>()); \ 2705 return Error::success(); \ 2711 #define LOOP_PASS(NAME, CREATE_PASS) \ 2712 if (Name == NAME) { \ 2713 FPM.addPass(createFunctionToLoopPassAdaptor(CREATE_PASS, false, false, \ 2715 return Error::success(); \ 2717 #define LOOP_PASS_WITH_PARAMS(NAME, CREATE_PASS, PARSER) \ 2718 if (checkParametrizedPassName(Name, NAME)) { \ 2719 auto Params = parsePassParameters(PARSER, Name, NAME); \ 2721 return Params.takeError(); \ 2722 FPM.addPass(createFunctionToLoopPassAdaptor(CREATE_PASS(Params.get()), \ 2723 false, false, DebugLogging)); \ 2724 return Error::success(); \ 2726 #include "PassRegistry.def" 2728 for (
auto &
C : FunctionPipelineParsingCallbacks)
2729 if (
C(
Name, FPM, InnerPipeline))
2731 return make_error<StringError>(
2732 formatv(
"unknown function pass '{0}'",
Name).str(),
2737 const PipelineElement &
E) {
2739 auto &InnerPipeline =
E.InnerPipeline;
2742 if (!InnerPipeline.empty()) {
2743 if (
Name ==
"loop") {
2745 if (
auto Err = parseLoopPassPipeline(NestedLPM, InnerPipeline))
2753 if (
auto Err = parseLoopPassPipeline(NestedLPM, InnerPipeline))
2759 for (
auto &
C : LoopPipelineParsingCallbacks)
2760 if (
C(
Name, LPM, InnerPipeline))
2764 return make_error<StringError>(
2765 formatv(
"invalid use of '{0}' pass as loop pipeline",
Name).str(),
2770 #define LOOP_PASS(NAME, CREATE_PASS) \ 2771 if (Name == NAME) { \ 2772 LPM.addPass(CREATE_PASS); \ 2773 return Error::success(); \ 2775 #define LOOP_PASS_WITH_PARAMS(NAME, CREATE_PASS, PARSER) \ 2776 if (checkParametrizedPassName(Name, NAME)) { \ 2777 auto Params = parsePassParameters(PARSER, Name, NAME); \ 2779 return Params.takeError(); \ 2780 LPM.addPass(CREATE_PASS(Params.get())); \ 2781 return Error::success(); \ 2783 #define LOOP_ANALYSIS(NAME, CREATE_PASS) \ 2784 if (Name == "require<" NAME ">") { \ 2785 LPM.addPass(RequireAnalysisPass< \ 2786 std::remove_reference<decltype(CREATE_PASS)>::type, Loop, \ 2787 LoopAnalysisManager, LoopStandardAnalysisResults &, \ 2789 return Error::success(); \ 2791 if (Name == "invalidate<" NAME ">") { \ 2792 LPM.addPass(InvalidateAnalysisPass< \ 2793 std::remove_reference<decltype(CREATE_PASS)>::type>()); \ 2794 return Error::success(); \ 2796 #include "PassRegistry.def" 2798 for (
auto &
C : LoopPipelineParsingCallbacks)
2799 if (
C(
Name, LPM, InnerPipeline))
2801 return make_error<StringError>(
formatv(
"unknown loop pass '{0}'",
Name).str(),
2806 #define MODULE_ALIAS_ANALYSIS(NAME, CREATE_PASS) \ 2807 if (Name == NAME) { \ 2808 AA.registerModuleAnalysis< \ 2809 std::remove_reference<decltype(CREATE_PASS)>::type>(); \ 2812 #define FUNCTION_ALIAS_ANALYSIS(NAME, CREATE_PASS) \ 2813 if (Name == NAME) { \ 2814 AA.registerFunctionAnalysis< \ 2815 std::remove_reference<decltype(CREATE_PASS)>::type>(); \ 2818 #include "PassRegistry.def" 2820 for (
auto &
C : AAParsingCallbacks)
2828 for (
const auto &Element : Pipeline) {
2829 if (
auto Err = parseLoopPass(LPM, Element))
2835 Error PassBuilder::parseFunctionPassPipeline(
2837 for (
const auto &Element : Pipeline) {
2838 if (
auto Err = parseFunctionPass(FPM, Element))
2846 for (
const auto &Element : Pipeline) {
2847 if (
auto Err = parseCGSCCPass(CGPM, Element))
2868 for (
const auto &Element : Pipeline) {
2869 if (
auto Err = parseModulePass(MPM, Element))
2880 auto Pipeline = parsePipelineText(PipelineText);
2881 if (!Pipeline || Pipeline->empty())
2882 return make_error<StringError>(
2883 formatv(
"invalid pipeline '{0}'", PipelineText).str(),
2892 Pipeline = {{
"cgscc",
std::move(*Pipeline)}};
2894 FunctionPipelineParsingCallbacks)) {
2895 Pipeline = {{
"function",
std::move(*Pipeline)}};
2896 }
else if (
isLoopPassName(FirstName, LoopPipelineParsingCallbacks)) {
2897 Pipeline = {{
"function", {{
"loop",
std::move(*Pipeline)}}}};
2899 for (
auto &
C : TopLevelPipelineParsingCallbacks)
2900 if (
C(MPM, *Pipeline, DebugLogging))
2904 auto &InnerPipeline = Pipeline->front().InnerPipeline;
2905 return make_error<StringError>(
2906 formatv(
"unknown {0} name '{1}'",
2907 (InnerPipeline.empty() ?
"pass" :
"pipeline"), FirstName)
2913 if (
auto Err = parseModulePassPipeline(MPM, *Pipeline))
2921 auto Pipeline = parsePipelineText(PipelineText);
2922 if (!Pipeline || Pipeline->empty())
2923 return make_error<StringError>(
2924 formatv(
"invalid pipeline '{0}'", PipelineText).str(),
2929 return make_error<StringError>(
2930 formatv(
"unknown cgscc pass '{0}' in pipeline '{1}'", FirstName,
2935 if (
auto Err = parseCGSCCPassPipeline(CGPM, *Pipeline))
2944 auto Pipeline = parsePipelineText(PipelineText);
2945 if (!Pipeline || Pipeline->empty())
2946 return make_error<StringError>(
2947 formatv(
"invalid pipeline '{0}'", PipelineText).str(),
2952 return make_error<StringError>(
2953 formatv(
"unknown function pass '{0}' in pipeline '{1}'", FirstName,
2958 if (
auto Err = parseFunctionPassPipeline(FPM, *Pipeline))
2966 auto Pipeline = parsePipelineText(PipelineText);
2967 if (!Pipeline || Pipeline->empty())
2968 return make_error<StringError>(
2969 formatv(
"invalid pipeline '{0}'", PipelineText).str(),
2972 if (
auto Err = parseLoopPassPipeline(CGPM, *Pipeline))
2981 if (PipelineText ==
"default") {
2986 while (!PipelineText.
empty()) {
2988 std::tie(
Name, PipelineText) = PipelineText.
split(
',');
2989 if (!parseAAPassName(AA,
Name))
2990 return make_error<StringError>(
2991 formatv(
"unknown alias analysis name '{0}'",
Name).str(),
2999 #define MODULE_ALIAS_ANALYSIS(NAME, CREATE_PASS) \ 3000 if (PassName == NAME) \ 3002 #define FUNCTION_ALIAS_ANALYSIS(NAME, CREATE_PASS) \ 3003 if (PassName == NAME) \ 3005 #include "PassRegistry.def" 3010 #define MODULE_ANALYSIS(NAME, CREATE_PASS) \ 3011 if (PassName == NAME) \ 3013 #define FUNCTION_ANALYSIS(NAME, CREATE_PASS) \ 3014 if (PassName == NAME) \ 3016 #define LOOP_ANALYSIS(NAME, CREATE_PASS) \ 3017 if (PassName == NAME) \ 3019 #define CGSCC_ANALYSIS(NAME, CREATE_PASS) \ 3020 if (PassName == NAME) \ 3022 #define MODULE_ALIAS_ANALYSIS(NAME, CREATE_PASS) \ 3023 if (PassName == NAME) \ 3025 #define FUNCTION_ALIAS_ANALYSIS(NAME, CREATE_PASS) \ 3026 if (PassName == NAME) \ 3028 #include "PassRegistry.def" 3034 bool DebugLogging)> &
C) {
3035 TopLevelPipelineParsingCallbacks.push_back(
C);
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...
Analysis pass providing a never-invalidated alias analysis result.
bool isEmpty() const
Returns if the pass manager contains any passes.
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.
ModulePassManager buildLTODefaultPipeline(OptimizationLevel Level, ModuleSummaryIndex *ExportSummary)
Build an LTO default optimization pipeline to a pass manager.
A simple and fast domtree-based CSE pass.
cl::opt< bool > EnableLoopFlatten
The profile annotation (profile-instr-use) pass for IR based PGO.
cl::opt< bool > EnableIROutliner
Thresholds to tune inline cost analysis.
bool LoopVectorization
Tuning option to enable/disable loop vectorization, set based on opt level.
Interfaces for registering analysis passes, producing common pass manager configurations,...
DevirtSCCRepeatedPass createDevirtSCCRepeatedPass(CGSCCPassT Pass, int MaxIterations)
A function to deduce a function pass type and wrap it in the templated adaptor.
Public interface to the memory profiler pass for instrumenting code to profile memory accesses.
ThinOrFullLTOPhase
This enumerates the LLVM full LTO or ThinLTO optimization phases.
AAManager buildDefaultAAPipeline()
Build the default AAManager with the default alias analysis pipeline registered.
Eliminate dead arguments (and return values) from functions.
ModuleToPostOrderCGSCCPassAdaptor createModuleToPostOrderCGSCCPassAdaptor(CGSCCPassT Pass)
A function to deduce a function pass type and wrap it in the templated adaptor.
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.
cl::opt< bool > ForgetSCEVInLoopUnroll
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.
bool Coroutines
Tuning option to enable/disable coroutine intrinsic lowering.
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.
OpenMP optimizations pass.
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.
static const OptimizationLevel Os
Similar to O2 but tries to optimize for small code size instead of fast execution without triggering ...
This file provides the interface for LLVM's Scalar Replacement of Aggregates pass.
void push_back(const T &Elt)
ThinLTO postlink (backend compile) phase.
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.
ModulePassManager buildPerModuleDefaultPipeline(OptimizationLevel Level, bool LTOPreLink=false)
Build a per-module default optimization pipeline.
RepeatedPass< PassT > createRepeatedPass(int Count, PassT P)
This file implements the Loop Fusion pass.
void registerModuleAnalyses(ModuleAnalysisManager &MAM)
Registers all available module analysis passes.
bool consume_front(StringRef Prefix)
Returns true if this StringRef has the given prefix and removes that prefix.
This is the interface for a metadata-based scoped no-alias analysis.
void registerModuleAnalysis()
Register a specific AA result.
LoopUnrollOptions & setFullUnrollMaxCount(unsigned O)
The instrumentation pass for recording function order.
LoopUnrollOptions & setUpperBound(bool UpperBound)
Enables or disables the use of trip count upper bound in loop unrolling.
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.
This file defines the interface for the loop nest analysis.
Public interface to the memory profiler module pass for instrumenting code to profile memory allocati...
ModulePassManager buildLTOPreLinkDefaultPipeline(OptimizationLevel Level)
Build a pre-link, LTO-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.
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"))
FunctionPassManager buildFunctionSimplificationPipeline(OptimizationLevel Level, ThinOrFullLTOPhase Phase)
Construct the core LLVM function canonicalization and simplification pipeline.
A utility pass template to force an analysis result to be available.
static cl::opt< bool > EnableMemProfiler("enable-mem-prof", cl::init(false), cl::Hidden, cl::ZeroOrMore, cl::desc("Enable memory profiler"))
ThinLTO prelink (summary) phase.
Tunable parameters for passes in the default pipelines.
Reassociate commutative expressions.
Simple pass that canonicalizes aliases.
Support structure for SCC passes to communicate updates the call graph back to the CGSCC pass manager...
StringSwitch & Case(StringLiteral S, T Value)
cl::opt< bool > EnableHotColdSplit
Optional< bool > EnableDeferral
Indicate whether we should allow inline deferral.
bool isAnalysisPassName(StringRef PassName)
Returns true if the pass name is the name of a (non-alias) analysis pass.
Run instruction simplification across each instruction in the function.
Pass to forward loads in a loop around the backedge to subsequent iterations.
static cl::opt< bool > EnablePGOInlineDeferral("enable-npm-pgo-inline-deferral", cl::init(true), cl::Hidden, cl::desc("Enable inline deferral during PGO"))
Flag to enable inline deferral during PGO.
A pass that transforms external global definitions into declarations.
PassBuilder(bool DebugLogging=false, TargetMachine *TM=nullptr, PipelineTuningOptions PTO=PipelineTuningOptions(), Optional< PGOOptions > PGOOpt=None, PassInstrumentationCallbacks *PIC=nullptr)
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.
This is the interface for a SCEV-based alias analysis.
cl::opt< bool > RunPartialInlining
ModulePassManager buildModuleSimplificationPipeline(OptimizationLevel Level, ThinOrFullLTOPhase Phase)
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.
Instrumentation based profiling lowering pass.
static const OptimizationLevel O3
Optimize for fast execution as much as possible.
std::enable_if_t< is_detected< HasRunOnLoopT, PassT >::value > addPass(PassT Pass)
std::vector< std::string > printBeforePasses()
bool registerPass(PassBuilderT &&PassBuilder)
Register an analysis pass with the manager.
ModuleInlinerWrapperPass buildInlinerPipeline(OptimizationLevel Level, ThinOrFullLTOPhase Phase, bool MandatoryOnly)
Construct the module pipeline that performs inlining as well as the inlining-driven cleanups.
LLVM_NODISCARD R Default(T Value)
std::enable_if_t<!std::is_same< PassT, PassManager >::value > addPass(PassT Pass)
bool MergeFunctions
Tuning option to enable/disable function merging.
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.
Contains a collection of routines for determining if a given instruction is guaranteed to execute if ...
LLVM_NODISCARD StringRef substr(size_t Start, size_t N=npos) const
Return a reference to the substring from [Start, Start + N).
LLVM_NODISCARD bool empty() const
empty - Check if the string is empty.
OuterAnalysisManagerProxy< CGSCCAnalysisManager, Function > CGSCCAnalysisManagerFunctionProxy
A proxy from a CGSCCAnalysisManager to a Function.
static constexpr size_t npos
void registerLoopAnalyses(LoopAnalysisManager &LAM)
Registers all available loop analysis passes.
Optimize scalar/vector interactions in IR using target cost models.
The instrumentation (profile-instr-gen) pass for IR based PGO.
This file provides interfaces used to build and manipulate a call graph, which is a very useful tool ...
The sample profiler data loader pass.
This file provides the interface for IR based instrumentation passes ( (profile-gen,...
bool match(StringRef String, SmallVectorImpl< StringRef > *Matches=nullptr, std::string *Error=nullptr) const
matches - Match the regex against a given String.
int64_t getSExtValue() const
Get sign extended value.
static bool isModulePassName(StringRef Name, CallbacksT &Callbacks)
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.
cl::opt< unsigned > MaxDevirtIterations
A CRTP mix-in to automatically provide informational APIs needed for passes.
void crossRegisterProxies(LoopAnalysisManager &LAM, FunctionAnalysisManager &FAM, CGSCCAnalysisManager &CGAM, ModuleAnalysisManager &MAM)
Cross register the analysis managers through their proxies.
Merge identical functions.
Pass to remove unused function declarations.
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.
virtual void registerDefaultAliasAnalyses(AAManager &)
Allow the target to register alias analyses with the AAManager for use with the new pass manager.
void registerFunctionAnalysis()
Register a specific AA result.
cl::opt< bool > EnableOrderFileInstrumentation
This class implements a trivial dead store elimination.
cl::opt< bool > DisablePreInliner
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...
std::enable_if_t< std::numeric_limits< T >::is_signed, bool > getAsInteger(unsigned Radix, T &Result) const
Parse the current string as an integer of the specified radix.
cl::opt< bool > FlattenedProfileUsed
LoopVectorizeOptions & setInterleaveOnlyWhenForced(bool Value)
bool UniqueLinkageNames
Uniquefy function linkage name. Its default value is false.
ModulePassManager buildThinLTOPreLinkDefaultPipeline(OptimizationLevel Level)
Build a pre-link, ThinLTO-targeting default optimization pipeline to a pass manager.
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 checkParametrizedPassName(StringRef Name, StringRef PassName)
cl::opt< bool > EnableConstraintElimination
A set of analyses that are preserved following a run of a transformation pass.
This is the interface for a metadata-based TBAA.
This file provides the interface for the pseudo probe implementation for AutoFDO.
cl::opt< bool > RunNewGVN
bool isAAPassName(StringRef PassName)
Returns true if the pass name is the name of an alias analysis pass.
An analysis pass based on the new PM to deliver ProfileSummaryInfo.
aarch64 falkor hwpf fix Falkor HW Prefetch Fix Late Phase
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")
ValuesClass values(OptsTy... Options)
Helper to build a ValuesClass by forwarding a variable number of arguments as an initializer list to ...
A manager for alias analyses.
This pass attempts to minimize the number of assume without loosing any information.
A CRTP mix-in that provides informational APIs needed for analysis passes.
A set of parameters to control various transforms performed by GVN pass.
static bool isFunctionPassName(StringRef Name, CallbacksT &Callbacks)
bool ForgetAllSCEVInLoopUnroll
Tuning option to forget all SCEV loops in LoopUnroll.
void addPGOInstrPassesForO0(ModulePassManager &MPM, bool RunProfileGen, bool IsCS, std::string ProfileFile, std::string ProfileRemappingFile)
Add PGOInstrumenation passes for O0 only.
cl::opt< unsigned > SetLicmMssaOptCap
void registerFunctionAnalyses(FunctionAnalysisManager &FAM)
Registers all available function analysis passes.
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly.
Analysis pass providing a never-invalidated alias analysis result.
This file provides the interface for LLVM's Global Value Numbering pass.
std::enable_if_t< is_detected< HasRunOnLoopT, LoopPassT >::value, FunctionToLoopPassAdaptor > createFunctionToLoopPassAdaptor(LoopPassT Pass, bool UseMemorySSA=false, bool UseBlockFrequencyInfo=false, bool DebugLogging=false)
A function to deduce a loop pass type and wrap it in the templated adaptor.
void addRequiredModuleAnalysis()
Allow adding module-level analyses benefiting the contained CGSCC passes.
A simple loop rotation transformation.
LoopUnrollOptions & setProfileBasedPeeling(int O)
static const OptimizationLevel Oz
A very specialized mode that will optimize for code size at any and all costs.
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
This file declares a simple ARC-aware AliasAnalysis using special knowledge of Objective C to enhance...
This file provides the interface for LLVM's Loop Data Prefetching Pass.
Provides passes to inlining "always_inline" functions.
LoopUnrollOptions & setOptLevel(int O)
static const char PassName[]
This class provides an interface for updating the loop pass manager based on mutations to the loop ne...
Simple pass that provides a name to every anonymous globals.
static const OptimizationLevel O0
Disable as many optimizations as possible.
This header defines the LoopLoadEliminationPass object.
static ErrorSuccess success()
Create a success value.
bool LoopInterleaving
Tuning option to set loop interleaving on/off, set based on opt level.
CGSCCPassManager & getPM()
Allow adding more CGSCC passes, besides inlining.
LoopVectorizeOptions & setVectorizeOnlyWhenForced(bool 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.
Full LTO postlink (backend compile) phase.
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.
static const Regex DefaultAliasRegex("^(default|thinlto-pre-link|thinlto|lto-pre-link|lto)<(O[0123sz])>$")
static InlineParams getInlineParamsFromOptLevel(PassBuilder::OptimizationLevel Level)
PipelineTuningOptions()
Constructor sets pipeline tuning defaults based on cl::opts.
cl::opt< bool > EnableUnrollAndJam
void registerParseTopLevelPipelineCallback(const std::function< bool(ModulePassManager &, ArrayRef< PipelineElement >, bool DebugLogging)> &C)
Register a callback for a top-level pipeline entry.
Module pass, wrapping the inliner pass.
The instrumentation (profile-instr-gen) pass for IR based PGO.
Error parsePassPipeline(ModulePassManager &MPM, StringRef PipelineText)
Parse a textual pass pipeline description into a ModulePassManager.
Pass to outline similar regions.
This pass converts vector operations into scalar operations, in order to expose optimization opportun...
Class for arbitrary precision integers.
Inlines functions marked as "always_inline".
cl::opt< bool > EnableKnowledgeRetention
unsigned LicmMssaOptCap
Tuning option to cap the number of calls to retrive clobbering accesses in MemorySSA,...
A pass that merges duplicate global constants into a single constant.
Analysis pass providing a never-invalidated alias analysis result.
bool LoopUnrolling
Tuning option to enable/disable loop unrolling. Its default value is true.
Options for the frontend instrumentation based profiling pass.
Simple pass that provides a name to every anonymous globals.
This pass performs merges of loads and stores on both sides of a.
#define clEnumValN(ENUMVAL, FLAGNAME, DESC)
Interfaces for passes which infer implicit function attributes from the name and signature of functio...
Analysis pass providing a never-invalidated alias analysis result.
std::vector< std::string > printAfterPasses()
No LTO/ThinLTO behavior needed.
LoopUnrollOptions & setRuntime(bool Runtime)
Enables or disables unrolling of loops with runtime trip count.
cl::opt< unsigned > SetLicmMssaNoAccForPromotionCap
static cl::opt< InliningAdvisorMode > UseInlineAdvisor("enable-ml-inliner", cl::init(InliningAdvisorMode::Default), cl::Hidden, cl::desc("Enable ML policy for inliner. Currently trained for -Oz only"), cl::values(clEnumValN(InliningAdvisorMode::Default, "default", "Heuristics-based inliner version."), clEnumValN(InliningAdvisorMode::Development, "development", "Use development mode (runtime-loadable model)."), clEnumValN(InliningAdvisorMode::Release, "release", "Use release mode (AOT-compiled model).")))
cl::opt< bool > EnableMSSALoopDependency
Enables memory ssa as a dependency for loop passes.
Represents a single loop in the control flow graph.
static const OptimizationLevel O2
Optimize for fast execution as much as possible without triggering significant incremental compile ti...
cl::opt< int > PreInlineThreshold
unsigned LicmMssaNoAccForPromotionCap
Tuning option to disable promotion to scalars in LICM with MemorySSA, if the number of access is too ...
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.
cl::opt< AttributorRunOption > AttributorRun
The header file for the LowerExpectIntrinsic pass as used by the new pass manager.
Pass to outline cold regions.
ModulePassManager buildO0DefaultPipeline(OptimizationLevel Level, bool LTOPreLink=false)
Build an O0 pipeline with the minimal semantically required passes.
cl::opt< bool > EnableMatrix
Provides passes for computing function attributes based on interprocedural analyses.
This file defines the interface for the loop cache analysis.
bool CallGraphProfile
Tuning option to enable/disable call graph profile.
OuterAnalysisManagerProxy< ModuleAnalysisManager, Function > ModuleAnalysisManagerFunctionProxy
Provide the ModuleAnalysisManager to Function proxy.
bool consume_back(StringRef Suffix)
Returns true if this StringRef has the given suffix and removes that suffix.
This header provides classes for managing passes over SCCs of the call graph.
static const OptimizationLevel O1
Optimize quickly without destroying debuggability.
cl::opt< bool > EnableGVNSink
This file defines passes to print out IR in various granularities.
CGSCCToFunctionPassAdaptor createCGSCCToFunctionPassAdaptor(FunctionPassT Pass)
A function to deduce a function pass type and wrap it in the templated adaptor.
void registerCGSCCAnalyses(CGSCCAnalysisManager &CGAM)
Registers all available CGSCC analysis passes.
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.
The profile size based optimization pass for memory intrinsics.
See the comments on JumpThreadingPass.
LLVM_NODISCARD char front() const
front - Get the first character in the string.
LLVM-provided high-level optimization levels.
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)
Primary interface to the complete machine description for the target machine.
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...
This class manages callbacks registration, as well as provides a way for PassInstrumentation to pass ...
ModuleToFunctionPassAdaptor createModuleToFunctionPassAdaptor(FunctionPassT Pass)
A function to deduce a function pass type and wrap it in the templated adaptor.
print Print MemDeps of function
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
StringRef - Represent a constant reference to a string, i.e.
This is the interface for LLVM's primary stateless and local alias analysis.
A container for analyses that lazily runs them and caches their results.
ModulePassManager buildModuleOptimizationPipeline(OptimizationLevel Level, bool LTOPreLink=false)
Construct the core LLVM module optimization pipeline.
ModulePassManager buildThinLTODefaultPipeline(OptimizationLevel Level, const ModuleSummaryIndex *ImportSummary)
Build an ThinLTO default optimization pipeline to a pass manager.
static cl::opt< bool > PerformMandatoryInliningsFirst("mandatory-inlining-first", cl::init(true), cl::Hidden, cl::ZeroOrMore, cl::desc("Perform mandatory inlinings module-wide, before performing " "inlining."))
cl::opt< bool > EnableGVNHoist
This pass performs function-level constant propagation and merging.
This header defines various interfaces for pass management in LLVM.
static void addAnnotationRemarksPass(ModulePassManager &MPM)
LoopUnrollOptions & setPeeling(bool Peeling)
Enables or disables loop peeling.
cl::opt< bool > EnableCHR
A special type used by analysis passes to provide an address that identifies that particular analysis...
The header file for the LowerConstantIntrinsics pass as used by the new pass manager.
bool SLPVectorization
Tuning option to enable/disable slp loop vectorization, set based on opt level.
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.
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)