[flang-commits] [flang] [flang][OpenMP] Fix firstprivate not working with lastprivate in DO SIMD (PR #170163)
Tom Eccles via flang-commits
flang-commits at lists.llvm.org
Mon Dec 1 09:17:53 PST 2025
https://github.com/tblah commented:
I'm not sure about your interpretation of the spec. There is no firstprivate clause for the simd construct so the firstprivate cannot apply to the simd. Running flang without your patch it looks like we correctly apply firstprivate and lastprivate to the wsloop but only lastprivate to simd.
This results in LLVM codegen where there are three private variables: the firstprivate copy of a for `omp do` - this is unused and would be removed by the optimizer; the private copy of `a` used in the body of `omp simd`; and the private copy of the loop iteration variable. As you observed, this means that the value of `a` inside the loop is uninitialized memory.
If this is a bug then I think the bug is that there are two completely separate declarations and memory for `a`. This is still visible in your lit test.
https://github.com/llvm/llvm-project/pull/170163
More information about the flang-commits
mailing list