[llvm] [NewPM/CodeGen] Rewrite pass manager nesting (PR #81068)
via llvm-commits
llvm-commits at lists.llvm.org
Sun Feb 18 02:10:40 PST 2024
================
@@ -182,49 +147,46 @@ int llvm::compileModuleWithNewPM(
return 1;
}
- ExitOnErr(PB.parsePassPipeline(MFPM, PassPipeline));
+ ExitOnErr(PB.parsePassPipeline(MPM, PassPipeline));
MPM.addPass(PrintMIRPreparePass(*OS));
+ MachineFunctionPassManager MFPM;
MFPM.addPass(PrintMIRPass(*OS));
MFPM.addPass(FreeMachineFunctionPass());
+ MPM.addPass(createModuleToMachineFunctionPassAdaptor(std::move(MFPM)));
- auto &MMI = MFAM.getResult<MachineModuleAnalysis>(*M).getMMI();
if (MIR->parseMachineFunctions(*M, MMI))
return 1;
} else {
- ExitOnErr(LLVMTM.buildCodeGenPipeline(MPM, MFPM, MFAM, *OS,
- DwoOut ? &DwoOut->os() : nullptr,
- FileType, Opt, &PIC));
-
- auto StartStopInfo = TargetPassConfig::getStartStopInfo(PIC);
- assert(StartStopInfo && "Expect StartStopInfo!");
-
- if (auto StopPassName = StartStopInfo->StopPass; !StopPassName.empty()) {
- MFPM.addPass(PrintMIRPass(*OS));
- MFPM.addPass(FreeMachineFunctionPass());
- }
+ ExitOnErr(LLVMTM.buildCodeGenPipeline(
+ MPM, *OS, DwoOut ? &DwoOut->os() : nullptr, FileType, Opt, &PIC));
}
if (PrintPipelinePasses) {
- std::string IRPipeline;
- raw_string_ostream IRSOS(IRPipeline);
- MPM.printPipeline(IRSOS, [&PIC](StringRef ClassName) {
+ std::string PipelineStr;
+ raw_string_ostream OS(PipelineStr);
+ MPM.printPipeline(OS, [&PIC](StringRef ClassName) {
auto PassName = PIC.getPassNameForClassName(ClassName);
return PassName.empty() ? ClassName : PassName;
});
- outs() << "IR pipeline: " << IRPipeline << '\n';
-
- std::string MIRPipeline;
- raw_string_ostream MIRSOS(MIRPipeline);
- MFPM.printPipeline(MIRSOS, [&PIC](StringRef ClassName) {
- auto PassName = PIC.getPassNameForClassName(ClassName);
- return PassName.empty() ? ClassName : PassName;
- });
- outs() << "MIR pipeline: " << MIRPipeline << '\n';
+ outs() << PipelineStr << '\n';
return 0;
}
- RunPasses(BOS.get(), Out.get(), M.get(), Context, Buffer, &MPM, &MAM, MFPM,
- MFAM);
+ // Before executing passes, print the final values of the LLVM options.
+ cl::PrintOptionValues();
+
+ MPM.run(*M, MAM);
+
+ if (Context.getDiagHandlerPtr()->HasErrors)
+ exit(1);
+
+ // Before executing passes, print the final values of the LLVM options.
+ cl::PrintOptionValues();
+
+ MPM.run(*M, MAM);
----------------
paperchalice wrote:
This resulted in the same pipeline being executed twice.
https://github.com/llvm/llvm-project/pull/81068
More information about the llvm-commits
mailing list