As far as I recall, [flang][OpenMP] Handle pre-detemined `lastprivate` for `simd` by ergawy · Pull Request #129507 · llvm/llvm-project · GitHub was trying to solve the problem of attaching a clause on a composite construct to one or more of the leaf constructs or attaching the clause to the wrong leaf in the construct.
19.2 Clauses on Compound Constructs
….
The effect of the lastprivate clause is as if it is applied to all leaf constructs that permit the
clause.
In that particular case, we were attaching lastprivate to the wrong leaf (parallel) rather the leaf to which it applies (simd).
I am not sure this is actually a bug. I know it violates restrictions of loop wrappers but I am wondering if the restriction should be imposed. At the time of working on that PR, I think I forgot about that restriction.
No changes were done by me at least to suppress any verifier errors.
@tblah Maybe another solution would be to do something similar to llvm-project/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp at 56ad5241c90567bda0484ccea9cd1fd8030029af · llvm/llvm-project · GitHub on the outlined fuction for the taskloop? However, this might be more difficult given that post-dominance does not apply here.