|
28 | 28 | #include "llvm/Bitcode/BitcodeWriterPass.h"
|
29 | 29 | #include "llvm/GenXIntrinsics/GenXSPIRVWriterAdaptor.h"
|
30 | 30 | #include "llvm/IR/Dominators.h"
|
31 |
| -#include "llvm/IR/IRPrintingPasses.h" |
32 | 31 | #include "llvm/IR/LLVMContext.h"
|
33 |
| -#include "llvm/IR/LegacyPassManager.h" |
34 | 32 | #include "llvm/IR/Module.h"
|
| 33 | +#include "llvm/IRPrinter/IRPrintingPasses.h" |
35 | 34 | #include "llvm/IRReader/IRReader.h"
|
36 | 35 | #include "llvm/Linker/Linker.h"
|
37 | 36 | #include "llvm/Passes/PassBuilder.h"
|
@@ -336,14 +335,15 @@ void saveModuleIR(Module &M, StringRef OutFilename) {
|
336 | 335 | raw_fd_ostream Out{OutFilename, EC, sys::fs::OF_None};
|
337 | 336 | checkError(EC, "error opening the file '" + OutFilename + "'");
|
338 | 337 |
|
339 |
| - // TODO: Use the new PassManager instead? |
340 |
| - legacy::PassManager PrintModule; |
341 |
| - |
| 338 | + ModulePassManager MPM; |
| 339 | + ModuleAnalysisManager MAM; |
| 340 | + PassBuilder PB; |
| 341 | + PB.registerModuleAnalyses(MAM); |
342 | 342 | if (OutputAssembly)
|
343 |
| - PrintModule.add(createPrintModulePass(Out, "")); |
| 343 | + MPM.addPass(PrintModulePass(Out)); |
344 | 344 | else if (Force || !CheckBitcodeOutputToConsole(Out))
|
345 |
| - PrintModule.add(createBitcodeWriterPass(Out)); |
346 |
| - PrintModule.run(M); |
| 345 | + MPM.addPass(BitcodeWriterPass(Out)); |
| 346 | + MPM.run(M, MAM); |
347 | 347 | }
|
348 | 348 |
|
349 | 349 | std::string saveModuleIR(Module &M, int I, StringRef Suff) {
|
|
0 commit comments