diff options
author | Arthur Eubanks <aeubanks@google.com> | 2021-02-11 14:37:29 -0800 |
---|---|---|
committer | Arthur Eubanks <aeubanks@google.com> | 2021-02-12 16:44:52 -0800 |
commit | 964f8103c58db5917c66ef39f50acf2004c90144 (patch) | |
tree | 49246aa5053b8f010bf3d995fe1c5aa49214d1f7 /llvm/lib/LTO/LTOBackend.cpp | |
parent | 2dbe88db5804f32c6dfc1aa474881c3cb7a61d03 (diff) | |
download | llvm-964f8103c58db5917c66ef39f50acf2004c90144.zip llvm-964f8103c58db5917c66ef39f50acf2004c90144.tar.gz llvm-964f8103c58db5917c66ef39f50acf2004c90144.tar.bz2 |
[NFC] Combine runNewPMPasses() and runNewPMCustomPasses()
I've already witnessed two separate changes missing runNewPMPasses()
because runNewPMCustomPasses() is so similar.
This cleans up some duplicated code.
Reviewed By: tejohnson
Differential Revision: https://reviews.llvm.org/D96553
Diffstat (limited to 'llvm/lib/LTO/LTOBackend.cpp')
-rw-r--r-- | llvm/lib/LTO/LTOBackend.cpp | 82 |
1 files changed, 22 insertions, 60 deletions
diff --git a/llvm/lib/LTO/LTOBackend.cpp b/llvm/lib/LTO/LTOBackend.cpp index bf49e5d..5eaa621 100644 --- a/llvm/lib/LTO/LTOBackend.cpp +++ b/llvm/lib/LTO/LTOBackend.cpp @@ -224,11 +224,6 @@ static void runNewPMPasses(const Config &Conf, Module &Mod, TargetMachine *TM, 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 @@ static void runNewPMPasses(const Config &Conf, Module &Mod, TargetMachine *TM, 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 @@ static void runNewPMPasses(const Config &Conf, Module &Mod, TargetMachine *TM, 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 @@ static void runNewPMPasses(const Config &Conf, Module &Mod, TargetMachine *TM, 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<TargetLibraryInfoImpl> 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 @@ bool lto::opt(const Config &Conf, TargetMachine *TM, unsigned Task, Module &Mod, /*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); } |