File tree Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -316,6 +316,13 @@ class SymbolTableCollection {
316
316
// / Lookup, or create, a symbol table for an operation.
317
317
SymbolTable &getSymbolTable (Operation *op);
318
318
319
+ // / Invalidate the cached symbol table for an operation.
320
+ // / This is important when doing IR modifications that erase and also create
321
+ // / operations having the 'OpTrait::SymbolTable' trait. If a symbol table of
322
+ // / an erased operation is not invalidated, a new operation sharing the same
323
+ // / address would be associated with outdated, and wrong, information.
324
+ void invalidateSymbolTable (Operation *op);
325
+
319
326
private:
320
327
friend class LockedSymbolTableCollection ;
321
328
Original file line number Diff line number Diff line change @@ -998,6 +998,13 @@ SymbolTable &SymbolTableCollection::getSymbolTable(Operation *op) {
998
998
return *it.first ->second ;
999
999
}
1000
1000
1001
+ void SymbolTableCollection::invalidateSymbolTable (Operation *op) {
1002
+ auto it = symbolTables.find (op);
1003
+
1004
+ if (it != symbolTables.end ())
1005
+ symbolTables.erase (it);
1006
+ }
1007
+
1001
1008
// ===----------------------------------------------------------------------===//
1002
1009
// LockedSymbolTableCollection
1003
1010
// ===----------------------------------------------------------------------===//
You can’t perform that action at this time.
0 commit comments