[Mlir-commits] [mlir] 0bf9aab - [mlir:OpenMP] Fix memory leak in asan translation

River Riddle llvmlistbot at llvm.org
Tue Mar 15 21:56:38 PDT 2022


Author: River Riddle
Date: 2022-03-15T21:54:55-07:00
New Revision: 0bf9aabd09f2c49cc43e16d6d62f86126c9fddd9

URL: https://github.com/llvm/llvm-project/commit/0bf9aabd09f2c49cc43e16d6d62f86126c9fddd9
DIFF: https://github.com/llvm/llvm-project/commit/0bf9aabd09f2c49cc43e16d6d62f86126c9fddd9.diff

LOG: [mlir:OpenMP] Fix memory leak in asan translation

A fake unreachable was created and removed, but never
erased.

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp b/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
index e1652af2c8f67..82fd430d94e8f 100644
--- a/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
+++ b/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
@@ -1100,14 +1100,13 @@ convertOmpAtomicUpdate(omp::AtomicUpdateOp &opInst,
 
   // 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->createAtomicUpdate(
       ompLoc, findAllocaInsertPoint(builder, moduleTranslation), llvmAtomicX,


        


More information about the Mlir-commits mailing list