[Mlir-commits] [mlir] [mlir][bufferization] Drop equivalent buffer results - modify public functions option (PR #177589)

Matthias Springer llvmlistbot at llvm.org
Mon Feb 2 00:24:56 PST 2026


================
@@ -0,0 +1,76 @@
+// RUN: mlir-opt -drop-equivalent-buffer-results -split-input-file %s | FileCheck %s
+// RUN: mlir-opt -drop-equivalent-buffer-results=modify-public-functions=1 -split-input-file %s | \
+// RUN:   FileCheck %s --check-prefix=MODIFY-PUBLIC
+
+
+// CHECK-LABEL: func private @single_buffer_return({{.*}}) {
+// CHECK: return
+
+!type = memref<?xf32, strided<[?], offset: ?>>
+func.func private @single_buffer_return(%buf: !type, %val: f32, %idx: index) -> !type {
+  memref.store %val, %buf[%idx] : !type
+  return %buf : !type
+}
+
+// -----
+
+// CHECK-LABEL: func private @multiple_buffer_returns({{.*}}) {
+// CHECK: return
+
+!type = memref<?xf32, strided<[?], offset: ?>>
+!type1 = memref<?x?xf32>
+func.func private @multiple_buffer_returns(
+    %buf: !type, %buf1: !type1, %val: f32, %idx: index) -> (!type1, !type) {
+  memref.store %val, %buf[%idx] : !type
+  memref.store %val, %buf1[%idx, %idx] : !type1
+  return %buf1, %buf : !type1, !type
+}
+
+// -----
+
+// CHECK-LABEL: func private @multiple_mixed_returns({{.*}}) -> i32 {
+// CHECK: %[[CST:.+]] = arith.constant 1 : i32
+// CHECK: return %[[CST]] : i32
+
+!type = memref<?xf32, strided<[?], offset: ?>>
+!type1 = memref<?x?xf32>
+func.func private @multiple_mixed_returns(
+    %buf: !type, %buf1: !type1, %val: f32, %idx: index) -> (!type1, i32, !type) {
+  memref.store %val, %buf[%idx] : !type
+  memref.store %val, %buf1[%idx, %idx] : !type1
+  %cst = arith.constant 1 : i32
+  return %buf1, %cst, %buf : !type1, i32, !type
+}
+
+// -----
+
+// Ensure public functions remain unchanged by default.
+// CHECK-LABEL: func @public_function(
+// CHECK-SAME:    %[[BUF:.+]]: memref<?xf32, strided<[?], offset: ?>>,
+// CHECK-SAME:    ) -> memref<?xf32, strided<[?], offset: ?>> {
+// CHECK: return %[[BUF]]
+
+// When explicitly requested, public functions can be modified.
----------------
matthias-springer wrote:

Can you also add a call site for one of the tests?

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


More information about the Mlir-commits mailing list