On Fri, Oct 11, 2024 at 04:59:27PM +0200, Jakub Jelinek wrote: > E.g. it would be IMHO fine if the gimplification is done in a similar way > how we do OMP_CLAUSE_REDUCTION_{INIT,MERGE} gimplification into > &OMP_CLAUSE_REDUCTION_GIMPLE_{INIT,MERGE}, instead of gimplifying the > map clause expression into a sequence pushed before the target construct > gimplify it into a gimple_seq operand of the clause, if needed with some > placeholder in it (I'd assume placeholder would be in this case the > iterator). Then at omp lowering time one can just emit a loop and > in the body of the loop just copy the gimple seq from the clause, which the > placeholder set to the loop iterator.
To expand more on why this is essential, gimplification performs an important part of the OpenMP handling, among others discovery of implicit OpenMP clauses. So, if one bypasses gimplification of some expression, that part isn't performed, so it would need to be duplicated later. Consider: int bar (int, int); void baz (int, int *); #pragma omp declare target enter (baz) void foo (int x, int *p) { #pragma omp parallel #pragma omp master #pragma omp target map (to, iterator (i = 0 : 4) : p[bar (x, i)]) baz (x, p); } If p[bar (x, i)] isn't gimplified during gimplification, then nothing will add the needed implicit firstprivate (x) clause on the parallel and it will ICE. Jakub