[llvm] [CodeGen] Let `PassBuilder` support machine passes (PR #76320)

via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 24 02:41:12 PDT 2024


================
@@ -1877,6 +1894,33 @@ Error PassBuilder::parseLoopPass(LoopPassManager &LPM,
                                  inconvertibleErrorCode());
 }
 
+Error PassBuilder::parseMachinePass(MachineFunctionPassManager &MFPM,
+                                    const PipelineElement &E) {
+  StringRef Name = E.Name;
+  if (!E.InnerPipeline.empty())
+    return make_error<StringError>("invalid pipeline",
+                                   inconvertibleErrorCode());
+
+#define MACHINE_MODULE_PASS(NAME, PASS_NAME, CONSTRUCTOR)                      \
+  if (Name == NAME) {                                                          \
+    MFPM.addPass(PASS_NAME());                                                 \
+    return Error::success();                                                   \
+  }
----------------
paperchalice wrote:

Oops the code is wrong here now. Initially when I took over this part, the original designer want to use machine function pass manager to manage both machine function pass and "machine module pass", but now I realized "machine module pass" is just a special kind of module pass that modifies all `MachineFunctionAnalysis::Result` i.e. `MachineFunciton`... 

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


More information about the llvm-commits mailing list