[Mlir-commits] [mlir] [mlir][MemRefToLLVM] Erase conflicting func declarations before conversion (PR #195960)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Wed May 6 03:02:09 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)
----------------
khaki3 wrote:
We're running both convert-func-to-llvm and finalize-memref-to-llvm together. Our policy was to convert multiple operations to LLVM in a single pass to maintain access to original types. However, it seems func-to-llvm allows us to keep function signatures anyway, so I’ll close this PR.
https://github.com/llvm/llvm-project/pull/195960
More information about the Mlir-commits
mailing list