-
Notifications
You must be signed in to change notification settings - Fork 10.7k
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 lowering for threadprivate with HLFIR
HLFIR inserts hlfir.declare for threadprivate variables. Seek over the hlfir.declare to find the threadprivate global symbol. Reviewed By: tblah Differential Revision: https://reviews.llvm.org/D157730
- Loading branch information
1 parent
cd861ad
commit bd686ca
Showing
2 changed files
with
31 additions
and
2 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,26 @@ | ||
! Simple test for lowering of OpenMP Threadprivate Directive with HLFIR. | ||
|
||
!RUN: %flang_fc1 -flang-experimental-hlfir -emit-hlfir -fopenmp %s -o - | FileCheck %s | ||
!RUN: bbc -hlfir -emit-hlfir -fopenmp %s -o - | FileCheck %s | ||
|
||
!CHECK-LABEL: @_QPsub | ||
!CHECK: %[[ADDR:.*]] = fir.address_of(@_QFsubEa) : !fir.ref<i32> | ||
!CHECK: %[[DECL:.*]]:2 = hlfir.declare %[[ADDR]] {uniq_name = "_QFsubEa"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>) | ||
!CHECK: %[[TP:.*]] = omp.threadprivate %[[DECL]]#1 : !fir.ref<i32> -> !fir.ref<i32> | ||
!CHECK: %[[TP_DECL:.*]]:2 = hlfir.declare %[[TP:.*]] {uniq_name = "_QFsubEa"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>) | ||
!CHECK: omp.parallel { | ||
!CHECK: %[[TP_PARALLEL:.*]] = omp.threadprivate %[[DECL]]#1 : !fir.ref<i32> -> !fir.ref<i32> | ||
!CHECK: %[[TP_PARALLEL_DECL:.*]]:2 = hlfir.declare %[[TP_PARALLEL]] {uniq_name = "_QFsubEa"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>) | ||
!CHECK: %[[TP_VAL:.*]] = fir.load %[[TP_PARALLEL_DECL]]#0 : !fir.ref<i32> | ||
!CHECK: %{{.*}} = fir.call @_FortranAioOutputInteger32(%{{.*}}, %[[TP_VAL]]) fastmath<contract> : (!fir.ref<i8>, i32) -> i1 | ||
!CHECK: omp.terminator | ||
|
||
!CHECK: fir.global internal @_QFsubEa : i32 | ||
|
||
subroutine sub() | ||
integer, save:: a | ||
!$omp threadprivate(a) | ||
!$omp parallel | ||
print *, a | ||
!$omp end parallel | ||
end subroutine |