Skip to content

Commit 2da3fac

Browse files
committed
Fix memory leak in MLIR SPIRV ModuleCombiner
1 parent bac4529 commit 2da3fac

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

mlir/lib/Dialect/SPIRV/Linking/ModuleCombiner/ModuleCombiner.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ OwningOpRef<spirv::ModuleOp> combine(ArrayRef<spirv::ModuleOp> inputModules,
126126
unsigned lastUsedID = 0;
127127

128128
for (auto inputModule : inputModules) {
129-
spirv::ModuleOp moduleClone = inputModule.clone();
129+
OwningOpRef<spirv::ModuleOp> moduleClone = inputModule.clone();
130130

131131
// In the combined module, rename all symbols that conflict with symbols
132132
// from the current input module. This renaming applies to all ops except
@@ -141,7 +141,7 @@ OwningOpRef<spirv::ModuleOp> combine(ArrayRef<spirv::ModuleOp> inputModules,
141141
StringRef oldSymName = symbolOp.getName();
142142

143143
if (!isa<FuncOp>(op) &&
144-
failed(updateSymbolAndAllUses(symbolOp, combinedModule, moduleClone,
144+
failed(updateSymbolAndAllUses(symbolOp, combinedModule, *moduleClone,
145145
lastUsedID)))
146146
return nullptr;
147147

@@ -170,14 +170,14 @@ OwningOpRef<spirv::ModuleOp> combine(ArrayRef<spirv::ModuleOp> inputModules,
170170

171171
// In the current input module, rename all symbols that conflict with
172172
// symbols from the combined module. This includes renaming spv.funcs.
173-
for (auto &op : *moduleClone.getBody()) {
173+
for (auto &op : *moduleClone->getBody()) {
174174
auto symbolOp = dyn_cast<SymbolOpInterface>(op);
175175
if (!symbolOp)
176176
continue;
177177

178178
StringRef oldSymName = symbolOp.getName();
179179

180-
if (failed(updateSymbolAndAllUses(symbolOp, moduleClone, combinedModule,
180+
if (failed(updateSymbolAndAllUses(symbolOp, *moduleClone, combinedModule,
181181
lastUsedID)))
182182
return nullptr;
183183

@@ -203,7 +203,7 @@ OwningOpRef<spirv::ModuleOp> combine(ArrayRef<spirv::ModuleOp> inputModules,
203203
}
204204

205205
// Clone all the module's ops to the combined module.
206-
for (auto &op : *moduleClone.getBody())
206+
for (auto &op : *moduleClone->getBody())
207207
combinedModuleBuilder.insert(op.clone());
208208
}
209209

0 commit comments

Comments
 (0)