[flang-commits] [flang] [flang][OpenMP] Privatize loop IVs in the innermost parallel (PR #227486)
via flang-commits
flang-commits at lists.llvm.org
Tue Sep 29 14:53:06 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-flang-fir-hlfir
Author: Leandro Lupori (luporl)
<details>
<summary>Changes</summary>
A sequential loop's iteration variable is predetermined private in the
innermost parallel, teams or task-generating construct that encloses
the loop. When the loop was nested in another construct, such as a
worksharing loop, lowering failed to privatize the variable in the
enclosing parallel region. Instead, it created a new local copy inside
the nested construct, so the parallel region's other references to the
variable used the shared host variable.
Fix this by deciding which construct privatizes a symbol based on the
scope that owns it. This also simplifies DataSharingProcessor: the
OMPConstructSymbolVisitor, which walked the parse tree to track where
symbols were defined, is no longer needed and has been removed.
I have noticed that metadirectives don't always own the symbols that
should be privatized in them, as semantics doesn't create a new scope.
I'm not very familiar with metadirectives, but it seems this causes some
privatization issues with non-explicitly specified DSAs, as
DataSharingProcessor relies on ownership information to determine which
symbols should be privatized. These issues already existed before this
change, and I haven't seen any test regressions after it. I've run the
gfortran and Fujitsu testsuites.
Fixes #<!-- -->207125
Assisted-By: Claude Code Opus 5.5 (tests and documentation only)
---
Full diff: https://github.com/llvm/llvm-project/pull/227486.diff
8 Files Affected:
- (modified) flang/lib/Lower/Bridge.cpp (+1-8)
- (modified) flang/lib/Lower/OpenMP/DataSharingProcessor.cpp (+67-130)
- (modified) flang/lib/Lower/OpenMP/DataSharingProcessor.h (-73)
- (modified) flang/test/Lower/OpenMP/lastprivate-simd.f90 (+4-1)
- (added) flang/test/Lower/OpenMP/predetermined-do-iv.f90 (+208)
- (modified) flang/test/Lower/OpenMP/shared-loop.f90 (+4-6)
- (modified) flang/test/Lower/OpenMP/taskgroup02.f90 (+1-2)
- (modified) flang/test/Lower/OpenMP/unstructured.f90 (+7-8)
``````````diff
The server is unavailable at this time. Please wait a few minutes before you try again.
``````````
</details>
https://github.com/llvm/llvm-project/pull/227486
More information about the flang-commits
mailing list