Remove deprecated registration APIs (NFC)
authorMehdi Amini <joker.eph@gmail.com>
Wed, 1 Sep 2021 18:38:07 +0000 (18:38 +0000)
committerMehdi Amini <joker.eph@gmail.com>
Wed, 1 Sep 2021 18:53:30 +0000 (18:53 +0000)
In D104421, we changed the API for pass registration.
Before you would write:

      void registerPass("my-pass", "My Pass Description.",
                        [] { return createMyPass(); });
while now you’d only write:

      void registerPass([] { return createMyPass(); });

If you’re using TableGen to define your pass registration, you shouldn’t have anything to do. If you’re using directly the C++ API here are some changes.
Your project may also be broken even if you use TableGen and you call the
generated registration API in case your pass implementation didn’t inherit from
the MyPassBase class generated by TableGen.

If you don't use TableGen, the "my-pass" and "My Pass Description." fields must
be provided by overriding methods on the pass itself:

  llvm::StringRef getArgument() const final { return "my-pass"; }
  llvm::StringRef getDescription() const final {
    return "My Pass Description.";
  }

Reviewed By: rriddle

Differential Revision: https://reviews.llvm.org/D104429

mlir/include/mlir/Pass/PassRegistry.h
mlir/lib/Pass/PassRegistry.cpp

index 449889b..8e07fc3 100644 (file)
@@ -125,12 +125,6 @@ void registerPassPipeline(
 
 /// Register a specific dialect pass allocator function with the system,
 /// typically used through the PassRegistration template.
-/// Deprecated: please use the alternate version below.
-void registerPass(StringRef arg, StringRef description,
-                  const PassAllocatorFunction &function);
-
-/// Register a specific dialect pass allocator function with the system,
-/// typically used through the PassRegistration template.
 void registerPass(const PassAllocatorFunction &function);
 
 /// PassRegistration provides a global initializer that registers a Pass
@@ -149,17 +143,6 @@ template <typename ConcretePass> struct PassRegistration {
   }
   PassRegistration()
       : PassRegistration([] { return std::make_unique<ConcretePass>(); }) {}
-
-  /// Constructor below are deprecated.
-
-  PassRegistration(StringRef arg, StringRef description,
-                   const PassAllocatorFunction &constructor) {
-    registerPass(arg, description, constructor);
-  }
-
-  PassRegistration(StringRef arg, StringRef description)
-      : PassRegistration(arg, description,
-                         [] { return std::make_unique<ConcretePass>(); }) {}
 };
 
 /// PassPipelineRegistration provides a global initializer that registers a Pass
index b3b94e5..0530ec7 100644 (file)
@@ -107,14 +107,19 @@ PassInfo::PassInfo(StringRef arg, StringRef description,
             optHandler(allocator()->passOptions);
           }) {}
 
-void mlir::registerPass(StringRef arg, StringRef description,
-                        const PassAllocatorFunction &function) {
+void mlir::registerPass(const PassAllocatorFunction &function) {
+  std::unique_ptr<Pass> pass = function();
+  StringRef arg = pass->getArgument();
+  if (arg.empty())
+    llvm::report_fatal_error(
+        "Trying to register a pass that does not override `getArgument()`");
+  StringRef description = pass->getDescription();
   PassInfo passInfo(arg, description, function);
   passRegistry->try_emplace(arg, passInfo);
 
   // Verify that the registered pass has the same ID as any registered to this
   // arg before it.
-  TypeID entryTypeID = function()->getTypeID();
+  TypeID entryTypeID = pass->getTypeID();
   auto it = passRegistryTypeIDs->try_emplace(arg, entryTypeID).first;
   if (it->second != entryTypeID)
     llvm::report_fatal_error(
@@ -123,16 +128,6 @@ void mlir::registerPass(StringRef arg, StringRef description,
         arg);
 }
 
-void mlir::registerPass(const PassAllocatorFunction &function) {
-  std::unique_ptr<Pass> pass = function();
-  StringRef arg = pass->getArgument();
-  if (arg.empty())
-    llvm::report_fatal_error(
-        "Trying to register a pass that does not override `getArgument()`: " +
-        pass->getName());
-  registerPass(arg, pass->getDescription(), function);
-}
-
 /// Returns the pass info for the specified pass argument or null if unknown.
 const PassInfo *mlir::Pass::lookupPassInfo(StringRef passArg) {
   auto it = passRegistry->find(passArg);