[llvm] [CodeGen] Port PrintMIR to new pass manager (PR #79440)

via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 25 04:10:44 PST 2024


================
@@ -20,6 +20,17 @@
 
 using namespace llvm;
 
+PreservedAnalyses PrintMIRPreparePass::run(Module &M, ModuleAnalysisManager &) {
+  printMIR(OS, M);
+  return PreservedAnalyses::all();
+}
+
+PreservedAnalyses PrintMIRPass::run(MachineFunction &MF,
+                                    MachineFunctionAnalysisManager &) {
+  printMIR(OS, MF);
----------------
paperchalice wrote:

It is also possible to use [`MF.getFunctionNumber()`
](https://llvm.org/doxygen/classllvm_1_1MachineFunction.html#a28a68f98b1944a3a50635a007c3c3907) to check if printing module is required, but there is no guarantee that the first MF has the number 0, although currently is.

https://github.com/llvm/llvm-project/pull/79440


More information about the llvm-commits mailing list