[flang] Update tests for opaque pointers

There is still one remaining failure in Lower/forall/character-1.f90.
This commit is contained in:
Nikita Popov 2022-06-02 11:53:00 +02:00
parent 9245c4930f
commit e3bfd7e52d
11 changed files with 160 additions and 165 deletions

View File

@ -3,9 +3,9 @@
// CHECK: @var_x = external global i32
fir.global @var_x : !fir.int<4> {}
// CHECK-LABEL: define i32* @getAddressOfX
// CHECK-LABEL: define ptr @getAddressOfX
func.func @getAddressOfX() -> !fir.ref<!fir.int<4>> {
%1 = fir.address_of(@var_x) : !fir.ref<!fir.int<4>>
// CHECK: ret i32* @var_x
// CHECK: ret ptr @var_x
return %1 : !fir.ref<!fir.int<4>>
}

View File

@ -2,14 +2,14 @@
// UNSUPPORTED: system-windows
// CHECK-LABEL: define i32* @alloca_scalar_nonchar()
// CHECK-LABEL: define ptr @alloca_scalar_nonchar()
// CHECK: alloca i32, i64 1
func.func @alloca_scalar_nonchar() -> !fir.ref<i32> {
%1 = fir.alloca i32
return %1 : !fir.ref<i32>
}
// CHECK-LABEL: define i32* @alloca_scalars_nonchar()
// CHECK-LABEL: define ptr @alloca_scalars_nonchar()
// CHECK: alloca i32, i64 100
func.func @alloca_scalars_nonchar() -> !fir.ref<i32> {
%0 = arith.constant 100 : index
@ -17,50 +17,50 @@ func.func @alloca_scalars_nonchar() -> !fir.ref<i32> {
return %1 : !fir.ref<i32>
}
// CHECK-LABEL: define i32* @allocmem_scalar_nonchar(
// CHECK: call i8* @malloc(i64 4)
// CHECK-LABEL: define ptr @allocmem_scalar_nonchar(
// CHECK: call ptr @malloc(i64 4)
func.func @allocmem_scalar_nonchar() -> !fir.heap<i32> {
%1 = fir.allocmem i32
return %1 : !fir.heap<i32>
}
// CHECK-LABEL: define i32* @allocmem_scalars_nonchar(
// CHECK: call i8* @malloc(i64 400)
// CHECK-LABEL: define ptr @allocmem_scalars_nonchar(
// CHECK: call ptr @malloc(i64 400)
func.func @allocmem_scalars_nonchar() -> !fir.heap<i32> {
%0 = arith.constant 100 : index
%1 = fir.allocmem i32, %0
return %1 : !fir.heap<i32>
}
// CHECK-LABEL: define [10 x i8]* @alloca_scalar_char(
// CHECK-LABEL: define ptr @alloca_scalar_char(
// CHECK: alloca [10 x i8], i64 1
func.func @alloca_scalar_char() -> !fir.ref<!fir.char<1,10>> {
%1 = fir.alloca !fir.char<1,10>
return %1 : !fir.ref<!fir.char<1,10>>
}
// CHECK-LABEL: define [10 x i16]* @alloca_scalar_char_kind(
// CHECK-LABEL: define ptr @alloca_scalar_char_kind(
// CHECK: alloca [10 x i16], i64 1
func.func @alloca_scalar_char_kind() -> !fir.ref<!fir.char<2,10>> {
%1 = fir.alloca !fir.char<2,10>
return %1 : !fir.ref<!fir.char<2,10>>
}
// CHECK-LABEL: define [10 x i8]* @allocmem_scalar_char(
// CHECK: call i8* @malloc(i64 ptrtoint ([10 x i8]* getelementptr ([10 x i8], [10 x i8]* null, i64 1) to i64))
// CHECK-LABEL: define ptr @allocmem_scalar_char(
// CHECK: call ptr @malloc(i64 ptrtoint (ptr getelementptr ([10 x i8], ptr null, i64 1) to i64))
func.func @allocmem_scalar_char() -> !fir.heap<!fir.char<1,10>> {
%1 = fir.allocmem !fir.char<1,10>
return %1 : !fir.heap<!fir.char<1,10>>
}
// CHECK-LABEL: define [10 x i16]* @allocmem_scalar_char_kind(
// CHECK: call i8* @malloc(i64 ptrtoint ([10 x i16]* getelementptr ([10 x i16], [10 x i16]* null, i64 1) to i64))
// CHECK-LABEL: define ptr @allocmem_scalar_char_kind(
// CHECK: call ptr @malloc(i64 ptrtoint (ptr getelementptr ([10 x i16], ptr null, i64 1) to i64))
func.func @allocmem_scalar_char_kind() -> !fir.heap<!fir.char<2,10>> {
%1 = fir.allocmem !fir.char<2,10>
return %1 : !fir.heap<!fir.char<2,10>>
}
// CHECK-LABEL: define i8* @alloca_scalar_dynchar(
// CHECK-LABEL: define ptr @alloca_scalar_dynchar(
// CHECK-SAME: i32 %[[len:.*]])
// CHECK: %[[mul1:.*]] = sext i32 %[[len]] to i64
// CHECK: alloca i8, i64 %[[mul1]]
@ -69,7 +69,7 @@ func.func @alloca_scalar_dynchar(%l : i32) -> !fir.ref<!fir.char<1,?>> {
return %1 : !fir.ref<!fir.char<1,?>>
}
// CHECK-LABEL: define i16* @alloca_scalar_dynchar_kind(
// CHECK-LABEL: define ptr @alloca_scalar_dynchar_kind(
// CHECK-SAME: i32 %[[len:.*]])
// CHECK: %[[mul1:.*]] = sext i32 %[[len]] to i64
// CHECK: alloca i16, i64 %[[mul1]]
@ -78,48 +78,48 @@ func.func @alloca_scalar_dynchar_kind(%l : i32) -> !fir.ref<!fir.char<2,?>> {
return %1 : !fir.ref<!fir.char<2,?>>
}
// CHECK-LABEL: define i8* @allocmem_scalar_dynchar(
// CHECK-LABEL: define ptr @allocmem_scalar_dynchar(
// CHECK-SAME: i32 %[[len:.*]])
// CHECK: %[[mul1:.*]] = sext i32 %[[len]] to i64
// CHECK: %[[mul2:.*]] = mul i64 1, %[[mul1]]
// CHECK: call i8* @malloc(i64 %[[mul2]])
// CHECK: call ptr @malloc(i64 %[[mul2]])
func.func @allocmem_scalar_dynchar(%l : i32) -> !fir.heap<!fir.char<1,?>> {
%1 = fir.allocmem !fir.char<1,?>(%l : i32)
return %1 : !fir.heap<!fir.char<1,?>>
}
// CHECK-LABEL: define i16* @allocmem_scalar_dynchar_kind(
// CHECK-LABEL: define ptr @allocmem_scalar_dynchar_kind(
// CHECK-SAME: i32 %[[len:.*]])
// CHECK: %[[mul1:.*]] = sext i32 %[[len]] to i64
// CHECK: %[[mul2:.*]] = mul i64 2, %[[mul1]]
// CHECK: call i8* @malloc(i64 %[[mul2]])
// CHECK: call ptr @malloc(i64 %[[mul2]])
func.func @allocmem_scalar_dynchar_kind(%l : i32) -> !fir.heap<!fir.char<2,?>>{
%1 = fir.allocmem !fir.char<2,?>(%l : i32)
return %1 : !fir.heap<!fir.char<2,?>>
}
// CHECK-LABEL: define i32** @alloca_ptr_to_dynarray_nonchar(
// CHECK: %1 = alloca i32*, i64 1
// CHECK-LABEL: define ptr @alloca_ptr_to_dynarray_nonchar(
// CHECK: %1 = alloca ptr, i64 1
func.func @alloca_ptr_to_dynarray_nonchar() -> !fir.ref<!fir.ptr<!fir.array<?xi32>>> {
%1 = fir.alloca !fir.ptr<!fir.array<?xi32>>
return %1 : !fir.ref<!fir.ptr<!fir.array<?xi32>>>
}
// CHECK-LABEL: define [3 x [3 x i32]]* @alloca_array_of_nonchar(
// CHECK-LABEL: define ptr @alloca_array_of_nonchar(
// CHECK: alloca [3 x [3 x i32]], i64 1
func.func @alloca_array_of_nonchar() -> !fir.ref<!fir.array<3x3xi32>> {
%1 = fir.alloca !fir.array<3x3xi32>
return %1 : !fir.ref<!fir.array<3x3xi32>>
}
// CHECK-LABEL: define [3 x [3 x [10 x i8]]]* @alloca_array_of_char(
// CHECK-LABEL: define ptr @alloca_array_of_char(
// CHECK: alloca [3 x [3 x [10 x i8]]], i64 1
func.func @alloca_array_of_char() -> !fir.ref<!fir.array<3x3x!fir.char<1,10>>> {
%1 = fir.alloca !fir.array<3x3x!fir.char<1,10>>
return %1 : !fir.ref<!fir.array<3x3x!fir.char<1,10>>>
}
// CHECK-LABEL: define i8* @alloca_array_of_dynchar(
// CHECK-LABEL: define ptr @alloca_array_of_dynchar(
// CHECK-SAME: i32 %[[len:.*]])
// CHECK: %[[mul1:.*]] = sext i32 %[[len]] to i64
// CHECK: %[[mul2:.*]] = mul i64 %[[mul1]], 9
@ -129,31 +129,31 @@ func.func @alloca_array_of_dynchar(%l: i32) -> !fir.ref<!fir.array<3x3x!fir.char
return %1 : !fir.ref<!fir.array<3x3x!fir.char<1,?>>>
}
// CHECK-LABEL: define [3 x [3 x i32]]* @allocmem_array_of_nonchar(
// CHECK: call i8* @malloc(i64 ptrtoint ([3 x [3 x i32]]* getelementptr ([3 x [3 x i32]], [3 x [3 x i32]]* null, i64 1) to i64))
// CHECK-LABEL: define ptr @allocmem_array_of_nonchar(
// CHECK: call ptr @malloc(i64 ptrtoint (ptr getelementptr ([3 x [3 x i32]], ptr null, i64 1) to i64))
func.func @allocmem_array_of_nonchar() -> !fir.heap<!fir.array<3x3xi32>> {
%1 = fir.allocmem !fir.array<3x3xi32>
return %1 : !fir.heap<!fir.array<3x3xi32>>
}
// CHECK-LABEL: define [3 x [3 x [10 x i8]]]* @allocmem_array_of_char(
// CHECK: call i8* @malloc(i64 ptrtoint ([3 x [3 x [10 x i8]]]* getelementptr ([3 x [3 x [10 x i8]]], [3 x [3 x [10 x i8]]]* null, i64 1) to i64))
// CHECK-LABEL: define ptr @allocmem_array_of_char(
// CHECK: call ptr @malloc(i64 ptrtoint (ptr getelementptr ([3 x [3 x [10 x i8]]], ptr null, i64 1) to i64))
func.func @allocmem_array_of_char() -> !fir.heap<!fir.array<3x3x!fir.char<1,10>>> {
%1 = fir.allocmem !fir.array<3x3x!fir.char<1,10>>
return %1 : !fir.heap<!fir.array<3x3x!fir.char<1,10>>>
}
// CHECK-LABEL: define i8* @allocmem_array_of_dynchar(
// CHECK-LABEL: define ptr @allocmem_array_of_dynchar(
// CHECK-SAME: i32 %[[len:.*]])
// CHECK: %[[mul1:.*]] = sext i32 %[[len]] to i64
// CHECK: %[[mul2:.*]] = mul i64 9, %[[mul1]]
// CHECK: call i8* @malloc(i64 %[[mul2]])
// CHECK: call ptr @malloc(i64 %[[mul2]])
func.func @allocmem_array_of_dynchar(%l: i32) -> !fir.heap<!fir.array<3x3x!fir.char<1,?>>> {
%1 = fir.allocmem !fir.array<3x3x!fir.char<1,?>>(%l : i32)
return %1 : !fir.heap<!fir.array<3x3x!fir.char<1,?>>>
}
// CHECK-LABEL: define [3 x i32]* @alloca_dynarray_of_nonchar(
// CHECK-LABEL: define ptr @alloca_dynarray_of_nonchar(
// CHECK-SAME: i64 %[[extent:.*]])
// CHECK: %[[prod1:.*]] = mul i64 1, %[[extent]]
// CHECK: alloca [3 x i32], i64 %[[prod1]]
@ -162,7 +162,7 @@ func.func @alloca_dynarray_of_nonchar(%e: index) -> !fir.ref<!fir.array<3x?xi32>
return %1 : !fir.ref<!fir.array<3x?xi32>>
}
// CHECK-LABEL: define i32* @alloca_dynarray_of_nonchar2(
// CHECK-LABEL: define ptr @alloca_dynarray_of_nonchar2(
// CHECK-SAME: i64 %[[extent:.*]])
// CHECK: %[[prod1:.*]] = mul i64 1, %[[extent]]
// CHECK: %[[prod2:.*]] = mul i64 %[[prod1]], %[[extent]]
@ -172,26 +172,26 @@ func.func @alloca_dynarray_of_nonchar2(%e: index) -> !fir.ref<!fir.array<?x?xi32
return %1 : !fir.ref<!fir.array<?x?xi32>>
}
// CHECK-LABEL: define [3 x i32]* @allocmem_dynarray_of_nonchar(
// CHECK-LABEL: define ptr @allocmem_dynarray_of_nonchar(
// CHECK-SAME: i64 %[[extent:.*]])
// CHECK: %[[prod1:.*]] = mul i64 ptrtoint ([3 x i32]* getelementptr ([3 x i32], [3 x i32]* null, i64 1) to i64), %[[extent]]
// CHECK: call i8* @malloc(i64 %[[prod1]])
// CHECK: %[[prod1:.*]] = mul i64 ptrtoint (ptr getelementptr ([3 x i32], ptr null, i64 1) to i64), %[[extent]]
// CHECK: call ptr @malloc(i64 %[[prod1]])
func.func @allocmem_dynarray_of_nonchar(%e: index) -> !fir.heap<!fir.array<3x?xi32>> {
%1 = fir.allocmem !fir.array<3x?xi32>, %e
return %1 : !fir.heap<!fir.array<3x?xi32>>
}
// CHECK-LABEL: define i32* @allocmem_dynarray_of_nonchar2(
// CHECK-LABEL: define ptr @allocmem_dynarray_of_nonchar2(
// CHECK-SAME: i64 %[[extent:.*]])
// CHECK: %[[prod1:.*]] = mul i64 4, %[[extent]]
// CHECK: %[[prod2:.*]] = mul i64 %[[prod1]], %[[extent]]
// CHECK: call i8* @malloc(i64 %[[prod2]])
// CHECK: call ptr @malloc(i64 %[[prod2]])
func.func @allocmem_dynarray_of_nonchar2(%e: index) -> !fir.heap<!fir.array<?x?xi32>> {
%1 = fir.allocmem !fir.array<?x?xi32>, %e, %e
return %1 : !fir.heap<!fir.array<?x?xi32>>
}
// CHECK-LABEL: define [3 x [10 x i16]]* @alloca_dynarray_of_char(
// CHECK-LABEL: define ptr @alloca_dynarray_of_char(
// CHECK-SAME: i64 %[[extent:.*]])
// CHECK: %[[prod1:.*]] = mul i64 1, %[[extent]]
// CHECK: alloca [3 x [10 x i16]], i64 %[[prod1]]
@ -200,7 +200,7 @@ func.func @alloca_dynarray_of_char(%e : index) -> !fir.ref<!fir.array<3x?x!fir.c
return %1 : !fir.ref<!fir.array<3x?x!fir.char<2,10>>>
}
// CHECK-LABEL: define [10 x i16]* @alloca_dynarray_of_char2(
// CHECK-LABEL: define ptr @alloca_dynarray_of_char2(
// CHECK-SAME: i64 %[[extent:.*]])
// CHECK: %[[prod1:.*]] = mul i64 1, %[[extent]]
// CHECK: %[[prod2:.*]] = mul i64 %[[prod1]], %[[extent]]
@ -210,26 +210,26 @@ func.func @alloca_dynarray_of_char2(%e : index) -> !fir.ref<!fir.array<?x?x!fir.
return %1 : !fir.ref<!fir.array<?x?x!fir.char<2,10>>>
}
// CHECK-LABEL: define [3 x [10 x i16]]* @allocmem_dynarray_of_char(
// CHECK-LABEL: define ptr @allocmem_dynarray_of_char(
// CHECK-SAME: i64 %[[extent:.*]])
// CHECK: %[[prod1:.*]] = mul i64 ptrtoint ([3 x [10 x i16]]* getelementptr ([3 x [10 x i16]], [3 x [10 x i16]]* null, i64 1) to i64), %[[extent]]
// CHECK: call i8* @malloc(i64 %[[prod1]])
// CHECK: %[[prod1:.*]] = mul i64 ptrtoint (ptr getelementptr ([3 x [10 x i16]], ptr null, i64 1) to i64), %[[extent]]
// CHECK: call ptr @malloc(i64 %[[prod1]])
func.func @allocmem_dynarray_of_char(%e : index) -> !fir.heap<!fir.array<3x?x!fir.char<2,10>>> {
%1 = fir.allocmem !fir.array<3x?x!fir.char<2,10>>, %e
return %1 : !fir.heap<!fir.array<3x?x!fir.char<2,10>>>
}
// CHECK-LABEL: define [10 x i16]* @allocmem_dynarray_of_char2(
// CHECK-LABEL: define ptr @allocmem_dynarray_of_char2(
// CHECK-SAME: i64 %[[extent:.*]])
// CHECK: %[[prod1:.*]] = mul i64 ptrtoint ([10 x i16]* getelementptr ([10 x i16], [10 x i16]* null, i64 1) to i64), %[[extent]]
// CHECK: %[[prod1:.*]] = mul i64 ptrtoint (ptr getelementptr ([10 x i16], ptr null, i64 1) to i64), %[[extent]]
// CHECK: %[[prod2:.*]] = mul i64 %[[prod1]], %[[extent]]
// CHECK: call i8* @malloc(i64 %[[prod2]])
// CHECK: call ptr @malloc(i64 %[[prod2]])
func.func @allocmem_dynarray_of_char2(%e : index) -> !fir.heap<!fir.array<?x?x!fir.char<2,10>>> {
%1 = fir.allocmem !fir.array<?x?x!fir.char<2,10>>, %e, %e
return %1 : !fir.heap<!fir.array<?x?x!fir.char<2,10>>>
}
// CHECK-LABEL: define i16* @alloca_dynarray_of_dynchar(
// CHECK-LABEL: define ptr @alloca_dynarray_of_dynchar(
// CHECK-SAME: i32 %[[len:.*]], i64 %[[extent:.*]])
// CHECK: %[[prod1:.*]] = sext i32 %[[len]] to i64
// CHECK: %[[prod2:.*]] = mul i64 %[[prod1]], 3
@ -240,7 +240,7 @@ func.func @alloca_dynarray_of_dynchar(%l: i32, %e : index) -> !fir.ref<!fir.arra
return %1 : !fir.ref<!fir.array<3x?x!fir.char<2,?>>>
}
// CHECK-LABEL: define i16* @alloca_dynarray_of_dynchar2(
// CHECK-LABEL: define ptr @alloca_dynarray_of_dynchar2(
// CHECK-SAME: i32 %[[len:.*]], i64 %[[extent:.*]])
// CHECK: %[[prod1:.*]] = sext i32 %[[len]] to i64
// CHECK: %[[prod2:.*]] = mul i64 %[[prod1]], %[[extent]]
@ -251,30 +251,30 @@ func.func @alloca_dynarray_of_dynchar2(%l: i32, %e : index) -> !fir.ref<!fir.arr
return %1 : !fir.ref<!fir.array<?x?x!fir.char<2,?>>>
}
// CHECK-LABEL: define i16* @allocmem_dynarray_of_dynchar(
// CHECK-LABEL: define ptr @allocmem_dynarray_of_dynchar(
// CHECK-SAME: i32 %[[len:.*]], i64 %[[extent:.*]])
// CHECK: %[[prod1:.*]] = sext i32 %[[len]] to i64
// CHECK: %[[prod2:.*]] = mul i64 6, %[[prod1]]
// CHECK: %[[prod3:.*]] = mul i64 %[[prod2]], %[[extent]]
// CHECK: call i8* @malloc(i64 %[[prod3]])
// CHECK: call ptr @malloc(i64 %[[prod3]])
func.func @allocmem_dynarray_of_dynchar(%l: i32, %e : index) -> !fir.heap<!fir.array<3x?x!fir.char<2,?>>> {
%1 = fir.allocmem !fir.array<3x?x!fir.char<2,?>>(%l : i32), %e
return %1 : !fir.heap<!fir.array<3x?x!fir.char<2,?>>>
}
// CHECK-LABEL: define i16* @allocmem_dynarray_of_dynchar2(
// CHECK-LABEL: define ptr @allocmem_dynarray_of_dynchar2(
// CHECK-SAME: i32 %[[len:.*]], i64 %[[extent:.*]])
// CHECK: %[[a:.*]] = sext i32 %[[len]] to i64
// CHECK: %[[prod1:.*]] = mul i64 2, %[[a]]
// CHECK: %[[prod2:.*]] = mul i64 %[[prod1]], %[[extent]]
// CHECK: %[[prod3:.*]] = mul i64 %[[prod2]], %[[extent]]
// CHECK: call i8* @malloc(i64 %[[prod3]])
// CHECK: call ptr @malloc(i64 %[[prod3]])
func.func @allocmem_dynarray_of_dynchar2(%l: i32, %e : index) -> !fir.heap<!fir.array<?x?x!fir.char<2,?>>> {
%1 = fir.allocmem !fir.array<?x?x!fir.char<2,?>>(%l : i32), %e, %e
return %1 : !fir.heap<!fir.array<?x?x!fir.char<2,?>>>
}
// CHECK-LABEL: define i32* @alloca_array_with_holes_nonchar(
// CHECK-LABEL: define ptr @alloca_array_with_holes_nonchar(
// CHECK-SAME: i64 %[[a:.*]], i64 %[[b:.*]])
// CHECK: %[[prod1:.*]] = mul i64 60, %[[a]]
// CHECK: %[[prod2:.*]] = mul i64 %[[prod1]], %[[b]]
@ -284,7 +284,7 @@ func.func @alloca_array_with_holes_nonchar(%0 : index, %1 : index) -> !fir.ref<!
return %a : !fir.ref<!fir.array<4x?x3x?x5xi32>>
}
// CHECK-LABEL: define [10 x i16]* @alloca_array_with_holes_char(
// CHECK-LABEL: define ptr @alloca_array_with_holes_char(
// CHECK-SAME: i64 %[[e:.*]])
// CHECK: %[[mul:.*]] = mul i64 12, %[[e]]
// CHECK: alloca [10 x i16], i64 %[[mul]]
@ -293,7 +293,7 @@ func.func @alloca_array_with_holes_char(%e: index) -> !fir.ref<!fir.array<3x?x4x
return %1 : !fir.ref<!fir.array<3x?x4x!fir.char<2,10>>>
}
// CHECK-LABEL: define i16* @alloca_array_with_holes_dynchar(
// CHECK-LABEL: define ptr @alloca_array_with_holes_dynchar(
// CHECK-SAME: i64 %[[len:.*]], i64 %[[extent:.*]])
// CHECK: %[[a:.*]] = mul i64 %[[len]], 12
// CHECK: %[[b:.*]] = mul i64 %[[a]], %[[extent]]
@ -303,30 +303,30 @@ func.func @alloca_array_with_holes_dynchar(%arg0: index, %arg1: index) -> !fir.r
return %1 : !fir.ref<!fir.array<3x?x4x!fir.char<2,?>>>
}
// CHECK-LABEL: define i32* @allocmem_array_with_holes_nonchar(
// CHECK-LABEL: define ptr @allocmem_array_with_holes_nonchar(
// CHECK-SAME: i64 %[[e1:.*]], i64 %[[e2:.*]])
// CHECK: %[[a:.*]] = mul i64 240, %[[e1]]
// CHECK: %[[b:.*]] = mul i64 %3, %[[e2]]
// CHECK: call i8* @malloc(i64 %[[b]])
// CHECK: call ptr @malloc(i64 %[[b]])
func.func @allocmem_array_with_holes_nonchar(%0 : index, %1 : index) -> !fir.heap<!fir.array<4x?x3x?x5xi32>> {
%a = fir.allocmem !fir.array<4x?x3x?x5xi32>, %0, %1
return %a : !fir.heap<!fir.array<4x?x3x?x5xi32>>
}
// CHECK-LABEL: define [10 x i16]* @allocmem_array_with_holes_char(
// CHECK-LABEL: define ptr @allocmem_array_with_holes_char(
// CHECK-SAME: i64 %[[e:.*]])
// CHECK: %[[mul:.*]] = mul i64 mul (i64 ptrtoint ([10 x i16]* getelementptr ([10 x i16], [10 x i16]* null, i64 1) to i64), i64 12), %[[e]]
// CHECK: call i8* @malloc(i64 %[[mul]])
// CHECK: %[[mul:.*]] = mul i64 mul (i64 ptrtoint (ptr getelementptr ([10 x i16], ptr null, i64 1) to i64), i64 12), %[[e]]
// CHECK: call ptr @malloc(i64 %[[mul]])
func.func @allocmem_array_with_holes_char(%e: index) -> !fir.heap<!fir.array<3x?x4x!fir.char<2,10>>> {
%1 = fir.allocmem !fir.array<3x?x4x!fir.char<2,10>>, %e
return %1 : !fir.heap<!fir.array<3x?x4x!fir.char<2,10>>>
}
// CHECK-LABEL: define i16* @allocmem_array_with_holes_dynchar(
// CHECK-LABEL: define ptr @allocmem_array_with_holes_dynchar(
// CHECK-SAME: i64 %[[len:.*]], i64 %[[extent:.*]])
// CHECK: %[[a:.*]] = mul i64 24, %[[len]]
// CHECK: %[[b:.*]] = mul i64 %[[a]], %[[extent]]
// CHECK: call i8* @malloc(i64 %[[b]])
// CHECK: call ptr @malloc(i64 %[[b]])
func.func @allocmem_array_with_holes_dynchar(%arg0: index, %arg1: index) -> !fir.heap<!fir.array<3x?x4x!fir.char<2,?>>> {
%1 = fir.allocmem !fir.array<3x?x4x!fir.char<2,?>>(%arg0 : index), %arg1
return %1 : !fir.heap<!fir.array<3x?x4x!fir.char<2,?>>>

View File

@ -1,6 +1,6 @@
// RUN: tco %s | FileCheck %s
// CHECK-LABEL: define void @x([10 x float]* %0)
// CHECK-LABEL: define void @x(ptr %0)
func.func @x(%arr : !fir.ref<!fir.array<10xf32>>) {
%1 = arith.constant 0 : index
%2 = arith.constant 9 : index
@ -9,11 +9,11 @@ func.func @x(%arr : !fir.ref<!fir.array<10xf32>>) {
%a = fir.alloca !fir.array<10xf32>
fir.do_loop %iv = %1 to %2 step %stepvar unordered {
%3 = fir.coordinate_of %arr, %iv : (!fir.ref<!fir.array<10xf32>>, index) -> !fir.ref<f32>
// CHECK: %[[reg10:.*]] = load float, float*
// CHECK: %[[reg10:.*]] = load float, ptr
%4 = fir.load %3 : !fir.ref<f32>
// CHECK: %[[reg11:.*]] = getelementptr [10 x float], [10 x float]*
// CHECK: %[[reg11:.*]] = getelementptr [10 x float], ptr
%5 = fir.coordinate_of %a, %iv : (!fir.ref<!fir.array<10xf32>>, index) -> !fir.ref<f32>
// CHECK: store float %[[reg10]], float* %[[reg11]]
// CHECK: store float %[[reg10]], ptr %[[reg11]]
fir.store %4 to %5 : !fir.ref<f32>
}
%6 = fir.embox %a : (!fir.ref<!fir.array<10xf32>>) -> !fir.box<!fir.array<10xf32>>

View File

@ -10,7 +10,7 @@ func.func @get_name() {
%2 = arith.constant 9 : i64
%3 = fir.convert %1 : (!fir.ref<!fir.char<1,9>>) -> !fir.ref<!fir.char<1,?>>
%4 = fir.emboxchar %3, %2 : (!fir.ref<!fir.char<1,?>>, i64) -> !fir.boxchar<1>
// CHECK: call void @callee(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @name, i32 0, i32 0), i64 9)
// CHECK: call void @callee(ptr @name, i64 9)
fir.call @callee(%4) : (!fir.boxchar<1>) -> ()
return
}

View File

@ -1,21 +1,21 @@
// RUN: tco %s | FileCheck %s
// CHECK-LABEL: define void @_QPtest_callee({ i32*, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }* %0)
// CHECK-LABEL: define void @_QPtest_callee(ptr %0)
func.func @_QPtest_callee(%arg0: !fir.box<!fir.array<?xi32>>) {
return
}
// CHECK-LABEL: define void @_QPtest_slice()
func.func @_QPtest_slice() {
// CHECK: %[[a1:.*]] = alloca { i32*, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, align 8,
// CHECK: %[[a1:.*]] = alloca { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, align 8,
// CHECK: %[[a2:.*]] = alloca [20 x i32], i64 1, align 4,
// CHECK: %[[a3:.*]] = getelementptr [20 x i32], [20 x i32]* %[[a2]], i64 0, i64 0,
// CHECK: %[[a4:.*]] = insertvalue { i32*, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }
// CHECK: { i32* undef, i64 4, i32 20180515, i8 1, i8 9, i8 0, i8 0, [1 x [3 x i64]]
// CHECK: [i64 1, i64 5, i64 8]] }, i32* %[[a3]], 0,
// CHECK: store { i32*, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] } %[[a4]], { i32*, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }* %[[a1]], align 8
// CHECK: call void @_QPtest_callee({ i32*, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }* %[[a1]]),
// CHECK: %[[a3:.*]] = getelementptr [20 x i32], ptr %[[a2]], i64 0, i64 0,
// CHECK: %[[a4:.*]] = insertvalue { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }
// CHECK: { ptr undef, i64 4, i32 20180515, i8 1, i8 9, i8 0, i8 0, [1 x [3 x i64]]
// CHECK: [i64 1, i64 5, i64 8]] }, ptr %[[a3]], 0,
// CHECK: store { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] } %[[a4]], ptr %[[a1]], align 8
// CHECK: call void @_QPtest_callee(ptr %[[a1]]),
%c20 = arith.constant 20 : index
%c1_i64 = arith.constant 1 : i64
%c10_i64 = arith.constant 10 : i64
@ -28,24 +28,24 @@ func.func @_QPtest_slice() {
return
}
// CHECK-LABEL: define void @_QPtest_dt_callee({ i32*, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }* %0)
// CHECK-LABEL: define void @_QPtest_dt_callee(ptr %0)
func.func @_QPtest_dt_callee(%arg0: !fir.box<!fir.array<?xi32>>) {
return
}
// CHECK-LABEL: define void @_QPtest_dt_slice()
func.func @_QPtest_dt_slice() {
// CHECK: %[[a1:.*]] = alloca { i32*, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, align 8,
// CHECK: %[[a1:.*]] = alloca { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, align 8,
// CHECK: %[[a3:.*]] = alloca [20 x %_QFtest_dt_sliceTt], i64 1, align 8,
// CHECK: %[[a4:.*]] = getelementptr [20 x %_QFtest_dt_sliceTt], [20 x %_QFtest_dt_sliceTt]* %[[a3]], i64 0, i64 0, i32 0,
// CHECK: %[[a5:.*]] = insertvalue { i32*, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }
// CHECK-SAME: { i32* undef, i64 4, i32 20180515, i8 1, i8 9, i8 0, i8 0, [1 x [3 x i64]]
// CHECK: %[[a4:.*]] = getelementptr [20 x %_QFtest_dt_sliceTt], ptr %[[a3]], i64 0, i64 0, i32 0,
// CHECK: %[[a5:.*]] = insertvalue { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }
// CHECK-SAME: { ptr undef, i64 4, i32 20180515, i8 1, i8 9, i8 0, i8 0, [1 x [3 x i64]]
// CHECK-SAME: [i64 1, i64 5, i64 mul
// CHECK-SAME: (i64 ptrtoint (%_QFtest_dt_sliceTt* getelementptr (%_QFtest_dt_sliceTt, %_QFtest_dt_sliceTt* null, i64 1) to i64), i64 2)]] }
// CHECK-SAME: , i32* %[[a4]], 0
// CHECK-SAME: (i64 ptrtoint (ptr getelementptr (%_QFtest_dt_sliceTt, ptr null, i64 1) to i64), i64 2)]] }
// CHECK-SAME: , ptr %[[a4]], 0
// CHECK: store { i32*, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] } %[[a5]], { i32*, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }* %[[a1]], align 8,
// CHECK: call void @_QPtest_dt_callee({ i32*, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }* %[[a1]]),
// CHECK: store { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] } %[[a5]], ptr %[[a1]], align 8,
// CHECK: call void @_QPtest_dt_callee(ptr %[[a1]]),
%c20 = arith.constant 20 : index
%c1_i64 = arith.constant 1 : i64
%c10_i64 = arith.constant 10 : i64
@ -62,7 +62,7 @@ func.func @_QPtest_dt_slice() {
func.func private @do_something(!fir.box<!fir.array<?xf32>>) -> ()
// CHECK: define void @fir_dev_issue_1416
// CHECK-SAME: [40 x float]* %[[base_addr:.*]], i64 %[[low:.*]], i64 %[[up:.*]], i64 %[[at:.*]])
// CHECK-SAME: ptr %[[base_addr:.*]], i64 %[[low:.*]], i64 %[[up:.*]], i64 %[[at:.*]])
func.func @fir_dev_issue_1416(%arg0: !fir.ref<!fir.array<40x?xf32>>, %low: index, %up: index, %at : index) {
// Test fir.embox with a constant interior array shape.
%c1 = arith.constant 1 : index
@ -73,9 +73,9 @@ func.func @fir_dev_issue_1416(%arg0: !fir.ref<!fir.array<40x?xf32>>, %low: index
// CHECK: %[[diff:.*]] = sub i64 %[[at]], %[[low]]
// CHECK: %[[mul:.*]] = mul i64 %[[diff]], 1
// CHECK: %[[offset:.*]] = add i64 %[[mul]], 0
// CHECK: %[[addr:.*]] = getelementptr [40 x float], [40 x float]* %0, i64 %[[offset]], i64 0
// CHECK: %[[box:.*]] = insertvalue { float*, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }
// CHECK-SAME: { float* undef, i64 4, i32 20180515, i8 1, i8 27, i8 0, i8 0, [1 x [3 x i64]] [{{.*}} [i64 1, i64 40, i64 4]] }, float* %[[addr]], 0
// CHECK: %[[addr:.*]] = getelementptr [40 x float], ptr %0, i64 %[[offset]], i64 0
// CHECK: %[[box:.*]] = insertvalue { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }
// CHECK-SAME: { ptr undef, i64 4, i32 20180515, i8 1, i8 27, i8 0, i8 0, [1 x [3 x i64]] [{{.*}} [i64 1, i64 40, i64 4]] }, ptr %[[addr]], 0
%3 = fir.embox %arg0(%1) [%2] : (!fir.ref<!fir.array<40x?xf32>>, !fir.shapeshift<2>, !fir.slice<2>) -> !fir.box<!fir.array<?xf32>>
fir.call @do_something(%3) : (!fir.box<!fir.array<?xf32>>) -> ()
return

View File

@ -14,8 +14,8 @@ func.func @test_embox(%addr: !fir.ref<!some_freestyle_type>) {
return
}
// CHECK-LABEL: define void @test_embox(
// CHECK-SAME: %some_not_mangled_type* %[[ADDR:.*]])
// CHECK: insertvalue { %some_not_mangled_type*, i64, i32, i8, i8, i8, i8, i8*, [1 x i64] }
// CHECK-SAME: { %some_not_mangled_type* undef, i64 ptrtoint (%some_not_mangled_type* getelementptr (%some_not_mangled_type, %some_not_mangled_type* null, i32 1) to i64),
// CHECK-SAME: i32 20180515, i8 0, i8 42, i8 0, i8 1, i8* null, [1 x i64] undef },
// CHECK-SAME: %some_not_mangled_type* %[[ADDR]], 0,
// CHECK-SAME: ptr %[[ADDR:.*]])
// CHECK: insertvalue { ptr, i64, i32, i8, i8, i8, i8, ptr, [1 x i64] }
// CHECK-SAME: { ptr undef, i64 ptrtoint (ptr getelementptr (%some_not_mangled_type, ptr null, i32 1) to i64),
// CHECK-SAME: i32 20180515, i8 0, i8 42, i8 0, i8 1, ptr null, [1 x i64] undef },
// CHECK-SAME: ptr %[[ADDR]], 0,

View File

@ -4,7 +4,7 @@
// CHECK-LABEL: @foo1
func.func @foo1(%arg0: !fir.box<!fir.array<?xf32>>) -> i1 {
// CHECK: %[[ptr:.*]] = ptrtoint { float*, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }* %{{.*}} to i64
// CHECK: %[[ptr:.*]] = ptrtoint ptr %{{.*}} to i64
// CHECK: icmp ne i64 %[[ptr]], 0
%0 = fir.is_present %arg0 : (!fir.box<!fir.array<?xf32>>) -> i1
return %0 : i1
@ -13,14 +13,14 @@ func.func @foo1(%arg0: !fir.box<!fir.array<?xf32>>) -> i1 {
// CHECK-LABEL: @bar1
func.func @bar1() -> i1 {
%0 = fir.absent !fir.box<!fir.array<?xf32>>
// CHECK: call i1 @foo1({ float*, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }* null)
// CHECK: call i1 @foo1(ptr null)
%1 = fir.call @foo1(%0) : (!fir.box<!fir.array<?xf32>>) -> i1
return %1 : i1
}
// CHECK-LABEL: @foo2
func.func @foo2(%arg0: !fir.ref<i64>) -> i1 {
// CHECK: %[[ptr:.*]] = ptrtoint i64* %{{.*}} to i64
// CHECK: %[[ptr:.*]] = ptrtoint ptr %{{.*}} to i64
// CHECK: icmp ne i64 %[[ptr]], 0
%0 = fir.is_present %arg0 : (!fir.ref<i64>) -> i1
return %0 : i1
@ -29,15 +29,15 @@ func.func @foo2(%arg0: !fir.ref<i64>) -> i1 {
// CHECK-LABEL: @bar2
func.func @bar2() -> i1 {
%0 = fir.absent !fir.ref<i64>
// CHECK: call i1 @foo2(i64* null)
// CHECK: call i1 @foo2(ptr null)
%1 = fir.call @foo2(%0) : (!fir.ref<i64>) -> i1
return %1 : i1
}
// CHECK-LABEL: @foo3
func.func @foo3(%arg0: !fir.boxchar<1>) -> i1 {
// CHECK: %[[extract:.*]] = extractvalue { i8*, i64 } %{{.*}}, 0
// CHECK: %[[ptr:.*]] = ptrtoint i8* %[[extract]] to i64
// CHECK: %[[extract:.*]] = extractvalue { ptr, i64 } %{{.*}}, 0
// CHECK: %[[ptr:.*]] = ptrtoint ptr %[[extract]] to i64
// CHECK: icmp ne i64 %[[ptr]], 0
%0 = fir.is_present %arg0 : (!fir.boxchar<1>) -> i1
return %0 : i1
@ -46,7 +46,7 @@ func.func @foo3(%arg0: !fir.boxchar<1>) -> i1 {
// CHECK-LABEL: @bar3
func.func @bar3() -> i1 {
%0 = fir.absent !fir.boxchar<1>
// CHECK: call i1 @foo3(i8* null, i64 undef)
// CHECK: call i1 @foo3(ptr null, i64 undef)
%1 = fir.call @foo3(%0) : (!fir.boxchar<1>) -> i1
return %1 : i1
}

View File

@ -8,9 +8,9 @@
func.func private @bar1(!fir.box<!fir.array<?xf32>>)
// CHECK-LABEL: define void @test_rebox_1(
// CHECK-SAME: { float*, i64, i32, i8, i8, i8, i8, [2 x [3 x i64]] }* %[[INBOX:.*]])
// CHECK-SAME: ptr %[[INBOX:.*]])
func.func @test_rebox_1(%arg0: !fir.box<!fir.array<?x?xf32>>) {
// CHECK: %[[OUTBOX_ALLOC:.*]] = alloca { float*, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }
// CHECK: %[[OUTBOX_ALLOC:.*]] = alloca { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }
%c2 = arith.constant 2 : index
%c3 = arith.constant 3 : index
%c4 = arith.constant 4 : index
@ -21,24 +21,22 @@ func.func @test_rebox_1(%arg0: !fir.box<!fir.array<?x?xf32>>) {
%0 = fir.slice %c5, %undef, %undef, %c6, %c80, %c3 : (index, index, index, index, index, index) -> !fir.slice<2>
%1 = fir.shift %c3, %c4 : (index, index) -> !fir.shift<2>
// CHECK: %[[INSTRIDE_0_GEP:.*]] = getelementptr { float*, i64, i32, i8, i8, i8, i8, [2 x [3 x i64]] }, { float*, i64, i32, i8, i8, i8, i8, [2 x [3 x i64]] }* %[[INBOX]], i32 0, i32 7, i64 0, i32 2
// CHECK: %[[INSTRIDE_0:.]] = load i64, i64* %[[INSTRIDE_0_GEP]]
// CHECK: %[[INSTRIDE_1_GEP:.*]] = getelementptr { float*, i64, i32, i8, i8, i8, i8, [2 x [3 x i64]] }, { float*, i64, i32, i8, i8, i8, i8, [2 x [3 x i64]] }* %[[INBOX]], i32 0, i32 7, i64 1, i32 2
// CHECK: %[[INSTRIDE_1:.*]] = load i64, i64* %[[INSTRIDE_1_GEP]]
// CHECK: %[[INBASE_GEP:.*]] = getelementptr { float*, i64, i32, i8, i8, i8, i8, [2 x [3 x i64]] }, { float*, i64, i32, i8, i8, i8, i8, [2 x [3 x i64]] }* %[[INBOX]], i32 0, i32 0
// CHECK: %[[INBASE:.*]] = load float*, float** %[[INBASE_GEP]]
// CHECK: %[[VOIDBASE:.*]] = bitcast float* %[[INBASE]] to i8*
// CHECK: %[[INSTRIDE_0_GEP:.*]] = getelementptr { ptr, i64, i32, i8, i8, i8, i8, [2 x [3 x i64]] }, ptr %[[INBOX]], i32 0, i32 7, i64 0, i32 2
// CHECK: %[[INSTRIDE_0:.]] = load i64, ptr %[[INSTRIDE_0_GEP]]
// CHECK: %[[INSTRIDE_1_GEP:.*]] = getelementptr { ptr, i64, i32, i8, i8, i8, i8, [2 x [3 x i64]] }, ptr %[[INBOX]], i32 0, i32 7, i64 1, i32 2
// CHECK: %[[INSTRIDE_1:.*]] = load i64, ptr %[[INSTRIDE_1_GEP]]
// CHECK: %[[INBASE_GEP:.*]] = getelementptr { ptr, i64, i32, i8, i8, i8, i8, [2 x [3 x i64]] }, ptr %[[INBOX]], i32 0, i32 0
// CHECK: %[[INBASE:.*]] = load ptr, ptr %[[INBASE_GEP]]
// CHECK: %[[OFFSET_0:.*]] = mul i64 2, %[[INSTRIDE_0]]
// CHECK: %[[VOIDBASE0:.*]] = getelementptr i8, i8* %[[VOIDBASE]], i64 %[[OFFSET_0]]
// CHECK: %[[VOIDBASE0:.*]] = getelementptr i8, ptr %[[INBASE]], i64 %[[OFFSET_0]]
// CHECK: %[[OFFSET_1:.*]] = mul i64 2, %[[INSTRIDE_1]]
// CHECK: %[[VOIDBASE1:.*]] = getelementptr i8, i8* %[[VOIDBASE0]], i64 %[[OFFSET_1]]
// CHECK: %[[VOIDBASE1:.*]] = getelementptr i8, ptr %[[VOIDBASE0]], i64 %[[OFFSET_1]]
// CHECK: %[[OUTSTRIDE0:.*]] = mul i64 3, %[[INSTRIDE_1]]
// CHECK: %[[OUTBOX0:.*]] = insertvalue { float*, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] } { float* undef, i64 4, i32 {{.*}}, i8 1, i8 27, i8 0, i8 0, [1 x [3 x i64]] [{{.*}} [i64 1, i64 25, i64 undef]] }, i64 %[[OUTSTRIDE0]], 7, 0, 2
// CHECK: %[[OUTBASE:.*]] = bitcast i8* %[[VOIDBASE1]] to float*
// CHECK: %[[OUTBOX1:.*]] = insertvalue { float*, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] } %[[OUTBOX0]], float* %[[OUTBASE]], 0
// CHECK: store { float*, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] } %[[OUTBOX1]], { float*, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }* %[[OUTBOX_ALLOC]], align 8
// CHECK: %[[OUTBOX0:.*]] = insertvalue { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] } { ptr undef, i64 4, i32 {{.*}}, i8 1, i8 27, i8 0, i8 0, [1 x [3 x i64]] [{{.*}} [i64 1, i64 25, i64 undef]] }, i64 %[[OUTSTRIDE0]], 7, 0, 2
// CHECK: %[[OUTBOX1:.*]] = insertvalue { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] } %[[OUTBOX0]], ptr %[[VOIDBASE1]], 0
// CHECK: store { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] } %[[OUTBOX1]], ptr %[[OUTBOX_ALLOC]], align 8
%2 = fir.rebox %arg0(%1) [%0] : (!fir.box<!fir.array<?x?xf32>>, !fir.shift<2>, !fir.slice<2>) -> !fir.box<!fir.array<?xf32>>
// CHECK: call void @bar1({ float*, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }* %[[OUTBOX_ALLOC]])
// CHECK: call void @bar1(ptr %[[OUTBOX_ALLOC]])
fir.call @bar1(%2) : (!fir.box<!fir.array<?xf32>>) -> ()
return
}
@ -51,16 +49,16 @@ func.func @test_rebox_1(%arg0: !fir.box<!fir.array<?x?xf32>>) {
func.func private @bar_rebox_test2(!fir.box<!fir.array<?x?x!fir.char<1,?>>>)
// CHECK-LABEL: define void @test_rebox_2(
// CHECK-SAME: { i8*, i64, i32, i8, i8, i8, i8, [2 x [3 x i64]] }* %[[INBOX:.*]])
// CHECK-SAME: ptr %[[INBOX:.*]])
func.func @test_rebox_2(%arg0: !fir.box<!fir.array<?x?x!fir.char<1,?>>>) {
%c1 = arith.constant 1 : index
%c4 = arith.constant 4 : index
%c30 = arith.constant 30 : index
%0 = fir.slice %c4, %c30, %c1, %c4, %c30, %c1 : (index, index, index, index, index, index) -> !fir.slice<2>
// CHECK: %[[OUTBOX:.*]] = alloca { i8*, i64, i32, i8, i8, i8, i8, [2 x [3 x i64]] }
// CHECK: %[[LEN_GEP:.*]] = getelementptr { i8*, i64, i32, i8, i8, i8, i8, [2 x [3 x i64]] }, { i8*, i64, i32, i8, i8, i8, i8, [2 x [3 x i64]] }* %[[INBOX]], i32 0, i32 1
// CHECK: %[[LEN:.*]] = load i64, i64* %[[LEN_GEP]]
// CHECK: insertvalue { i8*, i64, i32, i8, i8, i8, i8, [2 x [3 x i64]] } undef, i64 %[[LEN]], 1
// CHECK: %[[OUTBOX:.*]] = alloca { ptr, i64, i32, i8, i8, i8, i8, [2 x [3 x i64]] }
// CHECK: %[[LEN_GEP:.*]] = getelementptr { ptr, i64, i32, i8, i8, i8, i8, [2 x [3 x i64]] }, ptr %[[INBOX]], i32 0, i32 1
// CHECK: %[[LEN:.*]] = load i64, ptr %[[LEN_GEP]]
// CHECK: insertvalue { ptr, i64, i32, i8, i8, i8, i8, [2 x [3 x i64]] } undef, i64 %[[LEN]], 1
%1 = fir.rebox %arg0 [%0] : (!fir.box<!fir.array<?x?x!fir.char<1,?>>>, !fir.slice<2>) -> !fir.box<!fir.array<?x?x!fir.char<1,?>>>
fir.call @bar_rebox_test2(%1) : (!fir.box<!fir.array<?x?x!fir.char<1,?>>>) -> ()
@ -78,33 +76,31 @@ func.func @test_rebox_2(%arg0: !fir.box<!fir.array<?x?x!fir.char<1,?>>>) {
func.func private @bar_rebox_test3(!fir.box<!fir.array<?x?x?xf32>>)
// CHECK-LABEL: define void @test_rebox_3(
// CHECK-SAME: { float*, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }* %[[INBOX:.*]])
// CHECK-SAME: ptr %[[INBOX:.*]])
func.func @test_rebox_3(%arg0: !fir.box<!fir.array<?xf32>>) {
// CHECK: %[[OUTBOX_ALLOC:.*]] = alloca { float*, i64, i32, i8, i8, i8, i8, [3 x [3 x i64]] }
// CHECK: %[[OUTBOX_ALLOC:.*]] = alloca { ptr, i64, i32, i8, i8, i8, i8, [3 x [3 x i64]] }
%c2 = arith.constant 2 : index
%c3 = arith.constant 3 : index
%c4 = arith.constant 4 : index
%c5 = arith.constant 5 : index
%1 = fir.shape_shift %c2, %c3, %c3, %c4, %c4, %c5 : (index, index, index, index, index, index) -> !fir.shapeshift<3>
// CHECK: %[[INSTRIDE_GEP:.*]] = getelementptr { float*, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, { float*, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }* %[[INBOX]], i32 0, i32 7, i64 0, i32 2
// CHECK: %[[INSTRIDE:.*]] = load i64, i64* %[[INSTRIDE_GEP]]
// CHECK: %[[INBASE_GEP:.*]] = getelementptr { float*, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, { float*, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }* %[[INBOX]], i32 0, i32 0
// CHECK: %[[INBASE:.*]] = load float*, float** %[[INBASE_GEP]]
// CHECK: %[[VOIDBASE:.*]] = bitcast float* %[[INBASE]] to i8*
// CHECK: %[[INSTRIDE_GEP:.*]] = getelementptr { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %[[INBOX]], i32 0, i32 7, i64 0, i32 2
// CHECK: %[[INSTRIDE:.*]] = load i64, ptr %[[INSTRIDE_GEP]]
// CHECK: %[[INBASE_GEP:.*]] = getelementptr { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %[[INBOX]], i32 0, i32 0
// CHECK: %[[INBASE:.*]] = load ptr, ptr %[[INBASE_GEP]]
// CHECK: %[[OUTSTRIDE1:.*]] = mul i64 3, %[[INSTRIDE]]
// CHECK: %[[OUTSTRIDE2:.*]] = mul i64 4, %[[OUTSTRIDE1]]
// CHECK: %[[OUTBOX0:.*]] = insertvalue { float*, i64, i32, i8, i8, i8, i8, [3 x [3 x i64]] } { float* undef, i64 4, i32 {{.*}}, i8 3, i8 27, i8 0, i8 0, [3 x [3 x i64]] [{{.*}} [i64 2, i64 3, i64 undef], [3 x i64] undef, [3 x i64] undef] }, i64 %[[INSTRIDE]], 7, 0, 2
// CHECK: %[[OUTBOX1:.*]] = insertvalue { float*, i64, i32, i8, i8, i8, i8, [3 x [3 x i64]] } %[[OUTBOX0]], i64 3, 7, 1, 0
// CHECK: %[[OUTBOX2:.*]] = insertvalue { float*, i64, i32, i8, i8, i8, i8, [3 x [3 x i64]] } %[[OUTBOX1]], i64 4, 7, 1, 1
// CHECK: %[[OUTBOX3:.*]] = insertvalue { float*, i64, i32, i8, i8, i8, i8, [3 x [3 x i64]] } %[[OUTBOX2]], i64 %[[OUTSTRIDE1]], 7, 1, 2
// CHECK: %[[OUTBOX4:.*]] = insertvalue { float*, i64, i32, i8, i8, i8, i8, [3 x [3 x i64]] } %[[OUTBOX3]], i64 4, 7, 2, 0
// CHECK: %[[OUTBOX5:.*]] = insertvalue { float*, i64, i32, i8, i8, i8, i8, [3 x [3 x i64]] } %[[OUTBOX4]], i64 5, 7, 2, 1
// CHECK: %[[OUTBOX6:.*]] = insertvalue { float*, i64, i32, i8, i8, i8, i8, [3 x [3 x i64]] } %[[OUTBOX5]], i64 %[[OUTSTRIDE2]], 7, 2, 2
// CHECK: %[[OUTBASE:.*]] = bitcast i8* %[[VOIDBASE]] to float*
// CHECK: %[[OUTBOX7:.*]] = insertvalue { float*, i64, i32, i8, i8, i8, i8, [3 x [3 x i64]] } %[[OUTBOX6]], float* %[[OUTBASE]], 0
// CHECK: store { float*, i64, i32, i8, i8, i8, i8, [3 x [3 x i64]] } %[[OUTBOX7]], { float*, i64, i32, i8, i8, i8, i8, [3 x [3 x i64]] }* %[[OUTBOX_ALLOC]]
// CHECK: %[[OUTBOX0:.*]] = insertvalue { ptr, i64, i32, i8, i8, i8, i8, [3 x [3 x i64]] } { ptr undef, i64 4, i32 {{.*}}, i8 3, i8 27, i8 0, i8 0, [3 x [3 x i64]] [{{.*}} [i64 2, i64 3, i64 undef], [3 x i64] undef, [3 x i64] undef] }, i64 %[[INSTRIDE]], 7, 0, 2
// CHECK: %[[OUTBOX1:.*]] = insertvalue { ptr, i64, i32, i8, i8, i8, i8, [3 x [3 x i64]] } %[[OUTBOX0]], i64 3, 7, 1, 0
// CHECK: %[[OUTBOX2:.*]] = insertvalue { ptr, i64, i32, i8, i8, i8, i8, [3 x [3 x i64]] } %[[OUTBOX1]], i64 4, 7, 1, 1
// CHECK: %[[OUTBOX3:.*]] = insertvalue { ptr, i64, i32, i8, i8, i8, i8, [3 x [3 x i64]] } %[[OUTBOX2]], i64 %[[OUTSTRIDE1]], 7, 1, 2
// CHECK: %[[OUTBOX4:.*]] = insertvalue { ptr, i64, i32, i8, i8, i8, i8, [3 x [3 x i64]] } %[[OUTBOX3]], i64 4, 7, 2, 0
// CHECK: %[[OUTBOX5:.*]] = insertvalue { ptr, i64, i32, i8, i8, i8, i8, [3 x [3 x i64]] } %[[OUTBOX4]], i64 5, 7, 2, 1
// CHECK: %[[OUTBOX6:.*]] = insertvalue { ptr, i64, i32, i8, i8, i8, i8, [3 x [3 x i64]] } %[[OUTBOX5]], i64 %[[OUTSTRIDE2]], 7, 2, 2
// CHECK: %[[OUTBOX7:.*]] = insertvalue { ptr, i64, i32, i8, i8, i8, i8, [3 x [3 x i64]] } %[[OUTBOX6]], ptr %[[INBASE]], 0
// CHECK: store { ptr, i64, i32, i8, i8, i8, i8, [3 x [3 x i64]] } %[[OUTBOX7]], ptr %[[OUTBOX_ALLOC]]
%2 = fir.rebox %arg0(%1) : (!fir.box<!fir.array<?xf32>>, !fir.shapeshift<3>) -> !fir.box<!fir.array<?x?x?xf32>>
// CHECK: call void @bar_rebox_test3({ float*, i64, i32, i8, i8, i8, i8, [3 x [3 x i64]] }* %[[OUTBOX_ALLOC]])
// CHECK: call void @bar_rebox_test3(ptr %[[OUTBOX_ALLOC]])
fir.call @bar_rebox_test3(%2) : (!fir.box<!fir.array<?x?x?xf32>>) -> ()
return
}
@ -114,21 +110,20 @@ func.func @test_rebox_3(%arg0: !fir.box<!fir.array<?xf32>>) {
// time constant length.
// CHECK-LABEL: define void @test_rebox_4(
// CHECK-SAME: { i8*, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }* %[[INPUT:.*]])
// CHECK-SAME: ptr %[[INPUT:.*]])
func.func @test_rebox_4(%arg0: !fir.box<!fir.array<?x!fir.char<1,?>>>) {
// CHECK: %[[NEWBOX_STORAGE:.*]] = alloca { [10 x i8]*, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }
// CHECK: %[[EXTENT_GEP:.*]] = getelementptr {{{.*}}}, { i8*, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }* %[[INPUT]], i32 0, i32 7, i64 0, i32 1
// CHECK: %[[EXTENT:.*]] = load i64, i64* %[[EXTENT_GEP]]
// CHECK: %[[STRIDE_GEP:.*]] = getelementptr { i8*, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, { i8*, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }* %[[INPUT]], i32 0, i32 7, i64 0, i32 2
// CHECK: %[[STRIDE:.*]] = load i64, i64* %[[STRIDE_GEP]]
// CHECK: %[[BASE_GEP:.*]] = getelementptr { i8*, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, { i8*, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }* %[[INPUT]], i32 0, i32 0
// CHECK: %[[BASE:.*]] = load i8*, i8** %[[BASE_GEP]]
// CHECK: %[[NEWBOX1:.*]] = insertvalue {{{.*}}} { [10 x i8]* undef, i64 10, i32 20180515, i8 1, i8 40, i8 1, i8 0, [1 x [3 x i64]] [{{.*}} [i64 1, i64 undef, i64 undef]] }, i64 %[[EXTENT]], 7, 0, 1
// CHECK: %[[NEWBOX2:.*]] = insertvalue { [10 x i8]*, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] } %[[NEWBOX1]], i64 %[[STRIDE]], 7, 0, 2
// CHECK: %[[BASE_CAST:.*]] = bitcast i8* %12 to [10 x i8]*
// CHECK: %[[NEWBOX3:.*]] = insertvalue { [10 x i8]*, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] } %[[NEWBOX2]], [10 x i8]* %[[BASE_CAST]], 0
// CHECK: store { [10 x i8]*, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] } %[[NEWBOX3]], { [10 x i8]*, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }* %[[NEWBOX_STORAGE]]
// CHECK: call void @bar_test_rebox_4({ [10 x i8]*, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }* %[[NEWBOX_STORAGE]])
// CHECK: %[[NEWBOX_STORAGE:.*]] = alloca { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }
// CHECK: %[[EXTENT_GEP:.*]] = getelementptr {{{.*}}}, ptr %[[INPUT]], i32 0, i32 7, i64 0, i32 1
// CHECK: %[[EXTENT:.*]] = load i64, ptr %[[EXTENT_GEP]]
// CHECK: %[[STRIDE_GEP:.*]] = getelementptr { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %[[INPUT]], i32 0, i32 7, i64 0, i32 2
// CHECK: %[[STRIDE:.*]] = load i64, ptr %[[STRIDE_GEP]]
// CHECK: %[[BASE_GEP:.*]] = getelementptr { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %[[INPUT]], i32 0, i32 0
// CHECK: %[[BASE:.*]] = load ptr, ptr %[[BASE_GEP]]
// CHECK: %[[NEWBOX1:.*]] = insertvalue {{{.*}}} { ptr undef, i64 10, i32 20180515, i8 1, i8 40, i8 1, i8 0, [1 x [3 x i64]] [{{.*}} [i64 1, i64 undef, i64 undef]] }, i64 %[[EXTENT]], 7, 0, 1
// CHECK: %[[NEWBOX2:.*]] = insertvalue { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] } %[[NEWBOX1]], i64 %[[STRIDE]], 7, 0, 2
// CHECK: %[[NEWBOX3:.*]] = insertvalue { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] } %[[NEWBOX2]], ptr %[[BASE]], 0
// CHECK: store { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] } %[[NEWBOX3]], ptr %[[NEWBOX_STORAGE]]
// CHECK: call void @bar_test_rebox_4(ptr %[[NEWBOX_STORAGE]])
%1 = fir.rebox %arg0 : (!fir.box<!fir.array<?x!fir.char<1,?>>>) -> !fir.box<!fir.ptr<!fir.array<?x!fir.char<1,10>>>>
fir.call @bar_test_rebox_4(%1) : (!fir.box<!fir.ptr<!fir.array<?x!fir.char<1,10>>>>) -> ()

View File

@ -12,28 +12,28 @@ subroutine ordered
!FIRDialect: omp.ordered_region {
!LLVMIRDialect: omp.ordered_region {
!LLVMIR: [[TMP0:%.*]] = call i32 @__kmpc_global_thread_num(%struct.ident_t* @[[GLOB0:[0-9]+]]), !dbg !{{.*}}
!LLVMIR-NEXT: call void @__kmpc_ordered(%struct.ident_t* @[[GLOB0]], i32 [[TMP0]]), !dbg !{{.*}}
!LLVMIR: [[TMP0:%.*]] = call i32 @__kmpc_global_thread_num(ptr @[[GLOB0:[0-9]+]]), !dbg !{{.*}}
!LLVMIR-NEXT: call void @__kmpc_ordered(ptr @[[GLOB0]], i32 [[TMP0]]), !dbg !{{.*}}
!$OMP ORDERED
a(i) = a(i-1) + 1
!FIRDialect: omp.terminator
!FIRDialect-NEXT: }
!LLVMIRDialect: omp.terminator
!LLVMIRDialect-NEXT: }
!LLVMIR: call void @__kmpc_end_ordered(%struct.ident_t* @[[GLOB0]], i32 [[TMP0]]), !dbg !{{.*}}
!LLVMIR: call void @__kmpc_end_ordered(ptr @[[GLOB0]], i32 [[TMP0]]), !dbg !{{.*}}
!$OMP END ORDERED
!FIRDialect: omp.ordered_region {
!LLVMIRDialect: omp.ordered_region {
!LLVMIR: [[TMP1:%.*]] = call i32 @__kmpc_global_thread_num(%struct.ident_t* @[[GLOB1:[0-9]+]]), !dbg !{{.*}}
!LLVMIR-NEXT: call void @__kmpc_ordered(%struct.ident_t* @[[GLOB1]], i32 [[TMP1]]), !dbg !{{.*}}
!LLVMIR: [[TMP1:%.*]] = call i32 @__kmpc_global_thread_num(ptr @[[GLOB1:[0-9]+]]), !dbg !{{.*}}
!LLVMIR-NEXT: call void @__kmpc_ordered(ptr @[[GLOB1]], i32 [[TMP1]]), !dbg !{{.*}}
!$OMP ORDERED THREADS
a(i) = a(i-1) + 1
!FIRDialect: omp.terminator
!FIRDialect-NEXT: }
!LLVMIRDialect: omp.terminator
!LLVMIRDialect-NEXT: }
!LLVMIR: call void @__kmpc_end_ordered(%struct.ident_t* @[[GLOB1]], i32 [[TMP1]]), !dbg !{{.*}}
!LLVMIR: call void @__kmpc_end_ordered(ptr @[[GLOB1]], i32 [[TMP1]]), !dbg !{{.*}}
!LLVMIR-NEXT: ret void, !dbg !{{.*}}
!$OMP END ORDERED

View File

@ -11,7 +11,7 @@
subroutine s0
common // a0, b0
! CHECK: call void @_QPs(float* bitcast ([8 x i8]* @_QB to float*), float* bitcast (i8* getelementptr inbounds ([8 x i8], [8 x i8]* @_QB, i32 0, i64 4) to float*))
! CHECK: call void @_QPs(ptr @_QB, ptr getelementptr (i8, ptr @_QB, i64 4))
call s(a0, b0)
end subroutine s0
@ -20,7 +20,7 @@ subroutine s1
common /x/ a1, b1
data a1 /1.0/, b1 /2.0/
! CHECK: call void @_QPs(float* getelementptr inbounds ({ float, float }, { float, float }* @_QBx, i32 0, i32 0), float* bitcast (i8* getelementptr (i8, i8* bitcast ({ float, float }* @_QBx to i8*), i64 4) to float*))
! CHECK: call void @_QPs(ptr @_QBx, ptr getelementptr (i8, ptr @_QBx, i64 4))
call s(a1, b1)
end subroutine s1
@ -28,7 +28,7 @@ end subroutine s1
subroutine s2
common /y/ a2, b2, c2
! CHECK: call void @_QPs(float* bitcast ([12 x i8]* @_QBy to float*), float* bitcast (i8* getelementptr inbounds ([12 x i8], [12 x i8]* @_QBy, i32 0, i64 4) to float*))
! CHECK: call void @_QPs(ptr @_QBy, ptr getelementptr (i8, ptr @_QBy, i64 4))
call s(a2, b2)
end subroutine s2
@ -53,9 +53,9 @@ end module
! CHECK-LABEL: _QPs4
subroutine s4
use mod_with_common
! CHECK: load i32, i32* bitcast ([8 x i8]* @_QBc_in_mod to i32*)
! CHECK: load i32, ptr @_QBc_in_mod
print *, i
! CHECK: load i32, i32* bitcast (i8* getelementptr inbounds ([8 x i8], [8 x i8]* @_QBc_in_mod, i32 0, i64 4) to i32*)
! CHECK: load i32, ptr getelementptr (i8, ptr @_QBc_in_mod, i64 4)
print *, j
end subroutine s4

View File

@ -7,5 +7,5 @@ END
! Verify that the offset in the struct does not regress from i32.
! CHECK-LABEL: define void @_QQmain()
! CHECK: getelementptr { float, float }, { float, float }* %{{[0-9]+}}, i64 0, i32 0
! CHECK: getelementptr { float, float }, ptr %{{[0-9]+}}, i64 0, i32 0