75 lines · plain
1// RUN: mlir-opt %s -generate-runtime-verification \2// RUN: -expand-strided-metadata \3// RUN: -test-cf-assert \4// RUN: -convert-to-llvm | \5// RUN: mlir-runner -e main -entry-point-result=void \6// RUN: -shared-libs=%mlir_runner_utils 2>&1 | \7// RUN: FileCheck %s8 9// RUN: mlir-opt %s -generate-runtime-verification \10// RUN: -expand-strided-metadata \11// RUN: -test-cf-assert \12// RUN: -convert-to-llvm="allow-pattern-rollback=0" \13// RUN: -reconcile-unrealized-casts | \14// RUN: mlir-runner -e main -entry-point-result=void \15// RUN: -shared-libs=%mlir_runner_utils 2>&1 | \16// RUN: FileCheck %s17 18func.func @load(%memref: memref<1xf32>, %index: index) {19 memref.load %memref[%index] : memref<1xf32>20 return21}22 23func.func @load_dynamic(%memref: memref<?xf32>, %index: index) {24 memref.load %memref[%index] : memref<?xf32>25 return26}27 28func.func @load_nd_dynamic(%memref: memref<?x?x?xf32>, %index0: index, %index1: index, %index2: index) {29 memref.load %memref[%index0, %index1, %index2] : memref<?x?x?xf32>30 return31}32 33func.func @main() {34 %0 = arith.constant 0 : index35 %1 = arith.constant 1 : index36 %n1 = arith.constant -1 : index37 %2 = arith.constant 2 : index38 %alloca_1 = memref.alloca() : memref<1xf32>39 %alloc_1 = memref.alloc(%1) : memref<?xf32>40 %alloc_2x2x2 = memref.alloc(%2, %2, %2) : memref<?x?x?xf32>41 42 // CHECK: ERROR: Runtime op verification failed43 // CHECK-NEXT: memref.load %{{.*}}[%{{.*}}] : memref<1xf32>44 // CHECK-NEXT: ^ out-of-bounds access45 // CHECK-NEXT: Location: loc({{.*}})46 func.call @load(%alloca_1, %1) : (memref<1xf32>, index) -> ()47 48 // CHECK: ERROR: Runtime op verification failed49 // CHECK-NEXT: memref.load %{{.*}}[%{{.*}}] : memref<?xf32>50 // CHECK-NEXT: ^ out-of-bounds access51 // CHECK-NEXT: Location: loc({{.*}})52 func.call @load_dynamic(%alloc_1, %1) : (memref<?xf32>, index) -> ()53 54 // CHECK: ERROR: Runtime op verification failed55 // CHECK-NEXT: memref.load %{{.*}}[%{{.*}}] : memref<?x?x?xf32>56 // CHECK-NEXT: ^ out-of-bounds access57 // CHECK-NEXT: Location: loc({{.*}})58 func.call @load_nd_dynamic(%alloc_2x2x2, %1, %n1, %0) : (memref<?x?x?xf32>, index, index, index) -> ()59 60 // CHECK-NOT: ERROR: Runtime op verification failed61 func.call @load(%alloca_1, %0) : (memref<1xf32>, index) -> ()62 63 // CHECK-NOT: ERROR: Runtime op verification failed64 func.call @load_dynamic(%alloc_1, %0) : (memref<?xf32>, index) -> ()65 66 // CHECK-NOT: ERROR: Runtime op verification failed67 func.call @load_nd_dynamic(%alloc_2x2x2, %1, %1, %0) : (memref<?x?x?xf32>, index, index, index) -> ()68 69 memref.dealloc %alloc_1 : memref<?xf32>70 memref.dealloc %alloc_2x2x2 : memref<?x?x?xf32>71 72 return73}74 75