[Mlir-commits] [mlir] [mlir][MemRefToLLVM] Erase conflicting func declarations before conversion (PR #195960)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Thu May 7 09:55:29 PDT 2026
================
@@ -0,0 +1,18 @@
+// RUN: mlir-opt -finalize-memref-to-llvm %s | FileCheck %s
+
+// Verify that memref.dealloc is lowered even when a func.func @free
+// declaration already exists in the module. The conflicting declaration
+// is erased and replaced with llvm.func @free before the conversion runs.
+
+// CHECK: llvm.func @free(!llvm.ptr)
+// CHECK-LABEL: func.func @dealloc_with_existing_free
+// CHECK: llvm.call @free(%{{.*}}) : (!llvm.ptr) -> ()
+// CHECK: return
+// CHECK-NOT: func.func @free
+
+func.func @dealloc_with_existing_free(%arg0: memref<?xf32>) {
+ memref.dealloc %arg0 : memref<?xf32>
+ return
+}
+
+func.func private @free(!llvm.ptr)
----------------
jeanPerier wrote:
> Why is there a func.func private @free(!llvm.ptr) in the first place?
To answer this, because when the code comes from Fortran/C/C++, the user may be using free/malloc/... directly too.
https://github.com/llvm/llvm-project/pull/195960
More information about the Mlir-commits
mailing list