Skip to content

Commit 91821ba

Browse files
authored
[MLIR] Fix FileCheck annotations and add 32-bit coverage (#167149)
Addresses #93154 by ensuring the test RUN/FILECHECK prefixes across `mlir/test/Conversion/FuncToLLVM/` and related files match their expected outputs, and adds an `index-bitwidth=32` variant of `expand-then-convert-to-llvm.mlir` that exercises `@collapse_shape_dynamic_with_non_identity_layout` through the same MemRef-to-LLVM pipeline so the 32-bit layout descriptors are verified.
1 parent 0246f33 commit 91821ba

File tree

6 files changed

+37
-15
lines changed

6 files changed

+37
-15
lines changed
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// RUN: mlir-opt -set-llvm-module-datalayout -convert-func-to-llvm %s | FileCheck %s
22

3-
// RUN-32: mlir-opt -set-llvm-module-datalayout='data-layout=p:32:32:32' -convert-func-to-llvm %s \
4-
// RUN-32: | FileCheck %s
3+
// RUN: mlir-opt -set-llvm-module-datalayout='data-layout=p:32:32:32' -convert-func-to-llvm %s \
4+
// RUN: | FileCheck %s --check-prefix=CHECK-32
55

66
// CHECK: module attributes {llvm.data_layout = ""}
7-
// CHECK-32: module attributes {llvm.data_layout ="p:32:32:32"}
7+
// CHECK-32: module attributes {llvm.data_layout = "p:32:32:32"}
88
module {}

mlir/test/Conversion/FuncToLLVM/func-memref.mlir

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// RUN: mlir-opt -pass-pipeline="builtin.module(func.func(convert-arith-to-llvm),convert-func-to-llvm,convert-cf-to-llvm,reconcile-unrealized-casts)" -split-input-file %s | FileCheck %s
22
// RUN: mlir-opt -pass-pipeline="builtin.module(func.func(convert-arith-to-llvm),convert-func-to-llvm{use-bare-ptr-memref-call-conv=1},convert-cf-to-llvm,reconcile-unrealized-casts)" -split-input-file %s | FileCheck %s --check-prefix=BAREPTR
3+
// RUN: mlir-opt -pass-pipeline="builtin.module(func.func(convert-arith-to-llvm{index-bitwidth=32}),convert-func-to-llvm{index-bitwidth=32},convert-cf-to-llvm{index-bitwidth=32},reconcile-unrealized-casts)" -split-input-file %s | FileCheck %s --check-prefix=CHECK32
34

45
// BAREPTR-LABEL: func @check_noalias
56
// BAREPTR-SAME: %{{.*}}: !llvm.ptr {llvm.noalias}, %{{.*}}: !llvm.ptr {llvm.noalias}

mlir/test/Conversion/MemRefToLLVM/expand-then-convert-to-llvm.mlir

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// RUN: mlir-opt -expand-strided-metadata -finalize-memref-to-llvm -lower-affine -convert-arith-to-llvm -cse %s -split-input-file | FileCheck %s
2+
// RUN: mlir-opt -expand-strided-metadata -finalize-memref-to-llvm='index-bitwidth=32' -lower-affine -convert-arith-to-llvm='index-bitwidth=32' -cse %s -split-input-file | FileCheck %s --check-prefix=CHECK32
23
//
34
// This test demonstrates a full "memref to llvm" pipeline where
45
// we first expand some of the memref operations (using affine,
@@ -441,10 +442,31 @@ func.func @collapse_shape_dynamic_with_non_identity_layout(
441442
// CHECK: %[[RES:.*]] = builtin.unrealized_conversion_cast %[[DESC6]] : !llvm.struct<(ptr, ptr, i64, array<2 x i64>, array<2 x i64>)> to memref<4x?xf32, strided<[?, ?], offset: ?>>
442443
// CHECK: return %[[RES]] : memref<4x?xf32, strided<[?, ?], offset: ?>>
443444
// CHECK: }
444-
// CHECK32-LABEL: func @collapse_shape_dynamic_with_non_identity_layout(
445-
// CHECK32: llvm.mlir.constant(1 : index) : i32
446-
// CHECK32: llvm.mlir.constant(4 : index) : i32
447-
// CHECK32: llvm.mlir.constant(1 : index) : i32
445+
// CHECK32-LABEL: func.func @collapse_shape_dynamic_with_non_identity_layout(
446+
// CHECK32-SAME: %[[ARG:.*]]: memref<4x?x?xf32, strided<[?, 4, 1], offset: ?>>) -> memref<4x?xf32, strided<[?, ?], offset: ?>> {
447+
// CHECK32: %[[MEM:.*]] = builtin.unrealized_conversion_cast %[[ARG]] : memref<4x?x?xf32, strided<[?, 4, 1], offset: ?>> to !llvm.struct<(ptr, ptr, i32, array<3 x i32>, array<3 x i32>)>
448+
// CHECK32: %[[BASE_BUFFER:.*]] = llvm.extractvalue %[[MEM]][0] : !llvm.struct<(ptr, ptr, i32,
449+
// CHECK32: %[[ALIGNED_BUFFER:.*]] = llvm.extractvalue %[[MEM]][1] : !llvm.struct<(ptr, ptr, i32,
450+
// CHECK32: %[[OFFSET:.*]] = llvm.extractvalue %[[MEM]][2] : !llvm.struct<(ptr, ptr, i32, array<3 x i32>, array<3 x i32>)>
451+
// CHECK32: %[[SIZE1:.*]] = llvm.extractvalue %[[MEM]][3, 1] : !llvm.struct<(ptr, ptr, i32, array<3 x i32>, array<3 x i32>)>
452+
// CHECK32: %[[SIZE2:.*]] = llvm.extractvalue %[[MEM]][3, 2] : !llvm.struct<(ptr, ptr, i32, array<3 x i32>, array<3 x i32>)>
453+
// CHECK32: %[[STRIDE0:.*]] = llvm.extractvalue %[[MEM]][4, 0] : !llvm.struct<(ptr, ptr, i32, array<3 x i32>, array<3 x i32>)>
454+
// CHECK32: %[[FINAL_SIZE1_I32:.*]] = llvm.mul %[[SIZE1]], %[[SIZE2]] overflow<nsw> : i32
455+
// CHECK32: %[[SIZE1_TO_IDX:.*]] = builtin.unrealized_conversion_cast %[[FINAL_SIZE1_I32]] : i32 to index
456+
// CHECK32: %[[FINAL_SIZE1_CAST:.*]] = builtin.unrealized_conversion_cast %[[SIZE1_TO_IDX]] : index to i32
457+
// CHECK32: %[[DESC:.*]] = llvm.mlir.poison : !llvm.struct<(ptr, ptr, i32, array<2 x i32>, array<2 x i32>)>
458+
// CHECK32: %[[DESC0:.*]] = llvm.insertvalue %[[BASE_BUFFER]], %[[DESC]][0] : !llvm.struct<(ptr, ptr, i32, array<2 x i32>, array<2 x i32>)>
459+
// CHECK32: %[[DESC1:.*]] = llvm.insertvalue %[[ALIGNED_BUFFER]], %[[DESC0]][1] : !llvm.struct<(ptr, ptr, i32, array<2 x i32>, array<2 x i32>)>
460+
// CHECK32: %[[DESC2:.*]] = llvm.insertvalue %[[OFFSET]], %[[DESC1]][2] : !llvm.struct<(ptr, ptr, i32, array<2 x i32>, array<2 x i32>)>
461+
// CHECK32: %[[C4_I32:.*]] = llvm.mlir.constant(4 : index) : i32
462+
// CHECK32: %[[DESC3:.*]] = llvm.insertvalue %[[C4_I32]], %[[DESC2]][3, 0] : !llvm.struct<(ptr, ptr, i32, array<2 x i32>, array<2 x i32>)>
463+
// CHECK32: %[[DESC4:.*]] = llvm.insertvalue %[[STRIDE0]], %[[DESC3]][4, 0] : !llvm.struct<(ptr, ptr, i32, array<2 x i32>, array<2 x i32>)>
464+
// CHECK32: %[[DESC5:.*]] = llvm.insertvalue %[[FINAL_SIZE1_CAST]], %[[DESC4]][3, 1] : !llvm.struct<(ptr, ptr, i32, array<2 x i32>, array<2 x i32>)>
465+
// CHECK32: %[[C1_I32:.*]] = llvm.mlir.constant(1 : index) : i32
466+
// CHECK32: %[[DESC6:.*]] = llvm.insertvalue %[[C1_I32]], %[[DESC5]][4, 1] : !llvm.struct<(ptr, ptr, i32, array<2 x i32>, array<2 x i32>)>
467+
// CHECK32: %[[RES:.*]] = builtin.unrealized_conversion_cast %[[DESC6]] : !llvm.struct<(ptr, ptr, i32, array<2 x i32>, array<2 x i32>)> to memref<4x?xf32, strided<[?, ?], offset: ?>>
468+
// CHECK32: return %[[RES]] : memref<4x?xf32, strided<[?, ?], offset: ?>>
469+
// CHECK32: }
448470

449471
// -----
450472

mlir/test/Dialect/Func/duplicate-function-elimination.mlir

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// RUN: mlir-opt %s --split-input-file --duplicate-function-elimination | \
2-
// RUN: FileCheck %s
2+
// RUN: FileCheck %s --check-prefixes=CHECK,CHECK-2,CHECK-3
33

44
func.func @identity(%arg0: tensor<f32>) -> tensor<f32> {
55
return %arg0 : tensor<f32>

mlir/test/Dialect/OpenACC/ops.mlir

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
// RUN: mlir-opt -split-input-file %s | FileCheck %s
1+
// RUN: mlir-opt -split-input-file %s | FileCheck %s --check-prefixes=CHECK,CHECK-3
22
// Verify the printed output can be parsed.
3-
// RUN: mlir-opt -split-input-file %s | mlir-opt -split-input-file | FileCheck %s
3+
// RUN: mlir-opt -split-input-file %s | mlir-opt -split-input-file | FileCheck %s --check-prefixes=CHECK,CHECK-3
44
// Verify the generic form can be parsed.
5-
// RUN: mlir-opt -split-input-file -mlir-print-op-generic %s | mlir-opt -split-input-file | FileCheck %s
5+
// RUN: mlir-opt -split-input-file -mlir-print-op-generic %s | mlir-opt -split-input-file | FileCheck %s --check-prefixes=CHECK,CHECK-3
66

77
func.func @compute1(%A: memref<10x10xf32>, %B: memref<10x10xf32>, %C: memref<10x10xf32>) -> memref<10x10xf32> {
88
%c0 = arith.constant 0 : index

mlir/test/mlir-tblgen/op-decl-and-defs.td

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ def NS_AOp : NS_Op<"a_op", [IsolatedFromAbove, IsolatedFromAbove]> {
6565
// CHECK: ::std::optional< ::llvm::APFloat > getSomeAttr2();
6666
// CHECK: ::mlir::Region &getSomeRegion() {
6767
// CHECK: ::mlir::RegionRange getSomeRegions() {
68+
// CHECK-NEXT: return odsRegions.drop_front(1);
69+
// CHECK: ::mlir::RegionRange getRegions() {
70+
// CHECK-NEXT: return odsRegions;
6871
// CHECK: };
6972
// CHECK: }
7073

@@ -152,10 +155,6 @@ def NS_AOp : NS_Op<"a_op", [IsolatedFromAbove, IsolatedFromAbove]> {
152155

153156
// Check that `getAttrDictionary()` is used when not using properties.
154157

155-
// DECLS: ::mlir::RegionRange AOpGenericAdaptorBase::getSomeRegions()
156-
// DECLS-NEXT: return odsRegions.drop_front(1);
157-
// DECLS: ::mlir::RegionRange AOpGenericAdaptorBase::getRegions()
158-
159158
// Check AttrSizedOperandSegments
160159
// ---
161160

0 commit comments

Comments
 (0)