brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.5 KiB · 6a7984c Raw
53 lines · plain
1// RUN: mlir-opt %s -generate-runtime-verification \2// RUN:     -test-cf-assert \3// RUN:     -convert-to-llvm \4// RUN:     -reconcile-unrealized-casts | \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:     -test-cf-assert \11// RUN:     -convert-to-llvm="allow-pattern-rollback=0" \12// RUN:     -reconcile-unrealized-casts | \13// RUN: mlir-runner -e main -entry-point-result=void \14// RUN:     -shared-libs=%mlir_runner_utils 2>&1 | \15// RUN: FileCheck %s16 17func.func @store_dynamic(%memref: memref<?xf32>, %index: index) {18  %cst = arith.constant 1.0 : f3219  memref.atomic_rmw addf %cst, %memref[%index] : (f32, memref<?xf32>) -> f3220  return21}22 23func.func @main() {24  // Allocate a memref<10xf32>, but disguise it as a memref<5xf32>. This is25  // necessary because "-test-cf-assert" does not abort the program and we do26  // not want to segfault when running the test case.27  %alloc = memref.alloca() : memref<10xf32>28  %ptr = memref.extract_aligned_pointer_as_index %alloc : memref<10xf32> -> index29  %ptr_i64 = arith.index_cast %ptr : index to i6430  %ptr_llvm = llvm.inttoptr %ptr_i64 : i64 to !llvm.ptr31  %c0 = llvm.mlir.constant(0 : index) : i6432  %c1 = llvm.mlir.constant(1 : index) : i6433  %c5 = llvm.mlir.constant(5 : index) : i6434  %4 = llvm.mlir.poison : !llvm.struct<(ptr, ptr, i64, array<1 x i64>, array<1 x i64>)>35  %5 = llvm.insertvalue %ptr_llvm, %4[0] : !llvm.struct<(ptr, ptr, i64, array<1 x i64>, array<1 x i64>)>36  %6 = llvm.insertvalue %ptr_llvm, %5[1] : !llvm.struct<(ptr, ptr, i64, array<1 x i64>, array<1 x i64>)>37  %8 = llvm.insertvalue %c0, %6[2] : !llvm.struct<(ptr, ptr, i64, array<1 x i64>, array<1 x i64>)>38  %9 = llvm.insertvalue %c5, %8[3, 0] : !llvm.struct<(ptr, ptr, i64, array<1 x i64>, array<1 x i64>)>39  %10 = llvm.insertvalue %c1, %9[4, 0] : !llvm.struct<(ptr, ptr, i64, array<1 x i64>, array<1 x i64>)>40  %buffer = builtin.unrealized_conversion_cast %10 : !llvm.struct<(ptr, ptr, i64, array<1 x i64>, array<1 x i64>)> to memref<5xf32>41  %cast = memref.cast %buffer : memref<5xf32> to memref<?xf32>42 43  //      CHECK: ERROR: Runtime op verification failed44  // CHECK-NEXT: memref.atomic_rmw addf %{{.*}}, %{{.*}} : (f32, memref<?xf32>) -> f3245  // CHECK-NEXT: ^ out-of-bounds access46  // CHECK-NEXT: Location: loc({{.*}})47  %c9 = arith.constant 9 : index48  func.call @store_dynamic(%cast, %c9) : (memref<?xf32>, index) -> ()49 50  return51}52 53