Skip to content

Commit 437c374

Browse files
committed
Replace incidental uses of the legacy pass manager with the new pass manager
1 parent 23b7f51 commit 437c374

File tree

3 files changed

+19
-12
lines changed

3 files changed

+19
-12
lines changed

src/aotcompile.cpp

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -515,20 +515,23 @@ void jl_dump_native_impl(void *native_code,
515515
std::vector<NewArchiveMember> unopt_bc_Archive;
516516
std::vector<std::string> outputs;
517517

518-
legacy::PassManager preopt, postopt;
518+
PassBuilder emptyPB;
519+
AnalysisManagers empty(emptyPB);
520+
ModulePassManager preopt, postopt;
521+
legacy::PassManager emitter; // MC emission is only supported on legacy PM
519522

520523
if (unopt_bc_fname)
521-
preopt.add(createBitcodeWriterPass(unopt_bc_OS));
524+
preopt.addPass(BitcodeWriterPass(unopt_bc_OS));
522525

523-
//Is this necessary for TM?
524-
// addTargetPasses(&postopt, TM->getTargetTriple(), TM->getTargetIRAnalysis());
525526
if (bc_fname)
526-
postopt.add(createBitcodeWriterPass(bc_OS));
527+
postopt.addPass(BitcodeWriterPass(bc_OS));
528+
//Is this necessary for TM?
529+
addTargetPasses(&emitter, TM->getTargetTriple(), TM->getTargetIRAnalysis());
527530
if (obj_fname)
528-
if (TM->addPassesToEmitFile(postopt, obj_OS, nullptr, CGFT_ObjectFile, false))
531+
if (TM->addPassesToEmitFile(emitter, obj_OS, nullptr, CGFT_ObjectFile, false))
529532
jl_safe_printf("ERROR: target does not support generation of object files\n");
530533
if (asm_fname)
531-
if (TM->addPassesToEmitFile(postopt, asm_OS, nullptr, CGFT_AssemblyFile, false))
534+
if (TM->addPassesToEmitFile(emitter, asm_OS, nullptr, CGFT_AssemblyFile, false))
532535
jl_safe_printf("ERROR: target does not support generation of object files\n");
533536

534537
legacy::PassManager optimizer;
@@ -567,7 +570,7 @@ void jl_dump_native_impl(void *native_code,
567570

568571
// do the actual work
569572
auto add_output = [&] (Module &M, StringRef unopt_bc_Name, StringRef bc_Name, StringRef obj_Name, StringRef asm_Name) {
570-
preopt.run(M);
573+
preopt.run(M, empty.MAM);
571574
optimizer.run(M);
572575

573576
// We would like to emit an alias or an weakref alias to redirect these symbols
@@ -585,7 +588,7 @@ void jl_dump_native_impl(void *native_code,
585588
injectCRTAlias(M, "__truncdfhf2", "julia__truncdfhf2",
586589
FunctionType::get(Type::getHalfTy(Context), { Type::getDoubleTy(Context) }, false));
587590

588-
postopt.run(M);
591+
postopt.run(M, empty.MAM);
589592

590593
if (unopt_bc_fname)
591594
emit_result(unopt_bc_Archive, unopt_bc_Buffer, unopt_bc_Name, outputs);

src/disasm.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -482,9 +482,11 @@ void jl_strip_llvm_debug(Module *m)
482482

483483
void jl_strip_llvm_addrspaces(Module *m)
484484
{
485-
legacy::PassManager PM;
486-
PM.add(createRemoveJuliaAddrspacesPass());
487-
PM.run(*m);
485+
PassBuilder PB;
486+
AnalysisManagers AM(PB);
487+
ModulePassManager MPM;
488+
MPM.addPass(RemoveJuliaAddrspacesPass());
489+
MPM.run(*m, AM.MAM);
488490
}
489491

490492
// print an llvm IR acquired from jl_get_llvmf

src/pipeline.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,8 @@ namespace {
205205
// BPF, NVPTX, and AMDGPU.
206206
//TODO implement these once LLVM exposes
207207
//the PassBuilder extension point callbacks
208+
//For now we'll maintain the insertion points even though they don't do anything
209+
//for the sake of documentation
208210
void invokePipelineStartCallbacks(ModulePassManager &MPM, PassBuilder &PB, OptimizationLevel O) {}
209211
void invokePeepholeEPCallbacks(FunctionPassManager &MPM, PassBuilder &PB, OptimizationLevel O) {}
210212
void invokeEarlySimplificationCallbacks(ModulePassManager &MPM, PassBuilder &PB, OptimizationLevel O) {}

0 commit comments

Comments
 (0)