diff --git a/src/aotcompile.cpp b/src/aotcompile.cpp index 15fd5184d156d..88f879a089157 100644 --- a/src/aotcompile.cpp +++ b/src/aotcompile.cpp @@ -551,7 +551,6 @@ void jl_dump_native_impl(void *native_code, std::vector unopt_bc_Archive; std::vector outputs; - ModuleAnalysisManager none; ModulePassManager preopt, postopt; legacy::PassManager emitter; @@ -603,13 +602,18 @@ void jl_dump_native_impl(void *native_code, // do the actual work auto add_output = [&] (Module &M, StringRef unopt_bc_Name, StringRef bc_Name, StringRef obj_Name, StringRef asm_Name) { - preopt.run(M, none); + AnalysisManagers AM; + PassBuilder PB; + AM.crossRegister(PB); + preopt.run(M, AM.MAM); if (unopt_bc_fname) emit_result(unopt_bc_Archive, unopt_bc_Buffer, unopt_bc_Name, outputs); if (!bc_fname && !obj_fname && !asm_fname) return; optimizer.run(M); - postopt.run(M, none); + AM = AnalysisManagers(); + AM.crossRegister(PB); + postopt.run(M, AM.MAM); emitter.run(M); if (bc_fname) emit_result(bc_Archive, bc_Buffer, bc_Name, outputs); @@ -1395,17 +1399,22 @@ NewPM::NewPM(std::unique_ptr TM, int opt_level, OptimizationOptio PB(this->TM.get(), PipelineTuningOptions(), None, PIC.get()), MPM(createMPM(opt_level, options)), opt_level(opt_level) {} -PreservedAnalyses NewPM::run(Module &M) { - LoopAnalysisManager LAM; - FunctionAnalysisManager FAM(createFAM(opt_level, TM->getTargetIRAnalysis(), TM->getTargetTriple())); - CGSCCAnalysisManager CGAM; - ModuleAnalysisManager MAM; +AnalysisManagers::AnalysisManagers(PassBuilder &PB, TargetMachine &TM, int opt_level) : + LAM(), FAM(createFAM(opt_level, TM.getTargetIRAnalysis(), TM.getTargetTriple())), CGAM(), MAM() { + crossRegister(PB); +} + +void AnalysisManagers::crossRegister(PassBuilder &PB) { PB.registerLoopAnalyses(LAM); PB.registerFunctionAnalyses(FAM); PB.registerCGSCCAnalyses(CGAM); PB.registerModuleAnalyses(MAM); PB.crossRegisterProxies(LAM, FAM, CGAM, MAM); - return MPM.run(M, MAM); +} + +PreservedAnalyses NewPM::run(Module &M) { + AnalysisManagers analyses(PB, *TM, opt_level); + return MPM.run(M, analyses.MAM); } // TODO(vchuravy/maleadt): diff --git a/src/disasm.cpp b/src/disasm.cpp index 5301127d0d783..05af3c40f29ba 100644 --- a/src/disasm.cpp +++ b/src/disasm.cpp @@ -483,9 +483,11 @@ void jl_strip_llvm_debug(Module *m) void jl_strip_llvm_addrspaces(Module *m) { ModulePassManager PM; - ModuleAnalysisManager MAM; + AnalysisManagers AM; + PassBuilder PB; + AM.crossRegister(PB); PM.addPass(RemoveJuliaAddrspacesPass()); - PM.run(*m, MAM); + PM.run(*m, AM.MAM); } // print an llvm IR acquired from jl_get_llvmf diff --git a/src/jitlayers.h b/src/jitlayers.h index 6b0dbd2017f5a..db9d6cc16900c 100644 --- a/src/jitlayers.h +++ b/src/jitlayers.h @@ -83,6 +83,18 @@ static inline bool imaging_default() { return jl_options.image_codegen || (jl_generating_output() && !jl_options.incremental); } +struct AnalysisManagers { + LoopAnalysisManager LAM; + FunctionAnalysisManager FAM; + CGSCCAnalysisManager CGAM; + ModuleAnalysisManager MAM; + + AnalysisManagers() = default; + AnalysisManagers(PassBuilder &PB, TargetMachine &TM, int opt_level); + + void crossRegister(PassBuilder &PB); +}; + struct NewPM { std::unique_ptr TM; StandardInstrumentations SI;