[mlir][OpenMP] Fix memory leak by deleting unused value

Reviewed By: ftynse, rriddle

Differential Revision: https://reviews.llvm.org/D122633
This commit is contained in:
Shraiysh Vaishay 2022-03-30 03:11:14 +05:30
parent ecb4171dcb
commit 4d1010909f

View File

@ -1219,14 +1219,13 @@ convertOmpAtomicCapture(omp::AtomicCaptureOp atomicCaptureOp,
};
// Handle ambiguous alloca, if any.
auto allocaIP = findAllocaInsertPoint(builder, moduleTranslation);
llvm::UnreachableInst *unreachableInst;
if (allocaIP.getPoint() == ompLoc.IP.getPoint()) {
// Same point => split basic block and make them unambigous.
unreachableInst = builder.CreateUnreachable();
llvm::UnreachableInst *unreachableInst = builder.CreateUnreachable();
builder.SetInsertPoint(builder.GetInsertBlock()->splitBasicBlock(
unreachableInst, "alloca_split"));
ompLoc.IP = builder.saveIP();
unreachableInst->removeFromParent();
unreachableInst->eraseFromParent();
}
builder.restoreIP(ompBuilder->createAtomicCapture(
ompLoc, findAllocaInsertPoint(builder, moduleTranslation), llvmAtomicX,