// RUN: mlir-opt %s -func-bufferize -split-input-file -verify-diagnostics | FileCheck %s // CHECK-LABEL: func @identity( // CHECK-SAME: %[[ARG:.*]]: memref) -> memref { // CHECK: %[[TENSOR:.*]] = tensor_load %[[ARG]] : memref // CHECK: %[[MEMREF:.*]] = tensor_to_memref %[[TENSOR]] : memref // CHECK: return %[[MEMREF]] : memref func @identity(%arg0: tensor) -> tensor { return %arg0 : tensor } // CHECK-LABEL: func @block_arguments( // CHECK-SAME: %[[ARG:.*]]: memref) -> memref { // CHECK: %[[T1:.*]] = tensor_load %[[ARG]] : memref // CHECK: %[[M1:.*]] = tensor_to_memref %[[T1]] : memref // CHECK: br ^bb1(%[[M1]] : memref) // CHECK: ^bb1(%[[BBARG:.*]]: memref): // CHECK: %[[T2:.*]] = tensor_load %[[BBARG]] : memref // CHECK: %[[M2:.*]] = tensor_to_memref %[[T2]] : memref // CHECK: return %[[M2]] : memref func @block_arguments(%arg0: tensor) -> tensor { br ^bb1(%arg0: tensor) ^bb1(%bbarg: tensor): return %bbarg : tensor } // CHECK-LABEL: func private @source() -> memref // CHECK-LABEL: func @call_source() -> memref { // CHECK: %[[RET:.*]] = call @source() : () -> memref // CHECK: return %[[RET]] : memref func private @source() -> tensor func @call_source() -> tensor { %0 = call @source() : () -> tensor return %0 : tensor } // CHECK-LABEL: func @call_sink( // CHECK-SAME: %[[ARG:.*]]: memref) { // CHECK: %[[TENSOR:.*]] = tensor_load %[[ARG]] : memref // CHECK: %[[MEMREF:.*]] = tensor_to_memref %[[TENSOR]] : memref // CHECK: call @sink(%[[MEMREF]]) : (memref) -> () // CHECK: return func private @sink(tensor) func @call_sink(%arg0: tensor) { call @sink(%arg0) : (tensor) -> () return } // CHECK-LABEL: func @unconverted_op_in_body() -> memref { // CHECK: %[[TENSOR:.*]] = "test.source"() : () -> tensor // CHECK: %[[MEMREF:.*]] = tensor_to_memref %[[TENSOR]] : memref // CHECK: return %[[MEMREF]] : memref func @unconverted_op_in_body() -> tensor { %0 = "test.source"() : () -> tensor return %0 : tensor } // ----- // Because this pass updates block arguments, it needs to also atomically // update all terminators and issue an error if that is not possible. func @unable_to_update_terminator(%arg0: tensor) -> tensor { %0 = constant true cond_br %0, ^bb1(%arg0: tensor), ^bb2(%arg0: tensor) ^bb1(%bbarg0: tensor): // expected-error @+1 {{failed to legalize operation 'test.terminator'}} "test.terminator"() : () -> () ^bb2(%bbarg1: tensor): return %bbarg1 : tensor }