[clang] [OpenMP] Add variable capture support for transparent clause expression. (PR #185419)
Abhinav Gaba via cfe-commits
cfe-commits at lists.llvm.org
Wed Mar 11 14:46:28 PDT 2026
================
@@ -39,78 +41,132 @@ void TestTaskTransparent() {
}
#endif
-
// CHECK: FunctionDecl {{.*}} TestTaskTransparent 'void ()'
// CHECK: OMPTaskDirective
// CHECK-NEXT: OMPTransparentClause
-// CHECK-NEXT: ImplicitCastExpr {{.*}} 'omp_impex_t':'void **' <LValueToRValue>
// CHECK-NEXT: DeclRefExpr {{.*}} 'const omp_impex_t':'void **const' lvalue Var {{.*}} 'omp_not_impex' 'const omp_impex_t':'void **const'
// CHECK-NEXT: OMPFirstprivateClause
// CHECK-NEXT: DeclRefExpr {{.*}} 'omp_impex_t':'void **' lvalue Var {{.*}} 'imp' 'omp_impex_t':'void **' refers_to_enclosing_variable_or_capture
+// CHECK-NEXT: DeclRefExpr {{.*}} 'int' lvalue Var {{.*}} 'a' 'int' refers_to_enclosing_variable_or_capture
// CHECK-NEXT: CapturedStmt
// CHECK: OMPTaskDirective
// CHECK-NEXT: OMPTransparentClause
-// CHECK-NEXT: ImplicitCastExpr {{.*}} 'omp_impex_t':'void **' <LValueToRValue>
// CHECK-NEXT: DeclRefExpr {{.*}} 'omp_impex_t':'void **' lvalue Var {{.*}} 'imp' 'omp_impex_t':'void **' refers_to_enclosing_variable_or_capture
+// CHECK-NEXT: OMPFirstprivateClause
+// CHECK-NEXT: DeclRefExpr {{.*}} 'int' lvalue Var {{.*}} 'a' 'int' refers_to_enclosing_variable_or_capture
----------------
abhinavgaba wrote:
`load i32, ptr %a` should happen before scheduling the task, so there is no need to imply `firstprivate(a)` on a task on which `transparent(a)` is present.
The implicit reference should only affect the outer constructs. So if we had:
```c
#pragma omp task // (1)
{
#pragma omp task transparent(a) // (2)
{...}
}
```
The "implcit reference" should cause an implicit `firstprivate(a)` on the outer task `(1)`, not the inner task `(2)`.
https://github.com/llvm/llvm-project/pull/185419
More information about the cfe-commits
mailing list