brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.3 KiB · ae46de1 Raw
48 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:     -reconcile-unrealized-casts | \6// RUN: mlir-runner -e main -entry-point-result=void \7// RUN:     -shared-libs=%mlir_runner_utils 2>&1 | \8// RUN: FileCheck %s9 10// RUN: mlir-opt %s -generate-runtime-verification \11// RUN:     -expand-strided-metadata \12// RUN:     -test-cf-assert \13// RUN:     -convert-to-llvm="allow-pattern-rollback=0" \14// RUN:     -reconcile-unrealized-casts | \15// RUN: mlir-runner -e main -entry-point-result=void \16// RUN:     -shared-libs=%mlir_runner_utils 2>&1 | \17// RUN: FileCheck %s18 19func.func @main() {20  // This buffer is properly aligned. There should be no error.21  // CHECK-NOT: ^ memref is not aligned to 822  %alloc = memref.alloca() : memref<5xf64>23  %0 = memref.assume_alignment %alloc, 8 : memref<5xf64>24 25  // Construct a memref descriptor with a pointer that is not aligned to 4.26  // This cannot be done with just the memref dialect. We have to resort to27  // the LLVM dialect.28  %c0 = llvm.mlir.constant(0 : index) : i6429  %c1 = llvm.mlir.constant(1 : index) : i6430  %c3 = llvm.mlir.constant(3 : index) : i6431  %unaligned_ptr = llvm.inttoptr %c3 : i64 to !llvm.ptr32  %4 = llvm.mlir.poison : !llvm.struct<(ptr, ptr, i64, array<1 x i64>, array<1 x i64>)>33  %5 = llvm.insertvalue %unaligned_ptr, %4[0] : !llvm.struct<(ptr, ptr, i64, array<1 x i64>, array<1 x i64>)>34  %6 = llvm.insertvalue %unaligned_ptr, %5[1] : !llvm.struct<(ptr, ptr, i64, array<1 x i64>, array<1 x i64>)>35  %8 = llvm.insertvalue %c0, %6[2] : !llvm.struct<(ptr, ptr, i64, array<1 x i64>, array<1 x i64>)>36  %9 = llvm.insertvalue %c1, %8[3, 0] : !llvm.struct<(ptr, ptr, i64, array<1 x i64>, array<1 x i64>)>37  %10 = llvm.insertvalue %c1, %9[4, 0] : !llvm.struct<(ptr, ptr, i64, array<1 x i64>, array<1 x i64>)>38  %buffer = builtin.unrealized_conversion_cast %10 : !llvm.struct<(ptr, ptr, i64, array<1 x i64>, array<1 x i64>)> to memref<1xf32>39 40  //      CHECK: ERROR: Runtime op verification failed41  // CHECK-NEXT: %[[ASSUME:.*]] = memref.assume_alignment %{{.*}}, 4 : memref<1xf32>42  // CHECK-NEXT: ^ memref is not aligned to 443  // CHECK-NEXT: Location: loc({{.*}})44  %assume = memref.assume_alignment %buffer, 4 : memref<1xf32>45 46  return47}48