xref: /llvm-project/flang/test/Lower/OpenMP/location.f90 (revision 937cbce14c9aa956342a9c818c26a8a557802843)
1! This test checks location of OpenMP constructs and clauses
2
3!RUN: %flang_fc1 -emit-hlfir -fopenmp -mmlir --mlir-print-debuginfo %s -o - | FileCheck %s
4
5!CHECK-LABEL: sub_parallel
6subroutine sub_parallel()
7  print *, x
8!CHECK: omp.parallel   {
9  !$omp parallel
10    print *, x
11!CHECK:   omp.terminator loc(#[[PAR_LOC:.*]])
12!CHECK: } loc(#[[PAR_LOC]])
13  !$omp end parallel
14  print *, x
15end
16
17!CHECK-LABEL: sub_target
18subroutine sub_target()
19  print *, x
20!CHECK: omp.target {{.*}} {
21  !$omp target
22    print *, x
23!CHECK:   omp.terminator loc(#[[TAR_LOC:.*]])
24!CHECK: } loc(#[[TAR_LOC]])
25  !$omp end target
26  print *, x
27end
28
29!CHECK-LABEL: sub_loop
30subroutine sub_loop()
31!CHECK: omp.wsloop {
32!CHECK-NEXT: omp.loop_nest {{.*}} {
33  !$omp do
34  do i=1,10
35    print *, i
36!CHECK:   omp.yield loc(#[[LOOP_LOC:.*]])
37!CHECK: } loc(#[[LOOP_LOC]])
38!CHECK: } loc(#[[LOOP_LOC]])
39  end do
40  !$omp end do
41end
42
43!CHECK-LABEL: sub_standalone
44subroutine sub_standalone()
45  !CHECK: omp.barrier loc(#[[BAR_LOC:.*]])
46  !$omp barrier
47  !CHECK: omp.taskwait loc(#[[TW_LOC:.*]])
48  !$omp taskwait
49  !CHECK: omp.taskyield loc(#[[TY_LOC:.*]])
50  !$omp taskyield
51end
52
53subroutine sub_if(c)
54  logical(kind=4) :: c
55  !CHECK: %[[CVT:.*]] = fir.convert %{{.*}} : (!fir.logical<4>) -> i1 loc(#[[IF_LOC:.*]])
56  !CHECK: omp.task if(%[[CVT]])
57  !$omp task if(c)
58    print *, "Task"
59  !$omp end task
60  !CHECK: } loc(#[[TASK_LOC:.*]])
61end subroutine
62
63!CHECK: #[[PAR_LOC]] = loc("{{.*}}location.f90":9:9)
64!CHECK: #[[TAR_LOC]] = loc("{{.*}}location.f90":21:9)
65!CHECK: #[[LOOP_LOC]] = loc("{{.*}}location.f90":33:9)
66!CHECK: #[[BAR_LOC]] = loc("{{.*}}location.f90":46:9)
67!CHECK: #[[TW_LOC]] = loc("{{.*}}location.f90":48:9)
68!CHECK: #[[TY_LOC]] = loc("{{.*}}location.f90":50:9)
69!CHECK: #[[IF_LOC]] = loc("{{.*}}location.f90":57:14)
70!CHECK: #[[TASK_LOC]] = loc("{{.*}}location.f90":57:9)
71