-
Notifications
You must be signed in to change notification settings - Fork 10.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Flang][OpenMP] Fix loop index privatisation with HLFIR
Loop index variables are privatised for a worksharing loop. The alloca ops of the privatised index are hoisted to the entry block of the outlineable region or parent function. With HLFIR, the hlfir.declare should be created in the same place as the alloca op. To achieve this the alloc and the hflir.declare should be created in the same place. A new function is created in OpenMP.cpp for this purpose. Reviewed By: tblah Differential Revision: https://reviews.llvm.org/D156719
- Loading branch information
1 parent
1684406
commit 980808d
Showing
4 changed files
with
53 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
! This test checks lowering of OpenMP DO Directive with HLFIR. | ||
|
||
! RUN: bbc -hlfir -fopenmp -emit-fir %s -o - | FileCheck %s | ||
! RUN: %flang_fc1 -emit-fir -flang-experimental-hlfir -fopenmp %s -o - | FileCheck %s | ||
|
||
!CHECK-LABEL: func @_QPsimple_loop() | ||
subroutine simple_loop | ||
integer :: i | ||
! CHECK-DAG: %[[WS_ST:.*]] = arith.constant 1 : i32 | ||
! CHECK-DAG: %[[WS_END:.*]] = arith.constant 9 : i32 | ||
! CHECK: omp.parallel | ||
!$OMP PARALLEL | ||
! CHECK-DAG: %[[ALLOCA_IV:.*]] = fir.alloca i32 {{{.*}}, pinned} | ||
! CHECK: %[[IV:.*]] = fir.declare %[[ALLOCA_IV]] {uniq_name = "_QFsimple_loopEi"} : (!fir.ref<i32>) -> !fir.ref<i32> | ||
! CHECK: omp.wsloop for (%[[I:.*]]) : i32 = (%[[WS_ST]]) to (%[[WS_END]]) inclusive step (%[[WS_ST]]) | ||
!$OMP DO | ||
do i=1, 9 | ||
! CHECK: fir.store %[[I]] to %[[IV:.*]] : !fir.ref<i32> | ||
! CHECK: %[[LOAD_IV:.*]] = fir.load %[[IV]] : !fir.ref<i32> | ||
! CHECK: fir.call @_FortranAioOutputInteger32({{.*}}, %[[LOAD_IV]]) {{.*}}: (!fir.ref<i8>, i32) -> i1 | ||
print*, i | ||
end do | ||
! CHECK: omp.yield | ||
!$OMP END DO | ||
! CHECK: omp.terminator | ||
!$OMP END PARALLEL | ||
end subroutine |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters