[Mlir-commits] [mlir] [mlir] Apply rule of five for Pass / OperationPass (PR #80998)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Wed Feb 7 07:13:19 PST 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-mlir-core

@llvm/pr-subscribers-mlir

Author: Andrei Golubev (andrey-golubev)

<details>
<summary>Changes</summary>

Define all special member functions of C++ types (mlir::Pass and mlir::OperationPass) since one of them is already provided. As part of this, enable move semantics for these types as it probably makes sense since copy semantics is present.

---
Full diff: https://github.com/llvm/llvm-project/pull/80998.diff


1 Files Affected:

- (modified) mlir/include/mlir/Pass/Pass.h (+13) 


``````````diff
diff --git a/mlir/include/mlir/Pass/Pass.h b/mlir/include/mlir/Pass/Pass.h
index 121b253eb83fea..efe482fd726f7e 100644
--- a/mlir/include/mlir/Pass/Pass.h
+++ b/mlir/include/mlir/Pass/Pass.h
@@ -161,6 +161,13 @@ class Pass {
   explicit Pass(TypeID passID, std::optional<StringRef> opName = std::nullopt)
       : passID(passID), opName(opName) {}
   Pass(const Pass &other) : Pass(other.passID, other.opName) {}
+  Pass& operator=(const Pass &other) {
+    this->passID = other.passID;
+    this->opName = other.opName;
+    return *this;
+  }
+  Pass(Pass&&) = default;
+  Pass& operator=(Pass&&) = default;
 
   /// Returns the current pass state.
   detail::PassExecutionState &getPassState() {
@@ -352,6 +359,9 @@ class OperationPass : public Pass {
 protected:
   OperationPass(TypeID passID) : Pass(passID, OpT::getOperationName()) {}
   OperationPass(const OperationPass &) = default;
+  OperationPass& operator=(const OperationPass &) = default;
+  OperationPass(OperationPass&&) = default;
+  OperationPass& operator=(OperationPass&&) = default;
 
   /// Support isa/dyn_cast functionality.
   static bool classof(const Pass *pass) {
@@ -391,6 +401,9 @@ class OperationPass<void> : public Pass {
 protected:
   OperationPass(TypeID passID) : Pass(passID) {}
   OperationPass(const OperationPass &) = default;
+  OperationPass& operator=(const OperationPass &) = default;
+  OperationPass(OperationPass&&) = default;
+  OperationPass& operator=(OperationPass&&) = default;
 
   /// Indicate if the current pass can be scheduled on the given operation type.
   /// By default, generic operation passes can be scheduled on any operation.

``````````

</details>


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


More information about the Mlir-commits mailing list