-
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 HLFIR lowering for commonblock threadprivate
Commonblock names are not variables, but they can be marked as threadprivate in OpenMP. This requires the commonblock name to be bound to the address of the Commonblock. hlfir.declares are not required for these, but we should be able to retrieve the mlir Value corresponding to the Commonblock. This patch enables this by special casing the Commonblocks like procedures. Reviewed By: tblah, vzakhari Differential Revision: https://reviews.llvm.org/D158070
- Loading branch information
1 parent
869d231
commit 8b834ca
Showing
3 changed files
with
43 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
29 changes: 29 additions & 0 deletions
29
flang/test/Lower/OpenMP/threadprivate-common-block-hlfir.f90
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,29 @@ | ||
! Simple test for lowering of OpenMP Threadprivate Directive with HLFIR. | ||
! Test for common block. | ||
|
||
!RUN: %flang_fc1 -flang-experimental-hlfir -emit-hlfir -fopenmp %s -o - | FileCheck %s | ||
!RUN: bbc -hlfir -emit-hlfir -fopenmp %s -o - | FileCheck %s | ||
|
||
|
||
!CHECK: %[[CBLK_ADDR:.*]] = fir.address_of(@_QCblk) : !fir.ref<!fir.array<4xi8>> | ||
!CHECK: {{.*}} = omp.threadprivate %[[CBLK_ADDR]] : !fir.ref<!fir.array<4xi8>> -> !fir.ref<!fir.array<4xi8>> | ||
!CHECK: omp.parallel { | ||
!CHECK: %[[TP_PARALLEL:.*]] = omp.threadprivate %[[CBLK_ADDR]] : !fir.ref<!fir.array<4xi8>> -> !fir.ref<!fir.array<4xi8>> | ||
!CHECK: %[[TP_PARALLEL_ADDR:.*]] = fir.convert %[[TP_PARALLEL]] : (!fir.ref<!fir.array<4xi8>>) -> !fir.ref<!fir.array<?xi8>> | ||
!CHECK: %[[A_ADDR:.*]] = fir.coordinate_of %[[TP_PARALLEL_ADDR]], %c0_1 : (!fir.ref<!fir.array<?xi8>>, index) -> !fir.ref<i8> | ||
!CHECK: %[[A_ADDR_CVT:.*]] = fir.convert %[[A_ADDR]] : (!fir.ref<i8>) -> !fir.ref<i32> | ||
!CHECK: %[[A_DECL:.*]]:2 = hlfir.declare %[[A_ADDR_CVT]] {uniq_name = "_QFsub_commonblockEa"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>) | ||
!CHECK: %[[A_VAL:.*]] = fir.load %[[A_DECL]]#0 : !fir.ref<i32> | ||
!CHECK: {{.*}} = fir.call @_FortranAioOutputInteger32({{.*}}, %[[A_VAL]]) fastmath<contract> : (!fir.ref<i8>, i32) -> i1 | ||
!CHECK: omp.terminator | ||
!CHECK: } | ||
|
||
subroutine sub_commonblock() | ||
integer:: a | ||
common /blk/ a | ||
!$omp threadprivate(/blk/) | ||
|
||
!$omp parallel | ||
print *, a | ||
!$omp end parallel | ||
end |