[llvm] [CodeGen] Port `two-address-instructions` to new pass manager (PR #98632)

via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 12 06:58:01 PDT 2024


================
@@ -203,26 +226,75 @@ class TwoAddressInstructionPass : public MachineFunctionPass {
     AU.addPreservedID(MachineDominatorsID);
     MachineFunctionPass::getAnalysisUsage(AU);
   }
-
-  /// Pass entry point.
-  bool runOnMachineFunction(MachineFunction&) override;
 };
 
 } // end anonymous namespace
 
-char TwoAddressInstructionPass::ID = 0;
+PreservedAnalyses
+TwoAddressInstructionPass::run(MachineFunction &MF,
+                               MachineFunctionAnalysisManager &MFAM) {
+  // Disable optimizations if requested. We cannot skip the whole pass as some
+  // fixups are necessary for correctness.
+  TwoAddressInstructionImpl Impl(MF, MFAM);
+  if (MF.getFunction().hasOptNone())
----------------
paperchalice wrote:

skipFunction is legacy pass manager only and there is no counterpart in new pass manager, so here just check the optnone, like what skipFunction do. The rest part in skipFunction is in instrumentation.

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


More information about the llvm-commits mailing list