[Mlir-commits] [mlir] [mlir][func] Fix multiple bugs in `DuplicateFunctionElimination` (PR #109571)

Mehdi Amini llvmlistbot at llvm.org
Sun Sep 22 09:51:38 PDT 2024


================
@@ -97,14 +101,14 @@ struct DuplicateFunctionEliminationPass
       }
     });
 
-    // Update call ops to call unique func op representants.
-    module.walk([&](func::CallOp callOp) {
-      func::FuncOp callee = getRepresentant[callOp.getCalleeAttr().getAttr()];
-      callOp.setCallee(callee.getSymName());
-    });
-
-    // Erase redundant func ops.
+    // Update all symbol uses to reference unique func op
+    // representants and erase redundant func ops.
     for (auto it : toBeErased) {
+      auto oldSymbol = it.getSymNameAttr();
+      auto newSymbol = getRepresentant[oldSymbol].getSymNameAttr();
+      if (failed(
+              SymbolTable::replaceAllSymbolUses(oldSymbol, newSymbol, module)))
----------------
joker-eph wrote:

I'm concerned that `SymbolTable::replaceAllSymbolUses` is expensive inside the loop, we should be able to setup the mapping of definition/users in a single traversal of the module and then process the updates.

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


More information about the Mlir-commits mailing list