Skip to content

Commit 4d10109

Browse files
committed
[mlir][OpenMP] Fix memory leak by deleting unused value
Reviewed By: ftynse, rriddle Differential Revision: https://reviews.llvm.org/D122633
1 parent ecb4171 commit 4d10109

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1219,14 +1219,13 @@ convertOmpAtomicCapture(omp::AtomicCaptureOp atomicCaptureOp,
12191219
};
12201220
// Handle ambiguous alloca, if any.
12211221
auto allocaIP = findAllocaInsertPoint(builder, moduleTranslation);
1222-
llvm::UnreachableInst *unreachableInst;
12231222
if (allocaIP.getPoint() == ompLoc.IP.getPoint()) {
12241223
// Same point => split basic block and make them unambigous.
1225-
unreachableInst = builder.CreateUnreachable();
1224+
llvm::UnreachableInst *unreachableInst = builder.CreateUnreachable();
12261225
builder.SetInsertPoint(builder.GetInsertBlock()->splitBasicBlock(
12271226
unreachableInst, "alloca_split"));
12281227
ompLoc.IP = builder.saveIP();
1229-
unreachableInst->removeFromParent();
1228+
unreachableInst->eraseFromParent();
12301229
}
12311230
builder.restoreIP(ompBuilder->createAtomicCapture(
12321231
ompLoc, findAllocaInsertPoint(builder, moduleTranslation), llvmAtomicX,

0 commit comments

Comments
 (0)