OpenMP 5.0: Enables multiple map clauses for the same variable.
GCC now supports OpenMP 5.0's allowance of multiple map clauses on the same variable, requiring deduplication to avoid cycles during gimplification.
This commit enables support for OpenMP 5.0’s relaxation of the restriction against multiple map clauses referencing the same variable within a single OpenMP construct. To ensure correct code generation, the compiler now deduplicates or merges these map clauses before the topological sort in gimplify.cc, preventing potential cycles. This deduplication occurs both in the front-ends and during gimplification due to early clause expansion. The Fortran front-end sees adjustments to enum gfc_omp_map_op.
In Details
This patch involves modifications to the C, C++, and Fortran front-ends, as well as the gimplifier. Map clauses are deduplicated/merged before the topological sort in gimplify.cc. The changes to omp-general.cc, omp-low.cc, fold-const.cc are also relevant. Understanding the interaction between front-end clause processing, gimplification, and the OpenMP runtime is crucial for comprehending this commit.
For Context
OpenMP is a set of compiler directives, library routines, and environment variables that allows programmers to easily parallelize their code. The map clause in OpenMP specifies how variables are shared between the main program and the parallel regions. This commit updates the compiler to support a new feature in OpenMP 5.0 that allows multiple map clauses to refer to the same variable. The compiler now merges these clauses internally to ensure correct and efficient parallel execution, conforming to the updated OpenMP standard.