-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[MLIR] Add method to invalidate cached symbol table #138014
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@llvm/pr-subscribers-mlir-core Author: Michele Scuttari (mscuttari) ChangesThis PR adds a method to the This is important when doing IR modifications that erase and also create operations having the Full diff: https://github.com/llvm/llvm-project/pull/138014.diff 2 Files Affected:
diff --git a/mlir/include/mlir/IR/SymbolTable.h b/mlir/include/mlir/IR/SymbolTable.h
index 597c6a9a1d891..a22d6f3a0426b 100644
--- a/mlir/include/mlir/IR/SymbolTable.h
+++ b/mlir/include/mlir/IR/SymbolTable.h
@@ -316,6 +316,13 @@ class SymbolTableCollection {
/// Lookup, or create, a symbol table for an operation.
SymbolTable &getSymbolTable(Operation *op);
+ /// Invalidate the cached symbol table for an operation.
+ /// This is important when doing IR modifications that erase and also create
+ /// operations having the 'OpTrait::SymbolTable' trait. If a symbol table of
+ /// an erased operation is not invalidated, a new operation sharing the same
+ /// address would be associated with outdated, and wrong, information.
+ void invalidateSymbolTable(Operation *op);
+
private:
friend class LockedSymbolTableCollection;
diff --git a/mlir/lib/IR/SymbolTable.cpp b/mlir/lib/IR/SymbolTable.cpp
index 76c9b7b1e8afa..6a97adaba6cdc 100644
--- a/mlir/lib/IR/SymbolTable.cpp
+++ b/mlir/lib/IR/SymbolTable.cpp
@@ -998,6 +998,13 @@ SymbolTable &SymbolTableCollection::getSymbolTable(Operation *op) {
return *it.first->second;
}
+void SymbolTableCollection::invalidateSymbolTable(Operation *op) {
+ auto it = symbolTables.find(op);
+
+ if (it != symbolTables.end())
+ symbolTables.erase(it);
+}
+
//===----------------------------------------------------------------------===//
// LockedSymbolTableCollection
//===----------------------------------------------------------------------===//
|
@llvm/pr-subscribers-mlir Author: Michele Scuttari (mscuttari) ChangesThis PR adds a method to the This is important when doing IR modifications that erase and also create operations having the Full diff: https://github.com/llvm/llvm-project/pull/138014.diff 2 Files Affected:
diff --git a/mlir/include/mlir/IR/SymbolTable.h b/mlir/include/mlir/IR/SymbolTable.h
index 597c6a9a1d891..a22d6f3a0426b 100644
--- a/mlir/include/mlir/IR/SymbolTable.h
+++ b/mlir/include/mlir/IR/SymbolTable.h
@@ -316,6 +316,13 @@ class SymbolTableCollection {
/// Lookup, or create, a symbol table for an operation.
SymbolTable &getSymbolTable(Operation *op);
+ /// Invalidate the cached symbol table for an operation.
+ /// This is important when doing IR modifications that erase and also create
+ /// operations having the 'OpTrait::SymbolTable' trait. If a symbol table of
+ /// an erased operation is not invalidated, a new operation sharing the same
+ /// address would be associated with outdated, and wrong, information.
+ void invalidateSymbolTable(Operation *op);
+
private:
friend class LockedSymbolTableCollection;
diff --git a/mlir/lib/IR/SymbolTable.cpp b/mlir/lib/IR/SymbolTable.cpp
index 76c9b7b1e8afa..6a97adaba6cdc 100644
--- a/mlir/lib/IR/SymbolTable.cpp
+++ b/mlir/lib/IR/SymbolTable.cpp
@@ -998,6 +998,13 @@ SymbolTable &SymbolTableCollection::getSymbolTable(Operation *op) {
return *it.first->second;
}
+void SymbolTableCollection::invalidateSymbolTable(Operation *op) {
+ auto it = symbolTables.find(op);
+
+ if (it != symbolTables.end())
+ symbolTables.erase(it);
+}
+
//===----------------------------------------------------------------------===//
// LockedSymbolTableCollection
//===----------------------------------------------------------------------===//
|
@River707 It's the first time I land changes since the switch from Phabricator to Github, so I'd like to be sure that I'm not breaking any rules. Is it fine if I merge without the buildkite checks succeeding? Seems like it can't resolve the commit hash, but I don't understand why. |
Ideally it should be green, weird that it's red. Can you try rebasing? |
b812dc1
to
bef614e
Compare
This PR adds a method to the `SymbolTableCollection` class to invalidate the cached symbol table for an operation. This is important when doing IR modifications that erase and also create operations having the `OpTrait::SymbolTable` trait. If a symbol table of an erased operation is not invalidated, a new operation sharing the same address would be associated with outdated, and wrong, information.
This PR adds a method to the `SymbolTableCollection` class to invalidate the cached symbol table for an operation. This is important when doing IR modifications that erase and also create operations having the `OpTrait::SymbolTable` trait. If a symbol table of an erased operation is not invalidated, a new operation sharing the same address would be associated with outdated, and wrong, information.
This PR adds a method to the `SymbolTableCollection` class to invalidate the cached symbol table for an operation. This is important when doing IR modifications that erase and also create operations having the `OpTrait::SymbolTable` trait. If a symbol table of an erased operation is not invalidated, a new operation sharing the same address would be associated with outdated, and wrong, information.
This PR adds a method to the `SymbolTableCollection` class to invalidate the cached symbol table for an operation. This is important when doing IR modifications that erase and also create operations having the `OpTrait::SymbolTable` trait. If a symbol table of an erased operation is not invalidated, a new operation sharing the same address would be associated with outdated, and wrong, information.
This PR adds a method to the `SymbolTableCollection` class to invalidate the cached symbol table for an operation. This is important when doing IR modifications that erase and also create operations having the `OpTrait::SymbolTable` trait. If a symbol table of an erased operation is not invalidated, a new operation sharing the same address would be associated with outdated, and wrong, information.
…38143) This PR is a follow-up on #138125, and adds a bufferization state class providing information about the IR. The information currently consists of a cached list of symbol tables, which aims to solve the quadratic scaling of the bufferization task with respect to the number of symbols. The PR breaks API compatibility: the `bufferize` method of the `BufferizableOpInterface` has been enriched with a reference to a `BufferizationState` object. The bufferization state must be kept in a valid state by the interface implementations. For example, if an operation with the `Symbol` trait is inserted or replaced, its parent `SymbolTable` must be updated accordingly (see, for example, the bufferization of `arith::ConstantOp`, where the symbol table of the module gets the new global symbol inserted). Similarly, the invalidation of a symbol table must be performed if an operation with the `SymbolTable` trait is removed (this can be performed using the `invalidateSymbolTable` method, introduced in #138014).
This PR adds a method to the
SymbolTableCollection
class to invalidate the cached symbol table for an operation.This is important when doing IR modifications that erase and also create operations having the
OpTrait::SymbolTable
trait. If a symbol table of an erased operation is not invalidated, a new operation sharing the same address would be associated with outdated, and wrong, information.