[Mlir-commits] [mlir] [mlir][MemRefToLLVM] Erase conflicting func declarations before conversion (PR #195960)

Matthias Springer llvmlistbot at llvm.org
Wed May 6 00:30:26 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)
----------------
matthias-springer wrote:

Why is there a `func.func private @free(!llvm.ptr)` in the first place?

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


More information about the Mlir-commits mailing list