Please refer to the RFC here http://lists.llvm.org/pipermail/llvm-dev/2020-July/143309.html
This patch introduces the interfaces of machine passes and machine pass managers.
machine pass could define four methods:
(1) PreservedAnalyses run(MachineFunction &, MachineFunctionAnalysisManager &). Majority of the machine passes use this.
(2) Error doInitialization(Module &, MachineFunctionAnalysisManager &). Passes like AsmPrinter needs a hook to lower/transform global constructs. (invoked before all passes run method)
(3) Error doFinalization(Module &, MachineFunctionAnalysisManager &). Client: PrintMIRPass. This is also for completeness. (invoked after all passes run method)
(4) Error run(Module &, MachineFunctionAnalysisManager &). Client: MachineOutliner, DebugifyMachineModule. I would call this machine module pass which needs a global scope. It is like (2) but subject to pass ordering. Currently, a pass either define this or (1), but not both.
machine pass manger:
- MachineFunctionAnalysisManager: basically AnalysisManager<MachineFunction> augmented with the ability to register and query IR analyses.
- MachineFunctionPassManager: support only two methods, addPass and run.