diff --git a/llvm/lib/LTO/LTOBackend.cpp b/llvm/lib/LTO/LTOBackend.cpp --- a/llvm/lib/LTO/LTOBackend.cpp +++ b/llvm/lib/LTO/LTOBackend.cpp @@ -224,11 +224,6 @@ StandardInstrumentations SI(Conf.DebugPassManager); SI.registerCallbacks(PIC); PassBuilder PB(Conf.DebugPassManager, TM, Conf.PTO, PGOOpt, &PIC); - AAManager AA; - - // Parse a custom AA pipeline if asked to. - if (auto Err = PB.parseAAPipeline(AA, "default")) - report_fatal_error("Error parsing default AA pipeline"); RegisterPassPlugins(Conf.PassPlugins, PB); @@ -243,6 +238,16 @@ TLII->disableAllFunctions(); FAM.registerPass([&] { return TargetLibraryAnalysis(*TLII); }); + AAManager AA; + // Parse a custom AA pipeline if asked to. + if (!Conf.AAPipeline.empty()) { + if (auto Err = PB.parseAAPipeline(AA, Conf.AAPipeline)) { + report_fatal_error("unable to parse AA pipeline description '" + + Conf.AAPipeline + "': " + toString(std::move(Err))); + } + } else { + AA = PB.buildDefaultAAPipeline(); + } // Register the AA manager first so that our version is the one used. FAM.registerPass([&] { return std::move(AA); }); @@ -277,10 +282,17 @@ break; } - if (IsThinLTO) + // Parse a custom pipeline if asked to. + if (!Conf.OptPipeline.empty()) { + if (auto Err = PB.parsePassPipeline(MPM, Conf.OptPipeline)) { + report_fatal_error("unable to parse pass pipeline description '" + + Conf.OptPipeline + "': " + toString(std::move(Err))); + } + } else if (IsThinLTO) { MPM.addPass(PB.buildThinLTODefaultPipeline(OL, ImportSummary)); - else + } else { MPM.addPass(PB.buildLTODefaultPipeline(OL, ExportSummary)); + } if (!Conf.DisableVerify) MPM.addPass(VerifierPass()); @@ -288,55 +300,6 @@ MPM.run(Mod, MAM); } -static void runNewPMCustomPasses(const Config &Conf, Module &Mod, - TargetMachine *TM) { - PassBuilder PB(Conf.DebugPassManager, TM); - AAManager AA; - - // Parse a custom AA pipeline if asked to. - if (!Conf.AAPipeline.empty()) - if (auto Err = PB.parseAAPipeline(AA, Conf.AAPipeline)) - report_fatal_error("unable to parse AA pipeline description '" + - Conf.AAPipeline + "': " + toString(std::move(Err))); - - RegisterPassPlugins(Conf.PassPlugins, PB); - - LoopAnalysisManager LAM; - FunctionAnalysisManager FAM; - CGSCCAnalysisManager CGAM; - ModuleAnalysisManager MAM; - - std::unique_ptr TLII( - new TargetLibraryInfoImpl(Triple(TM->getTargetTriple()))); - if (Conf.Freestanding) - TLII->disableAllFunctions(); - FAM.registerPass([&] { return TargetLibraryAnalysis(*TLII); }); - - // Register the AA manager first so that our version is the one used. - FAM.registerPass([&] { return std::move(AA); }); - - // Register all the basic analyses with the managers. - PB.registerModuleAnalyses(MAM); - PB.registerCGSCCAnalyses(CGAM); - PB.registerFunctionAnalyses(FAM); - PB.registerLoopAnalyses(LAM); - PB.crossRegisterProxies(LAM, FAM, CGAM, MAM); - - ModulePassManager MPM; - - // Always verify the input. - MPM.addPass(VerifierPass()); - - // Now, add all the passes we've been requested to. - if (auto Err = PB.parsePassPipeline(MPM, Conf.OptPipeline)) - report_fatal_error("unable to parse pass pipeline description '" + - Conf.OptPipeline + "': " + toString(std::move(Err))); - - if (!Conf.DisableVerify) - MPM.addPass(VerifierPass()); - MPM.run(Mod, MAM); -} - static void runOldPMPasses(const Config &Conf, Module &Mod, TargetMachine *TM, bool IsThinLTO, ModuleSummaryIndex *ExportSummary, const ModuleSummaryIndex *ImportSummary) { @@ -392,13 +355,12 @@ /*Cmdline*/ CmdArgs); } // FIXME: Plumb the combined index into the new pass manager. - if (!Conf.OptPipeline.empty()) - runNewPMCustomPasses(Conf, Mod, TM); - else if (Conf.UseNewPM) + if (Conf.UseNewPM) { runNewPMPasses(Conf, Mod, TM, Conf.OptLevel, IsThinLTO, ExportSummary, ImportSummary); - else + } else { runOldPMPasses(Conf, Mod, TM, IsThinLTO, ExportSummary, ImportSummary); + } return !Conf.PostOptModuleHook || Conf.PostOptModuleHook(Task, Mod); }