[Mlir-commits] [mlir] [mlir][transform] Fix handling of transitive include in interpreter. (PR #67560)

Ingo Müller llvmlistbot at llvm.org
Wed Oct 4 05:56:50 PDT 2023


================
@@ -218,6 +218,79 @@ StringAttr SymbolTable::insert(Operation *symbol, Block::iterator insertPt) {
   return getSymbolName(symbol);
 }
 
+LogicalResult SymbolTable::rename(StringAttr from, StringAttr to) {
+  Operation *op = lookup(from);
+  return rename(op, to);
+}
+
+LogicalResult SymbolTable::rename(Operation *op, StringAttr to) {
+  StringAttr from = getNameIfSymbol(op);
+
+  assert(from && "expected valid 'name' attribute");
+  assert(op->getParentOp() == symbolTableOp &&
+         "expected this operation to be inside of the operation with this "
+         "SymbolTable");
+  assert(lookup(from) == op && "current name does not resolve to op");
+  assert(lookup(to) == nullptr && "new name already exists");
+
+  if (failed(SymbolTable::replaceAllSymbolUses(op, to, getOp())))
----------------
ingomueller-net wrote:

NB: If I replace this with `SymbolTable::replaceAllSymbolUses(cast<SymbolOpInterface>(op)->getNameAttr(), to, getOp())`, things break as some symbols don't get renamed. I found that *very* surprising. Is that indeed intended behavior? I would have expected that, irrespectively of whether I provide the name directly or via an op, all symbols with that name are replaced.

https://github.com/llvm/llvm-project/pull/67560


More information about the Mlir-commits mailing list