From: Mehdi Amini Date: Sat, 2 Oct 2021 23:55:25 +0000 (+0000) Subject: Fix memory leak in MLIR SPIRV ModuleCombiner X-Git-Tag: upstream/15.0.7~29819 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2da3facd864c36739e6e7f4b90e12aeb5afa7695;p=platform%2Fupstream%2Fllvm.git Fix memory leak in MLIR SPIRV ModuleCombiner --- diff --git a/mlir/lib/Dialect/SPIRV/Linking/ModuleCombiner/ModuleCombiner.cpp b/mlir/lib/Dialect/SPIRV/Linking/ModuleCombiner/ModuleCombiner.cpp index 2b4ac38..69e6859 100644 --- a/mlir/lib/Dialect/SPIRV/Linking/ModuleCombiner/ModuleCombiner.cpp +++ b/mlir/lib/Dialect/SPIRV/Linking/ModuleCombiner/ModuleCombiner.cpp @@ -126,7 +126,7 @@ OwningOpRef combine(ArrayRef inputModules, unsigned lastUsedID = 0; for (auto inputModule : inputModules) { - spirv::ModuleOp moduleClone = inputModule.clone(); + OwningOpRef moduleClone = inputModule.clone(); // In the combined module, rename all symbols that conflict with symbols // from the current input module. This renaming applies to all ops except @@ -141,7 +141,7 @@ OwningOpRef combine(ArrayRef inputModules, StringRef oldSymName = symbolOp.getName(); if (!isa(op) && - failed(updateSymbolAndAllUses(symbolOp, combinedModule, moduleClone, + failed(updateSymbolAndAllUses(symbolOp, combinedModule, *moduleClone, lastUsedID))) return nullptr; @@ -170,14 +170,14 @@ OwningOpRef combine(ArrayRef inputModules, // In the current input module, rename all symbols that conflict with // symbols from the combined module. This includes renaming spv.funcs. - for (auto &op : *moduleClone.getBody()) { + for (auto &op : *moduleClone->getBody()) { auto symbolOp = dyn_cast(op); if (!symbolOp) continue; StringRef oldSymName = symbolOp.getName(); - if (failed(updateSymbolAndAllUses(symbolOp, moduleClone, combinedModule, + if (failed(updateSymbolAndAllUses(symbolOp, *moduleClone, combinedModule, lastUsedID))) return nullptr; @@ -203,7 +203,7 @@ OwningOpRef combine(ArrayRef inputModules, } // Clone all the module's ops to the combined module. - for (auto &op : *moduleClone.getBody()) + for (auto &op : *moduleClone->getBody()) combinedModuleBuilder.insert(op.clone()); }