[all-commits] [llvm/llvm-project] 479057: [mlir] Make overloads of SymbolTable::replaceAllSy...
Ingo Müller via All-commits
all-commits at lists.llvm.org
Mon Oct 9 22:47:21 PDT 2023
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 479057887fbc8bfef17c86694f78496c54550f21
https://github.com/llvm/llvm-project/commit/479057887fbc8bfef17c86694f78496c54550f21
Author: Ingo Müller <ingomueller at google.com>
Date: 2023-10-10 (Tue, 10 Oct 2023)
Changed paths:
M mlir/lib/IR/SymbolTable.cpp
M mlir/test/python/ir/symbol_table.py
M mlir/unittests/IR/CMakeLists.txt
A mlir/unittests/IR/SymbolTableTest.cpp
Log Message:
-----------
[mlir] Make overloads of SymbolTable::replaceAllSymbolUses consistent. (#68320)
This function has several overloads that allow to specify the symbol
that should be renamed and the scope for that renaming in different
ways. The overloads were inconsistent in the following way (quoted
strings are `StringAttr`s, other variables are `Operation *`):
* `replaceAllSymbolUses(symbolOp, "new_symbol", scopeOp)` would traverse
into the nested regions of `scopeOp` and hence rename the symbol inside
of `scopeOp`.
* `replaceAllSymbolUses("symbol", "new_symbol", scopeOp)` would *not*
traverse into the nested regions of `scopeOp` and hence *not* rename the
symbol.
The underlying behavior was spread over different places and is somewhat
hard to understand. The two overloads above mainly differed by what
`collectSymbolScopes` computed, which is itself overloaded. If `scopeOp`
is a top-level module, then the overload on `(Operation *, Operation
*)`, which is used in the first of the above cases, computes a scope
where the body region of the module is the `limit`; however, the
overload on `(StringAttr, Operation *)` computed the module op itself as
the `limit`. Later, `walkSymbolTable` would walk the body of the module
if it was given as a region but it would *not* enter the regions of the
module op because that op has a symbol table (which was assumed to be a
*different* scope).
The fix in this commit is change the behavior of `collectSymbolScopes`
such that the `(StringAttr, Operation *)` overload returns a scope for
each region in the `limit` argument.
More information about the All-commits
mailing list