[Mlir-commits] [mlir] 5b09ffe - Revert "WIP listeners", totally pushed by mistake!
Mehdi Amini
llvmlistbot at llvm.org
Fri Jan 20 16:17:10 PST 2023
Author: Mehdi Amini
Date: 2023-01-21T01:16:06+01:00
New Revision: 5b09ffe6589a926650d7fd1187a83dd8f1719117
URL: https://github.com/llvm/llvm-project/commit/5b09ffe6589a926650d7fd1187a83dd8f1719117
DIFF: https://github.com/llvm/llvm-project/commit/5b09ffe6589a926650d7fd1187a83dd8f1719117.diff
LOG: Revert "WIP listeners", totally pushed by mistake!
This reverts commit 2e312a7baec5e8d8f841ee819966ff3f53f274c6.
Should never have been pushed here...
Added:
Modified:
mlir/include/mlir/IR/Operation.h
mlir/lib/IR/Operation.cpp
Removed:
################################################################################
diff --git a/mlir/include/mlir/IR/Operation.h b/mlir/include/mlir/IR/Operation.h
index 3fbcfe871a43..59d450ea97bb 100644
--- a/mlir/include/mlir/IR/Operation.h
+++ b/mlir/include/mlir/IR/Operation.h
@@ -22,30 +22,6 @@
#include <optional>
namespace mlir {
-class IRListeners {
-public:
- class ListenerInterface {
- public:
- ~ListenerInterface() = default;
- virtual void notifyOpInserted(Operation *op, Block *oldBlock, Block *newBlock);
- virtual void notifyOpDestroyed(Operation *op);
- };
- void notifyOpInserted(Operation *op, Block *oldBlock, Block *newBlock) {
- for (auto &listener : listeners)
- listener.notifyOpInserted(op, oldBlock, newBlock);
- }
- void notifyOpDestroyed(Operation *op) {
- for (auto &listener : listeners)
- listener.notifyOpDestroyed(op);
- }
- void addListener(std::shared_ptr<ListenerInterface> listener) {
- listeners.push_back(std::move(listener));
- }
- private:
- std::vector<std::shared_ptr<ListenerInterface>> listeners;
-};
-
-
/// Operation is the basic unit of execution within MLIR.
///
/// The following documentation are recommended to understand this class:
@@ -759,12 +735,6 @@ class alignas(8) Operation final
/// Returns true if this operation has a valid order.
bool hasValidOrder() { return orderIndex != kInvalidOrderIdx; }
- /// Attach a listener to this operation.
- void addListener(std::shared_ptr<ListenerInterface> listener) {
- if (!listeners) listeners = std::make_unique<IRListeners>();
- listeners->addListener(std::move(listener));
- }
-
private:
Operation(Location location, OperationName name, unsigned numResults,
unsigned numSuccessors, unsigned numRegions,
@@ -773,7 +743,7 @@ class alignas(8) Operation final
// Operations are deleted through the destroy() member because they are
// allocated with malloc.
~Operation();
-g
+
/// Returns the additional size necessary for allocating the given objects
/// before an Operation in-memory.
static size_t prefixAllocSize(unsigned numOutOfLineResults,
@@ -866,9 +836,6 @@ g
/// This holds general named attributes for the operation.
DictionaryAttr attrs;
- /// Optionally defined listeners that register here to capture IR modification events.
- std::unique_ptr<IRListeners> listeners;
-
// allow ilist_traits access to 'block' field.
friend struct llvm::ilist_traits<Operation>;
diff --git a/mlir/lib/IR/Operation.cpp b/mlir/lib/IR/Operation.cpp
index a700a54a784a..50815b3738bf 100644
--- a/mlir/lib/IR/Operation.cpp
+++ b/mlir/lib/IR/Operation.cpp
@@ -162,7 +162,6 @@ Operation::~Operation() {
/// Destroy this operation or one of its subclasses.
void Operation::destroy() {
- if (listeners) listeners->notifyOpDestroyed(this);
// Operations may have additional prefixed allocation, which needs to be
// accounted for here when computing the address to free.
char *rawMem = reinterpret_cast<char *>(this) -
@@ -381,9 +380,8 @@ Block *llvm::ilist_traits<::mlir::Operation>::getContainingBlock() {
/// keep the block pointer up to date.
void llvm::ilist_traits<::mlir::Operation>::addNodeToList(Operation *op) {
assert(!op->getBlock() && "already in an operation block!");
- auto oldBlock = op->block;
op->block = getContainingBlock();
- if (listeners) listeners->notifyOpInserted(op, oldBlock, newBlock);
+
// Invalidate the order on the operation.
op->orderIndex = Operation::kInvalidOrderIdx;
}
@@ -392,7 +390,6 @@ void llvm::ilist_traits<::mlir::Operation>::addNodeToList(Operation *op) {
/// We keep the block pointer up to date.
void llvm::ilist_traits<::mlir::Operation>::removeNodeFromList(Operation *op) {
assert(op->block && "not already in an operation block!");
- if (listeners) listeners->notifyOpRemoved(op);
op->block = nullptr;
}
More information about the Mlir-commits
mailing list