[PATCH] D67687: [NewPM][CodeGen] Introduce machine pass and machine pass manager

Arthur Eubanks via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 20 21:16:29 PDT 2020


aeubanks added a comment.

After thinking about this some more, I still don't understand why `MachineFunction`s aren't modeled as contained within a `Module` and don't really see the benefit of all this custom logic. Looking at some legacy passes like `MachineOutliner`, it's a `ModulePass` that finds all machine functions itself through the module.
The passes that you gave as examples that have some sort of `doInitialization`/`doFinalization` could just become a module pass (I'm thinking about doing that for `objc-arc` which has a `doInitialization`)?
Maybe I'm missing something, but going toward the route of modeling modules as containing machine functions and reusing more of the existing infra and less custom stuff specifically for codegen seems better. Then the only thing you'd have to do is add some pass manager/analysis manager typedefs, create a `ModuleToMachineFunctionPassAdaptor`, and add some proxies to `PassBuilder::crossRegisterProxies`.
That would make it less confusing and more consistent than having two different `run()` methods here.
And it would make it easier to share analyses between the different pipelines, by adding the machine function pass manager as part of the overall module pass manager (e.g. in PassBuilder.cpp).

You mentioned

> Because their data structures are separated. Logically they are representations of the same/similar thing at different abstraction level.

in the email thread. Do you mean that there should be some sort of `MachineModule`, instead of `Module` corresponding to both IR and MIR?



================
Comment at: llvm/include/llvm/CodeGen/MachinePassManager.h:19
+//
+// `doInitilization`/`doFinalization` are available like they do in legacy pass
+// manager. This is for machine function passes to work on module level
----------------
`doInitialization`

"like they are"


================
Comment at: llvm/lib/CodeGen/MachinePassManager.cpp:47
+
+    // Run machine moulde passes
+    if (HasRunOnModulePasses.count(Idx)) {
----------------
moulde -> module


================
Comment at: llvm/unittests/CodeGen/PassManagerTest.cpp:88
+    BeforeInitialization = Count;
+    return Error::success();
+  }
----------------
what about tests for returning an Error in doIntialization/doFinalization?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67687/new/

https://reviews.llvm.org/D67687





More information about the llvm-commits mailing list