[flang-commits] [flang] [flang][OpenMP] don't privatise loop index marked shared (PR #108176)
Leandro Lupori via flang-commits
flang-commits at lists.llvm.org
Thu Sep 12 05:32:24 PDT 2024
================
@@ -1326,7 +1326,8 @@ class FirConverter : public Fortran::lower::AbstractConverter {
bool isUnordered) {
if (isUnordered || sym.has<Fortran::semantics::HostAssocDetails>() ||
sym.has<Fortran::semantics::UseDetails>()) {
- if (!shallowLookupSymbol(sym)) {
+ if (!shallowLookupSymbol(sym) &&
+ !sym.test(Fortran::semantics::Symbol::Flag::OmpShared)) {
----------------
luporl wrote:
We do set the privatization flag on loop induction variables.
```f90
!$omp parallel
!$omp sections
do i=1,10
end do
!$omp end sections
!$omp end parallel
end
```
```
$ flang-new -fc1 -fdebug-unparse-with-symbols -fopenmp test.f90
!$omp parallel
!$omp sections
!$omp section
!DEF: /MainProgram1/OtherConstruct1/i (OmpPrivate, OmpPreDetermined) HostAssoc INTEGER(4)
do i=1,10
end do
!$omp end sections
!$omp end parallel
end program
```
But I think it's better to use `Symbol::Flag::OmpShared` anyway, since it seems to work and makes the intention more explicit.
https://github.com/llvm/llvm-project/pull/108176
More information about the flang-commits
mailing list