Skip to content

Commit 8663c66

Browse files
Rename and improve test
Add a second reduction of a by_val type, so that we can test for the most recent bug found. Also, since the test is now different, rename it. This test is going all the way to LLVM-IR to ensure the whole codegeneration works here.
1 parent a07d09a commit 8663c66

File tree

2 files changed

+48
-23
lines changed

2 files changed

+48
-23
lines changed

flang/test/Lower/OpenMP/parallel-reduction-allocate.f90

Lines changed: 0 additions & 23 deletions
This file was deleted.
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
!! Make sure that mixture of by-ref and by-val reductions work all the way
2+
!! to LLVM-IR code.
3+
! RUN: %flang_fc1 -emit-llvm -fopenmp -o - %s 2>&1 | FileCheck %s
4+
subroutine proc
5+
implicit none
6+
real(8),allocatable :: F(:)
7+
real(8),allocatable :: A(:)
8+
9+
integer :: I
10+
11+
!$omp parallel private(A) reduction(+:F,I)
12+
allocate(A(10))
13+
!$omp end parallel
14+
end subroutine proc
15+
16+
!CHECK-LABEL: define void @proc_()
17+
!CHECK: call void
18+
!CHECK-SAME: @__kmpc_fork_call(ptr {{.*}}, i32 1, ptr @[[OMP_PAR:.*]], {{.*}})
19+
20+
!CHECK: define internal void @[[OMP_PAR]](ptr {{.*}} %[[TID_ADDR:.*]], ptr noalias
21+
!CHECK: %[[TID_LOCAL:.*]] = alloca i32
22+
!CHECK: %[[TID:.*]] = load i32, ptr %[[TID_ADDR]]
23+
!CHECK: store i32 %[[TID]], ptr %[[TID_LOCAL]]
24+
!CHECK: %[[I_priv:.*]] = alloca i32
25+
!CHECK: %[[F_priv:.*]] = alloca ptr
26+
27+
!CHECK: omp.reduction.init:
28+
!CHECK: store ptr %{{.*}}, ptr %[[F_priv]]
29+
!CHECK: store i32 0, ptr %[[I_priv]]
30+
31+
!CHECK: omp.par.region8:
32+
!CHECK-NEXT: call ptr @malloc
33+
!CHECK-SAME: i64 10
34+
35+
!CHECK: %[[RED_ARR_0:.*]] = getelementptr inbounds [2 x ptr], ptr %red.array, i64 0, i64 0
36+
!CHECK: store ptr %[[F_priv]], ptr %[[RED_ARR_0:.*]]
37+
!CHECK: %[[RED_ARR_1:.*]] = getelementptr inbounds [2 x ptr], ptr %red.array, i64 0, i64 1
38+
!CHECK: store ptr %[[I_priv]], ptr %[[RED_ARR_1]]
39+
40+
!CHECK: omp.par.pre_finalize: ; preds = %reduce.finalize
41+
!CHECK: %{{.*}} = load ptr, ptr %[[F_priv]]
42+
!CHECK: br label %omp.reduction.cleanup
43+
44+
!CHECK: omp.reduction.cleanup:
45+
!CHECK: br i1 %{{.*}}, label %[[OMP_FREE:.*]], label %{{.*}}
46+
47+
!CHECK: [[OMP_FREE]]:
48+
!CHECK: call void @free

0 commit comments

Comments
 (0)