This is a revised version of the patch series posted at:
https://gcc.gnu.org/pipermail/gcc-patches/2024-October/664541.html
The previous version performed the expansion of the iterators into loops
at the omp-lowering stage, but that meant that the Gimplification of the
clauses with iterators was also delayed to that point, which is undesirable.
To fix this, I have split the handling of iterators into two phases. The
first stage happens during the gimplification pass - the iterator loops
are created, then immediately Gimplified. The resulting Gimple sequence
is later stored separately as an operand in the Gimple target statement
rather than incorporated directly into the main program code. When the
clause decl and sizes are gimplified in gimplify_scan_omp_clauses and
gimplify_adjust_omp_clauses, we enter the bind context of the iterator
loop body corresponding to the clause then gimplify the decl/size
directly into the loop body (which works because the iterator variables
are in scope at that point).
In the omp lowering pass, lower_omp_map_iterator_expr and
lower_omp_map_iterator_size as still called just before sending the
hostaddrs/sizes to the arrays read by libgomp, but they now enter the
bind context of the relevant loop body and generate code there. After
lowering is done, the gimple sequence containing the loops is inserted
just before the Gimple code for the target statement.
The behaviour with clauses not using all variables specified in an
iterator is also changed. It is now made into a warning when detected
instead of an error, and the iterator is trimmed to exclude the unused
variables. If no variables are used then the iterator is removed
entirely. If an iterator is shared between multiple clauses with
different sets of variables used, then the iterator is unshared and
trimmed accordingly.
- [PATCH v4 0/5] openmp: Add support for iterators in Open... Kwok Cheung Yeung
-