[Mlir-commits] [mlir] 69eb7e3 - Free the memory allocated by mlirOperationStateAddXXX methods in mlirOperationCreate.
Alex Zinenko
llvmlistbot at llvm.org
Mon Aug 10 01:32:59 PDT 2020
Author: Jing Pu
Date: 2020-08-10T10:32:50+02:00
New Revision: 69eb7e36aa3c71997811054bb31d4546b08bfff0
URL: https://github.com/llvm/llvm-project/commit/69eb7e36aa3c71997811054bb31d4546b08bfff0
DIFF: https://github.com/llvm/llvm-project/commit/69eb7e36aa3c71997811054bb31d4546b08bfff0.diff
LOG: Free the memory allocated by mlirOperationStateAddXXX methods in mlirOperationCreate.
Previously, the memory leaks on heap. Since the MlirOperationState is not intended to be used again after mlirOperationCreate, the patch simplify frees the memory in mlirOperationCreate instead of creating any new API.
Reviewed By: ftynse
Differential Revision: https://reviews.llvm.org/D85629
Added:
Modified:
mlir/lib/CAPI/IR/IR.cpp
Removed:
################################################################################
diff --git a/mlir/lib/CAPI/IR/IR.cpp b/mlir/lib/CAPI/IR/IR.cpp
index 3161bda2081b..be477325d3b6 100644
--- a/mlir/lib/CAPI/IR/IR.cpp
+++ b/mlir/lib/CAPI/IR/IR.cpp
@@ -176,6 +176,12 @@ MlirOperation mlirOperationCreate(const MlirOperationState *state) {
for (unsigned i = 0; i < state->nRegions; ++i)
cppState.addRegion(std::unique_ptr<Region>(unwrap(state->regions[i])));
+ free(state->results);
+ free(state->operands);
+ free(state->regions);
+ free(state->successors);
+ free(state->attributes);
+
return wrap(Operation::create(cppState));
}
More information about the Mlir-commits
mailing list