[llvm] [NewPM][CodeGen] add TargetPassConfig like API (PR #70906)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 1 01:13:24 PDT 2023


================
@@ -195,7 +234,22 @@ template <typename DerivedT> class CodeGenPassBuilder {
   // Function object to maintain state while adding codegen machine passes.
   class AddMachinePass {
   public:
-    AddMachinePass(MachineFunctionPassManager &PM) : PM(PM) {}
+    AddMachinePass(const CodeGenPassBuilder &Builder,
+                   MachineFunctionPassManager &PM, bool AddPrePostHook = false)
+        : AddPrePostHook(AddPrePostHook), Builder(Builder), PM(PM) {
+      BeforeCallbacks.emplace_back([this](AnalysisKey *) {
+        if (this->AddPrePostHook)
+          this->Builder.addMachinePrePasses(this->PM);
+        return true;
+      });
+
+      AfterCallbacks.emplace_back([this](AnalysisKey *, StringRef Name) {
+        if (this->AddPrePostHook) {
+          std::string Banner = "After " + Name.str();
----------------
arsenm wrote:

I'd expect the "After" part of the banner to be produced during the emission of the message down after the actual addition, and this would just pass the raw pass name. I guess this is a pre-existing wart 

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


More information about the llvm-commits mailing list