Skip to content

Commit b8b403b

Browse files
[fir][test] Update box.fir tests
Adds checks for allocas used for temp storage between a fir.ref<fir.box> and a fir.box.
1 parent 58bc994 commit b8b403b

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

flang/test/Fir/box.fir

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,14 @@ func.func @fa(%a : !fir.ref<!fir.array<100xf32>>) {
5656
// CHECK-LABEL: define void @b1(
5757
// CHECK-SAME: ptr %[[res:.*]], ptr %[[arg0:.*]], i64 %[[arg1:.*]])
5858
func.func @b1(%arg0 : !fir.ref<!fir.char<1,?>>, %arg1 : index) -> !fir.box<!fir.char<1,?>> {
59+
// CHECK: %[[alloca:.*]] = alloca { ptr, i64, i32, i8, i8, i8, i8 }
5960
// CHECK: %[[size:.*]] = mul i64 ptrtoint (ptr getelementptr (i8, ptr null, i32 1) to i64), %[[arg1]]
6061
// CHECK: insertvalue {{.*}} undef, i64 %[[size]], 1
6162
// CHECK: insertvalue {{.*}} i32 20240719, 2
6263
// CHECK: insertvalue {{.*}} ptr %[[arg0]], 0
6364
%x = fir.embox %arg0 typeparams %arg1 : (!fir.ref<!fir.char<1,?>>, index) -> !fir.box<!fir.char<1,?>>
64-
// CHECK: store {{.*}}, ptr %[[res]]
65+
// CHECK: store {{.*}}, ptr %[[alloca]]
66+
// CHECK: call void @llvm.memcpy.p0.p0.i32(ptr %[[res]], ptr %[[alloca]], i32 24, i1 false)
6567
return %x : !fir.box<!fir.char<1,?>>
6668
}
6769

@@ -71,11 +73,13 @@ func.func @b1(%arg0 : !fir.ref<!fir.char<1,?>>, %arg1 : index) -> !fir.box<!fir.
7173
// CHECK-SAME: ptr %[[arg0:.*]], i64 %[[arg1:.*]])
7274
func.func @b2(%arg0 : !fir.ref<!fir.array<?x!fir.char<1,5>>>, %arg1 : index) -> !fir.box<!fir.array<?x!fir.char<1,5>>> {
7375
%1 = fir.shape %arg1 : (index) -> !fir.shape<1>
76+
// CHECK: %[[alloca:.*]] = alloca { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }
7477
// CHECK: insertvalue {{.*}} { ptr undef, i64 ptrtoint (ptr getelementptr ([5 x i8], ptr null, i32 1) to i64), i32 20240719, i8 1, i8 40, i8 0, i8 0, {{.*}} }, i64 %[[arg1]], 7, 0, 1
7578
// CHECK: insertvalue {{.*}} %{{.*}}, i64 ptrtoint (ptr getelementptr ([5 x i8], ptr null, i32 1) to i64), 7, 0, 2
7679
// CHECK: insertvalue {{.*}} ptr %[[arg0]], 0
7780
%2 = fir.embox %arg0(%1) : (!fir.ref<!fir.array<?x!fir.char<1,5>>>, !fir.shape<1>) -> !fir.box<!fir.array<?x!fir.char<1,5>>>
78-
// CHECK: store {{.*}}, ptr %[[res]]
81+
// CHECK: store {{.*}}, ptr %[[alloca]]
82+
// CHECK: call void @llvm.memcpy.p0.p0.i32(ptr %[[res]], ptr %[[alloca]], i32 48, i1 false)
7983
return %2 : !fir.box<!fir.array<?x!fir.char<1,5>>>
8084
}
8185

@@ -84,14 +88,16 @@ func.func @b2(%arg0 : !fir.ref<!fir.array<?x!fir.char<1,5>>>, %arg1 : index) ->
8488
// CHECK-SAME: ptr %[[res:.*]], ptr %[[arg0:.*]], i64 %[[arg1:.*]], i64 %[[arg2:.*]])
8589
func.func @b3(%arg0 : !fir.ref<!fir.array<?x!fir.char<1,?>>>, %arg1 : index, %arg2 : index) -> !fir.box<!fir.array<?x!fir.char<1,?>>> {
8690
%1 = fir.shape %arg2 : (index) -> !fir.shape<1>
91+
// CHECK: %[[alloca:.*]] = alloca { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }
8792
// CHECK: %[[size:.*]] = mul i64 ptrtoint (ptr getelementptr (i8, ptr null, i32 1) to i64), %[[arg1]]
8893
// CHECK: insertvalue {{.*}} i64 %[[size]], 1
8994
// CHECK: insertvalue {{.*}} i32 20240719, 2
9095
// CHECK: insertvalue {{.*}} i64 %[[arg2]], 7, 0, 1
9196
// CHECK: insertvalue {{.*}} i64 %[[size]], 7, 0, 2
9297
// CHECK: insertvalue {{.*}} ptr %[[arg0]], 0
9398
%2 = fir.embox %arg0(%1) typeparams %arg1 : (!fir.ref<!fir.array<?x!fir.char<1,?>>>, !fir.shape<1>, index) -> !fir.box<!fir.array<?x!fir.char<1,?>>>
94-
// CHECK: store {{.*}}, ptr %[[res]]
99+
// CHECK: store {{.*}}, ptr %[[alloca]]
100+
// CHECK: call void @llvm.memcpy.p0.p0.i32(ptr %[[res]], ptr %[[alloca]], i32 48, i1 false)
95101
return %2 : !fir.box<!fir.array<?x!fir.char<1,?>>>
96102
}
97103

@@ -101,14 +107,16 @@ func.func @b3(%arg0 : !fir.ref<!fir.array<?x!fir.char<1,?>>>, %arg1 : index, %ar
101107
func.func @b4(%arg0 : !fir.ref<!fir.array<7x!fir.char<1,?>>>, %arg1 : index) -> !fir.box<!fir.array<7x!fir.char<1,?>>> {
102108
%c_7 = arith.constant 7 : index
103109
%1 = fir.shape %c_7 : (index) -> !fir.shape<1>
110+
// CHECK: %[[alloca:.*]] = alloca { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }
104111
// CHECK: %[[size:.*]] = mul i64 ptrtoint (ptr getelementptr (i8, ptr null, i32 1) to i64), %[[arg1]]
105112
// CHECK: insertvalue {{.*}} i64 %[[size]], 1
106113
// CHECK: insertvalue {{.*}} i32 20240719, 2
107114
// CHECK: insertvalue {{.*}} i64 7, 7, 0, 1
108115
// CHECK: insertvalue {{.*}} i64 %[[size]], 7, 0, 2
109116
// CHECK: insertvalue {{.*}} ptr %[[arg0]], 0
110117
%x = fir.embox %arg0(%1) typeparams %arg1 : (!fir.ref<!fir.array<7x!fir.char<1,?>>>, !fir.shape<1>, index) -> !fir.box<!fir.array<7x!fir.char<1,?>>>
111-
// CHECK: store {{.*}}, ptr %[[res]]
118+
// CHECK: store {{.*}}, ptr %[[alloca]]
119+
// CHECK: call void @llvm.memcpy.p0.p0.i32(ptr %[[res]], ptr %[[alloca]], i32 48, i1 false)
112120
return %x : !fir.box<!fir.array<7x!fir.char<1,?>>>
113121
}
114122

@@ -117,8 +125,7 @@ func.func @b4(%arg0 : !fir.ref<!fir.array<7x!fir.char<1,?>>>, %arg1 : index) ->
117125
// CHECK-SAME: ptr %[[arg0:.*]], ptr %[[arg1:.*]])
118126
func.func @b5(%arg0 : !fir.ref<!fir.box<!fir.heap<!fir.array<?x?xf32>>>>, %arg1 : !fir.box<!fir.heap<!fir.array<?x?xf32>>>) {
119127
fir.store %arg1 to %arg0 : !fir.ref<!fir.box<!fir.heap<!fir.array<?x?xf32>>>>
120-
// CHECK: %[[boxLoad:.*]] = load { ptr, i64, i32, i8, i8, i8, i8, [2 x [3 x i64]] }, ptr %[[arg1]]
121-
// CHECK: store { ptr, i64, i32, i8, i8, i8, i8, [2 x [3 x i64]] } %[[boxLoad]], ptr %[[arg0]]
128+
// CHECK: call void @llvm.memcpy.p0.p0.i32(ptr %0, ptr %1, i32 72, i1 false)
122129
return
123130
}
124131

0 commit comments

Comments
 (0)