[Mlir-commits] [mlir] [mlir][ExecutionEngine] fix default free function in `OwningMemRef`. (PR #153133)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Mon Aug 11 21:04:57 PDT 2025
https://github.com/batzor created https://github.com/llvm/llvm-project/pull/153133
`basePtr` should be freed instead of `data` because it is the one which is storing the output of `malloc`. In `allocAligned()`, the `data` is malloced and then assigned to `basePtr`.
For details, take a look at:
https://github.com/llvm/llvm-project/blob/e0df5f8/mlir/include/mlir/ExecutionEngine/MemRefUtils.h#L111 https://github.com/llvm/llvm-project/blob/e0df5f8/mlir/include/mlir/ExecutionEngine/MemRefUtils.h#L167-L170 https://github.com/llvm/llvm-project/blob/e0df5f8/mlir/include/mlir/ExecutionEngine/MemRefUtils.h#L59-L96
>From 97f041f041f120201f6501cfa17fad877da674fc Mon Sep 17 00:00:00 2001
From: Batzorig Zorigoo <32958247+batzor at users.noreply.github.com>
Date: Tue, 12 Aug 2025 12:45:02 +0900
Subject: [PATCH] fix(mlir): free properly in `OwningMemRef`
`basePtr` should be freed instead of `data` because it is the one which
is storing the output of `malloc`.
For details, take a look at:
https://github.com/llvm/llvm-project/blob/e0df5f8/mlir/include/mlir/ExecutionEngine/MemRefUtils.h#L111
https://github.com/llvm/llvm-project/blob/e0df5f8/mlir/include/mlir/ExecutionEngine/MemRefUtils.h#L167-L170
https://github.com/llvm/llvm-project/blob/e0df5f8/mlir/include/mlir/ExecutionEngine/MemRefUtils.h#L59-L96
---
mlir/include/mlir/ExecutionEngine/MemRefUtils.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mlir/include/mlir/ExecutionEngine/MemRefUtils.h b/mlir/include/mlir/ExecutionEngine/MemRefUtils.h
index 6e72f7c23bdcf..d66d757cb7a8e 100644
--- a/mlir/include/mlir/ExecutionEngine/MemRefUtils.h
+++ b/mlir/include/mlir/ExecutionEngine/MemRefUtils.h
@@ -151,7 +151,7 @@ class OwningMemRef {
AllocFunType allocFun = &::malloc,
std::function<void(StridedMemRefType<T, Rank>)> freeFun =
[](StridedMemRefType<T, Rank> descriptor) {
- ::free(descriptor.data);
+ ::free(descriptor.basePtr);
})
: freeFunc(freeFun) {
if (shapeAlloc.empty())
More information about the Mlir-commits
mailing list