[llvm-branch-commits] [clang] [llvm] [clang][OpenMP] Emit lastprivate final copies in no-loop kernels (PR #224045)

Dhruva Chakrabarti via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Sun Nov 1 00:02:58 PDT 2026


================
@@ -72,6 +72,48 @@ int main(void) {
   if (red != 1024)
     ++errors;
 
+  // No-loop kernel with a lastprivate variable (final value from thread executing last iteration)
+  for (int i = 0; i < 1024; ++i)
+    array[i] = 1;
+
+  int last = -1;
+#pragma omp target teams distribute parallel for lastprivate(last)
+  for (int i = 0; i < 1024; ++i) {
+    array[i] = i + 1;
+    last = i;
+  }
+  errors += check_errors(array);
+#ifdef ASSERT_LASTPRIVATE
----------------
dhruvachak wrote:

I would prefer adding the explicit map tofrom. That way, we would have more coverage for the lastprivate codepath in this PR.

https://github.com/llvm/llvm-project/pull/224045


More information about the llvm-branch-commits mailing list