[Mlir-commits] [mlir] [mlir] Add pass to add comdat to all linkonce functions (PR #65270)

Mehdi Amini llvmlistbot at llvm.org
Mon Sep 11 15:51:02 PDT 2023


================
@@ -45,12 +46,13 @@ struct AddComdatsPass : public LLVM::impl::LLVMAddComdatsBase<AddComdatsPass> {
   void runOnOperation() override {
     OpBuilder builder{&getContext()};
     ModuleOp mod = getOperation();
-    mod.walk([&](LLVM::LLVMFuncOp op) {
+    SymbolTable symbolTable{mod};
----------------
joker-eph wrote:

One slight more tweak, can we make this lazy? Maybe:
```
std::unique_ptr<SymbolTable> symbolTable;
auto getSymTab = [&] () -> SymbolTable& {
  if (!symbolTable)
    symbolTable = std::make_unique<SymbolTable>(mod);
  return *symbolTable;
};
```

And then you can call `addComdat(op, builder, getSymTab(), mod);`


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


More information about the Mlir-commits mailing list