-
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 privatization of threadprivate common block (#77821)
In some cases, when privatizing a threadprivate common block, the original symbol will correspond to the common block, instead of its threadprivate version. This can happen, for instance, with a common block, declared in a separate module, used by a parent procedure and privatized in its child procedure. In this case, symbol lookup won't find a symbol in the parent procedure, but only in the module where the common block was defined. Fixes #65028
- Loading branch information
Showing
2 changed files
with
54 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,29 @@ | ||
! This test checks lowering of OpenMP Threadprivate Directive. | ||
! Test for common block, defined in one module, used in a subroutine of | ||
! another module and privatized in a nested subroutine. | ||
|
||
!RUN: %flang_fc1 -emit-hlfir -fopenmp %s -o - | FileCheck %s | ||
|
||
!CHECK: fir.global common @cmn_(dense<0> : vector<4xi8>) : !fir.array<4xi8> | ||
module m0 | ||
common /cmn/ k1 | ||
!$omp threadprivate(/cmn/) | ||
end | ||
|
||
module m1 | ||
contains | ||
subroutine ss1 | ||
use m0 | ||
contains | ||
!CHECK-LABEL: func @_QMm1Fss1Pss2 | ||
!CHECK: %[[CMN:.*]] = fir.address_of(@cmn_) : !fir.ref<!fir.array<4xi8>> | ||
!CHECK: omp.parallel | ||
!CHECK: %{{.*}} = omp.threadprivate %[[CMN]] : !fir.ref<!fir.array<4xi8>> -> !fir.ref<!fir.array<4xi8>> | ||
subroutine ss2 | ||
!$omp parallel copyin (k1) | ||
!$omp end parallel | ||
end subroutine ss2 | ||
end subroutine ss1 | ||
end | ||
|
||
end |