[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:05:49 PDT 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-mlir

Author: Baz (batzor)

<details>
<summary>Changes</summary>

`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


---
Full diff: https://github.com/llvm/llvm-project/pull/153133.diff


1 Files Affected:

- (modified) mlir/include/mlir/ExecutionEngine/MemRefUtils.h (+1-1) 


``````````diff
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())

``````````

</details>


https://github.com/llvm/llvm-project/pull/153133


More information about the Mlir-commits mailing list