OpenMP: Fix Fortran mapping of allocatable comps of global variables [PR128969]
Corrects OpenMP Fortran mapping for allocatable components within global variables.
This change fixes an issue in OpenMP’s Fortran support where the mapping of allocatable components within global variables was incorrect. The scan_sharing_clauses function has been reordered to properly handle the deep mapping required for these Fortran constructs. Previously, global variables returned too early, preventing the flex_array_ptr boolean from being set correctly, which is necessary for this deep mapping.
In Details
The scan_sharing_clauses function in omp-low.cc is responsible for processing OpenMP sharing clauses and setting up data mapping structures. This patch corrects its behavior for Fortran code when dealing with global variables that have allocatable components. The issue stemmed from an early exit for global variables, which prevented the flex_array_ptr flag from being correctly set on the internal address-mapping structure. Reordering the if blocks ensures this flag is set, enabling the correct deep mapping of nested allocatable components.
- OpenMP
- An API that supports multi-platform shared-memory parallel programming in C, C++, and Fortran.
- allocatable component
- In Fortran, a data member within a derived type (struct) that can be dynamically allocated and deallocated during program execution.
- global variable
- A variable declared outside of any function, making it accessible from anywhere within the program.
- Fortran
- A high-level programming language primarily used for scientific and numerical computation.
- mapping
- In the context of parallel programming, mapping refers to how data is associated with or accessed by different computational units or threads.