Break circular dependency between FIR dialect and utilities
[llvm-project.git] / flang / test / Lower / forall / character-1.f90
blob8ccc09d90be646f68ecae725c9053d48408ff9ca
1 ! RUN: bbc %s -o - | tco | FileCheck %s
2 ! RUN: %flang -emit-llvm -S -mmlir -disable-external-name-interop %s -o - | FileCheck %s
3 ! Test from Fortran source through to LLVM IR.
4 ! UNSUPPORTED: system-windows
6 ! Assumed size array of assumed length character.
7 program test
8 character :: x(3) = (/ '1','2','3' /)
9 call sub(x)
10 contains
11 subroutine sub(x)
12 character(*) x(:)
13 forall (i=1:2)
14 x(i:i)(1:1) = x(i+1:i+1)(1:1)
15 end forall
16 print *,x
17 end subroutine sub
18 end program test
20 ! CHECK-LABEL: define void @_QFPsub(
21 ! CHECK-SAME: ptr %[[arg:.*]])
22 ! CHECK: %[[extent:.*]] = getelementptr { {{.*}}, [1 x [3 x i64]] }, ptr %[[arg]], i32 0, i32 7, i64 0, i32 1
23 ! CHECK: %[[extval:.*]] = load i64, ptr %[[extent]]
24 ! CHECK: %[[elesize:.*]] = getelementptr { {{.*}}, [1 x [3 x i64]] }, ptr %[[arg]], i32 0, i32 1
25 ! CHECK: %[[esval:.*]] = load i64, ptr %[[elesize]]
26 ! CHECK: %[[mul:.*]] = mul i64 ptrtoint (ptr getelementptr (i8, ptr null, i32 1) to i64), %[[esval]]
27 ! CHECK: %[[mul2:.*]] = mul i64 %[[mul]], %[[extval]]
28 ! CHECK: %[[buff:.*]] = call ptr @malloc(i64 %[[mul2]])
29 ! CHECK: %[[to:.*]] = getelementptr i8, ptr %[[buff]], i64 %
30 ! CHECK: call void @llvm.memmove.p0.p0.i64(ptr %[[to]], ptr %{{.*}}, i64 %{{.*}}, i1 false)
31 ! CHECK: call void @free(ptr %[[buff]])
32 ! CHECK: call ptr @_FortranAioBeginExternalListOutput