Skip to content

[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

Merged
merged 1 commit into from
May 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions mlir/include/mlir/IR/SymbolTable.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
4 changes: 4 additions & 0 deletions mlir/lib/IR/SymbolTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -998,6 +998,10 @@ SymbolTable &SymbolTableCollection::getSymbolTable(Operation *op) {
return *it.first->second;
}

void SymbolTableCollection::invalidateSymbolTable(Operation *op) {
symbolTables.erase(op);
}

//===----------------------------------------------------------------------===//
// LockedSymbolTableCollection
//===----------------------------------------------------------------------===//
Expand Down