llvmbot wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Zahira Ammarguellat (zahiraam)

<details>
<summary>Changes</summary>

This patch extends the `transparent` clause implementation to properly handle 
runtime variable expressions as the `impex-type` argument, as required by the 
OpenMP specification:
`"The use of a variable in an impex-type expression causes an implicit 
reference to the variable in all enclosing constructs. The impex-type 
expression is evaluated in the context outside of the construct on which the 
clause appears."`

---

Patch is 39.01 KiB, truncated to 20.00 KiB below, full version: 
https://github.com/llvm/llvm-project/pull/185419.diff


6 Files Affected:

- (modified) clang/include/clang/AST/OpenMPClause.h (+13-8) 
- (modified) clang/lib/AST/OpenMPClause.cpp (+2-1) 
- (modified) clang/lib/Sema/SemaOpenMP.cpp (+33-15) 
- (modified) clang/test/OpenMP/task_transparent_messages.cpp (+4-4) 
- (modified) clang/test/OpenMP/task_transparent_serialization.cpp (+72-16) 
- (modified) clang/test/OpenMP/taskloop_codegen.cpp (+142-101) 


``````````diff
diff --git a/clang/include/clang/AST/OpenMPClause.h 
b/clang/include/clang/AST/OpenMPClause.h
index e6b9c47a90c76..af5d3f4698eda 100644
--- a/clang/include/clang/AST/OpenMPClause.h
+++ b/clang/include/clang/AST/OpenMPClause.h
@@ -1506,7 +1506,9 @@ class OMPThreadsetClause final : public OMPClause {
 /// clause with OpenMP keyword 'omp_not_impex`. Other valid keywords that may
 /// appear in this clause are 'omp_import', 'omp_export' and 'omp_impex'.
 ///
-class OMPTransparentClause final : public OMPClause {
+class OMPTransparentClause final
+    : public OMPOneStmtClause<llvm::omp::OMPC_transparent, OMPClause>,
+      public OMPClauseWithPreInit {
   friend class OMPClauseReader;
 
   /// Location of '('.
@@ -1530,15 +1532,18 @@ class OMPTransparentClause final : public OMPClause {
   /// \param StartLoc Starting location of the clause.
   /// \param LParenLoc Location of '('.
   /// \param EndLoc Ending location of the clause.
-  OMPTransparentClause(Expr *ImpexTypeKind, SourceLocation StartLoc,
-                       SourceLocation LParenLoc, SourceLocation EndLoc)
-      : OMPClause(llvm::omp::OMPC_transparent, StartLoc, EndLoc),
-        LParenLoc(LParenLoc), ImpexType(ImpexTypeKind) {}
+  OMPTransparentClause(Expr *ImpexTypeKind, Stmt *HelperValStmt,
+                       OpenMPDirectiveKind CaptureRegion,
+                       SourceLocation StartLoc, SourceLocation LParenLoc,
+                       SourceLocation EndLoc)
+      : OMPOneStmtClause(ImpexTypeKind, StartLoc, LParenLoc, EndLoc),
+        OMPClauseWithPreInit(this), LParenLoc(LParenLoc),
+        ImpexType(ImpexTypeKind) {
+    setPreInitStmt(HelperValStmt, CaptureRegion);
+  }
 
   /// Build an empty clause.
-  OMPTransparentClause()
-      : OMPClause(llvm::omp::OMPC_transparent, SourceLocation(),
-                  SourceLocation()) {}
+  OMPTransparentClause() : OMPOneStmtClause(), OMPClauseWithPreInit(this) {}
 
   /// Returns the location of '('.
   SourceLocation getLParenLoc() const { return LParenLoc; }
diff --git a/clang/lib/AST/OpenMPClause.cpp b/clang/lib/AST/OpenMPClause.cpp
index 48ec1551d0607..d4826c3c6edca 100644
--- a/clang/lib/AST/OpenMPClause.cpp
+++ b/clang/lib/AST/OpenMPClause.cpp
@@ -109,6 +109,8 @@ const OMPClauseWithPreInit *OMPClauseWithPreInit::get(const 
OMPClause *C) {
     return static_cast<const OMPDynGroupprivateClause *>(C);
   case OMPC_message:
     return static_cast<const OMPMessageClause *>(C);
+  case OMPC_transparent:
+    return static_cast<const OMPTransparentClause *>(C);
   case OMPC_default:
   case OMPC_proc_bind:
   case OMPC_safelen:
@@ -127,7 +129,6 @@ const OMPClauseWithPreInit *OMPClauseWithPreInit::get(const 
OMPClause *C) {
   case OMPC_untied:
   case OMPC_mergeable:
   case OMPC_threadset:
-  case OMPC_transparent:
   case OMPC_threadprivate:
   case OMPC_groupprivate:
   case OMPC_flush:
diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index f69938c31adfa..16397e4353c98 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -17494,25 +17494,38 @@ OMPClause 
*SemaOpenMP::ActOnOpenMPThreadsetClause(OpenMPThreadsetKind Kind,
       OMPThreadsetClause(Kind, KindLoc, StartLoc, LParenLoc, EndLoc);
 }
 
-static OMPClause *createTransparentClause(Sema &SemaRef, ASTContext &Ctx,
-                                          Expr *ImpexTypeArg,
-                                          SourceLocation StartLoc,
-                                          SourceLocation LParenLoc,
-                                          SourceLocation EndLoc) {
+static OMPClause *
+createTransparentClause(Sema &SemaRef, ASTContext &Ctx, Expr *ImpexTypeArg,
+                        Stmt *HelperValStmt, OpenMPDirectiveKind CaptureRegion,
+                        SourceLocation StartLoc, SourceLocation LParenLoc,
+                        SourceLocation EndLoc) {
   ExprResult ER = SemaRef.DefaultLvalueConversion(ImpexTypeArg);
   if (ER.isInvalid())
     return nullptr;
 
-  return new (Ctx) OMPTransparentClause(ER.get(), StartLoc, LParenLoc, EndLoc);
+  return new (Ctx) OMPTransparentClause(ER.get(), HelperValStmt, CaptureRegion,
+                                        StartLoc, LParenLoc, EndLoc);
 }
 
 OMPClause *SemaOpenMP::ActOnOpenMPTransparentClause(Expr *ImpexTypeArg,
                                                     SourceLocation StartLoc,
                                                     SourceLocation LParenLoc,
                                                     SourceLocation EndLoc) {
+  Stmt *HelperValStmt = nullptr;
+  OpenMPDirectiveKind DKind = DSAStack->getCurrentDirective();
+  OpenMPDirectiveKind CaptureRegion = getOpenMPCaptureRegionForClause(
+      DKind, OMPC_transparent, getLangOpts().OpenMP);
+  if (CaptureRegion != OMPD_unknown &&
+      !SemaRef.CurContext->isDependentContext()) {
+    Expr *ValExpr = SemaRef.MakeFullExpr(ImpexTypeArg).get();
+    llvm::MapVector<const Expr *, DeclRefExpr *> Captures;
+    ValExpr = tryBuildCapture(SemaRef, ValExpr, Captures).get();
+    HelperValStmt = buildPreInits(getASTContext(), Captures);
+  }
   if (!ImpexTypeArg) {
     return new (getASTContext())
-        OMPTransparentClause(ImpexTypeArg, StartLoc, LParenLoc, EndLoc);
+        OMPTransparentClause(ImpexTypeArg, HelperValStmt, CaptureRegion,
+                             StartLoc, LParenLoc, EndLoc);
   }
   QualType Ty = ImpexTypeArg->getType();
 
@@ -17527,14 +17540,15 @@ OMPClause 
*SemaOpenMP::ActOnOpenMPTransparentClause(Expr *ImpexTypeArg,
           << TypedefName;
       return nullptr;
     }
-    return createTransparentClause(SemaRef, getASTContext(), ImpexTypeArg,
-                                   StartLoc, LParenLoc, EndLoc);
+    return new (getASTContext())
+        OMPTransparentClause(ImpexTypeArg, HelperValStmt, CaptureRegion,
+                             StartLoc, LParenLoc, EndLoc);
   }
 
   if (Ty->isEnumeralType())
     return createTransparentClause(SemaRef, getASTContext(), ImpexTypeArg,
-                                   StartLoc, LParenLoc, EndLoc);
-
+                                   HelperValStmt, CaptureRegion, StartLoc,
+                                   LParenLoc, EndLoc);
   if (Ty->isIntegerType()) {
     if (isNonNegativeIntegerValue(ImpexTypeArg, SemaRef, OMPC_transparent,
                                   /*StrictlyPositive=*/false)) {
@@ -17548,12 +17562,16 @@ OMPClause 
*SemaOpenMP::ActOnOpenMPTransparentClause(Expr *ImpexTypeArg,
                 static_cast<int64_t>(SemaOpenMP::OpenMPImpexType::OMP_Export))
           SemaRef.Diag(StartLoc, diag::err_omp_transparent_invalid_value);
       }
-      return createTransparentClause(SemaRef, getASTContext(), ImpexTypeArg,
-                                     StartLoc, LParenLoc, EndLoc);
+      return new (getASTContext())
+          OMPTransparentClause(ImpexTypeArg, HelperValStmt, CaptureRegion,
+                               StartLoc, LParenLoc, EndLoc);
     }
   }
-  SemaRef.Diag(StartLoc, diag::err_omp_transparent_invalid_type) << Ty;
-  return nullptr;
+  if (!isNonNegativeIntegerValue(ImpexTypeArg, SemaRef, OMPC_transparent,
+                                 /*StrictlyPositive=*/true))
+    return nullptr;
+  return new (getASTContext()) OMPTransparentClause(
+      ImpexTypeArg, HelperValStmt, CaptureRegion, StartLoc, LParenLoc, EndLoc);
 }
 
 OMPClause *SemaOpenMP::ActOnOpenMPProcBindClause(ProcBindKind Kind,
diff --git a/clang/test/OpenMP/task_transparent_messages.cpp 
b/clang/test/OpenMP/task_transparent_messages.cpp
index a58df6ba2a77b..8ad90fc80310f 100644
--- a/clang/test/OpenMP/task_transparent_messages.cpp
+++ b/clang/test/OpenMP/task_transparent_messages.cpp
@@ -31,13 +31,13 @@ void TestTaskTransparentWithErrors() {
 #pragma omp task transparent(omp_impex)
   // expected-error@+1{{invalid value for transparent clause, expected one of: 
omp_not_impex, omp_import, omp_export, omp_impex}}
 #pragma omp task transparent(5)
-  // expected-error@+1{{transparent clause cannot be applied to type: 'int *'}}
+  // expected-error@+1{{expression must have integral or unscoped enumeration 
type, not 'int *'}}
 #pragma omp task transparent(ptr)
-  // expected-error@+1{{transparent clause cannot be applied to type: 'int *'}}
+  // expected-error@+1{{expression must have integral or unscoped enumeration 
type, not 'int *'}}
 #pragma omp task transparent(&x)
-  // expected-error@+1{{transparent clause cannot be applied to type: 
'double'}}
+  // expected-error@+1{{expression must have integral or unscoped enumeration 
type, not 'double'}}
 #pragma omp task transparent(20.0)
-  // expected-error@+1{{transparent clause cannot be applied to type: 
'int[5]'}}
+  // expected-error@+1{{expression must have integral or unscoped enumeration 
type, not 'int[5]'}}
 #pragma omp task transparent(arr)
   for (int i = 0; i < 5; ++i) {}
 }
diff --git a/clang/test/OpenMP/task_transparent_serialization.cpp 
b/clang/test/OpenMP/task_transparent_serialization.cpp
index 110bd608b41ab..9e8313c614f6e 100644
--- a/clang/test/OpenMP/task_transparent_serialization.cpp
+++ b/clang/test/OpenMP/task_transparent_serialization.cpp
@@ -25,6 +25,8 @@ void TestTaskTransparent() {
   omp_impex_t imp;
 #pragma omp task transparent(omp_not_impex)
 #pragma omp task transparent(imp)
+#pragma omp task transparent(a)
+#pragma omp task transparent(a+1)
 
 #pragma omp parallel
   {
@@ -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
+// CHECK-NEXT: CapturedStmt
+// CHECK: OMPTaskDirective
+// CHECK-NEXT: OMPTransparentClause
+// CHECK-NEXT: ImplicitCastExpr {{.*}} 'int' <LValueToRValue>
+// CHECK-NEXT: DeclRefExpr {{.*}} 'int' lvalue Var {{.*}} 'a' 'int' 
refers_to_enclosing_variable_or_capture
+// CHECK-NEXT: OMPFirstprivateClause
+// CHECK-NEXT: DeclRefExpr {{.*}} 'int' lvalue Var {{.*}} 'a' 'int' 
refers_to_enclosing_variable_or_capture
+// CHECK-NEXT: CapturedStmt
+// CHECK-NEXT: CapturedDecl
+// CHECK: OMPTaskDirective
+// CHECK-NEXT: OMPTransparentClause
+// CHECK-NEXT: BinaryOperator {{.*}} 'int' '+'
+// CHECK-NEXT: ImplicitCastExpr {{.*}} <col:30> 'int' <LValueToRValue>
+// CHECK-NEXT: DeclRefExpr {{.*}} 'int' lvalue Var {{.*}} 'a' 'int' 
refers_to_enclosing_variable_or_capture
+// CHECK-NEXT: IntegerLiteral {{.*}} <col:32> 'int' 1
+// CHECK-NEXT: CapturedStmt
+// CHEC-NEXT: CapturedDecl
+// CHECK: OMPTaskLoopDirective
+// CHECK-NEXT: OMPTransparentClause
+// CHECK-NEXT: DeclRefExpr {{.*}} 'const omp_impex_t':'void **const' lvalue 
Var {{.*}} 'omp_impex' 'const omp_impex_t':'void **const'
 // CHECK-NEXT: CapturedStmt
-// CHECK:  OMPTaskDirective
+// CHECK: OMPTaskLoopDirective
+// CHECK-NEXT:  OMPTransparentClause
+// CHECK-NEXT: DeclRefExpr {{.*}} 'const omp_impex_t':'void **const' lvalue 
Var {{.*}} 'omp_impex' 'const omp_impex_t':'void **const'
+// CHECK-NEXT: CapturedStmt
+// CHECK: OMPTaskDirective
+// CHECK-NEXT: OMPTransparentClause
+// CHECK-NEXT: DeclRefExpr {{.*}} 'const omp_impex_t':'void **const' lvalue 
Var {{.*}} 'omp_export' 'const omp_impex_t':'void **const'
+// CHECK-NEXT: CapturedStmt
+// CHECK: OMPTaskLoopDirective
+// CHECK-NEXT: OMPTransparentClause
+// CHECK-NEXT: DeclRefExpr {{.*}} 'const omp_impex_t':'void **const' lvalue 
Var {{.*}} 'omp_impex' 'const omp_impex_t':'void **const'
+// CHECK-NEXT: CapturedStmt
+// CHECK: OMPTaskLoopDirective
+// CHECK-NEXT: OMPTransparentClause
+// CHECK-NEXT: DeclRefExpr {{.*}} 'const omp_impex_t':'void **const' lvalue 
Var {{.*}} 'omp_impex' 'const omp_impex_t':'void **const'
+// CHECK: CapturedStmt
+// 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_export' 'const omp_impex_t':'void **const'
 // CHECK-NEXT: CapturedStmt
 // CHECK: OMPTaskLoopDirective
 // CHECK-NEXT: OMPTransparentClause
-// CHECK-NEXT: ImplicitCastExpr {{.*}} 'omp_impex_t':'void **' <LValueToRValue>
 // CHECK-NEXT: DeclRefExpr {{.*}} 'const omp_impex_t':'void **const' lvalue 
Var {{.*}} 'omp_impex' 'const omp_impex_t':'void **const'
 // CHECK-NEXT: CapturedStmt
 // CHECK: OMPTaskLoopDirective
 // CHECK-NEXT: OMPTransparentClause
-// CHECK-NEXT: ImplicitCastExpr {{.*}} 'omp_impex_t':'void **' <LValueToRValue>
 // CHECK-NEXT: DeclRefExpr {{.*}} 'const omp_impex_t':'void **const' lvalue 
Var {{.*}} 'omp_impex' 'const omp_impex_t':'void **const'
 // CHECK-NEXT: CapturedStmt
 // 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_export' 'const omp_impex_t':'void **const'
 // CHECK-NEXT: CapturedStmt
 // CHECK: OMPTaskLoopDirective
 // CHECK-NEXT: OMPTransparentClause
-// CHECK-NEXT: ImplicitCastExpr {{.*}} 'omp_impex_t':'void **' <LValueToRValue>
 // CHECK-NEXT: DeclRefExpr {{.*}} 'const omp_impex_t':'void **const' lvalue 
Var {{.*}} 'omp_impex' 'const omp_impex_t':'void **const'
 // CHECK-NEXT: CapturedStmt
 // CHECK: OMPTaskLoopDirective
 // CHECK-NEXT: OMPTransparentClause
-// CHECK-NEXT: ImplicitCastExpr {{.*}} 'omp_impex_t':'void **' <LValueToRValue>
 // CHECK-NEXT: DeclRefExpr {{.*}} 'const omp_impex_t':'void **const' lvalue 
Var {{.*}} 'omp_impex' 'const omp_impex_t':'void **const'
 // CHECK-NEXT: CapturedStmt
 // CHECK: OMPTaskDirective
 // CHECK-NEXT: OMPTransparentClause
-// CHECK-NEXT: ImplicitCastExpr {{.*}} 'omp_impex_t':'void **' <LValueToRValue>
+// CHECK-NEXT: BinaryOperator {{.*}} 'int' '+'
+// CHECK-NEXT: ImplicitCastExpr {{.*}} 'int' <LValueToRValue>
+// CHECK-NEXT: DeclRefExpr {{.*}} 'int' lvalue Var {{.*}} 'a' 'int' 
refers_to_enclosing_variable_or_capture
+// CHECK-NEXT: IntegerLiteral {{.*}} <col:32> 'int' 1
+// CHECK-NEXT: CapturedStmt
+// CHECK: OMPTaskDirective
+// CHECK-NEXT: OMPTransparentClause
+// CHECK-NEXT: DeclRefExpr{{.*}} 'const omp_impex_t':'void **const' lvalue Var 
{{.*}} 'omp_export' 'const omp_impex_t':'void **const'
+/// CHECK-NEXT: CapturedStmt
+// CHECK: OMPTaskLoopDirective
+// CHECK-NEXT: OMPTransparentClause
+// CHECK-NEXT: DeclRefExpr {{.*}} 'const omp_impex_t':'void **const' lvalue 
Var {{.*}} 'omp_impex' 'const omp_impex_t':'void **const'
+// CHECK-NEXT: CapturedStmt
+// CHECK: OMPTaskLoopDirective
+// CHECK-NEXT: OMPTransparentClause
+// CHECK-NEXT: DeclRefExpr {{.*}} 'const omp_impex_t':'void **const' lvalue 
Var {{.*}} 'omp_impex' 'const omp_impex_t':'void **const'
+// CHECK-NEXT: CapturedStmt
+// CHECK: OMPTaskDirective
+// CHECK-NEXT: OMPTransparentClause
 // CHECK-NEXT: DeclRefExpr {{.*}} 'const omp_impex_t':'void **const' lvalue 
Var {{.*}} 'omp_export' 'const omp_impex_t':'void **const'
 // CHECK-NEXT: CapturedStmt
 // CHECK: OMPTaskLoopDirective
 // CHECK-NEXT: OMPTransparentClause
-// CHECK-NEXT: ImplicitCastExpr {{.*}} 'omp_impex_t':'void **' <LValueToRValue>
 // CHECK-NEXT: DeclRefExpr {{.*}} 'const omp_impex_t':'void **const' lvalue 
Var {{.*}} 'omp_impex' 'const omp_impex_t':'void **const'
 // CHECK-NEXT: CapturedStmt
 // CHECK: OMPTaskLoopDirective
 // CHECK-NEXT: OMPTransparentClause
-// CHECK-NEXT: ImplicitCastExpr {{.*}} 'omp_impex_t':'void **' <LValueToRValue>
 // CHECK-NEXT: DeclRefExpr {{.*}} 'const omp_impex_t':'void **const' lvalue 
Var {{.*}} 'omp_impex' 'const omp_impex_t':'void **const'
 // CHECK-NEXT: CapturedStmt
 // 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_export' 'const omp_impex_t':'void **const'
 // CHECK-NEXT: CapturedStmt
 // CHECK: OMPTaskLoopDirective
 // CHECK-NEXT: OMPTransparentClause
-// CHECK-NEXT: ImplicitCastExpr {{.*}} 'omp_impex_t':'void **' <LValueToRValue>
 // CHECK-NEXT: DeclRefExpr {{.*}} 'const omp_impex_t':'void **const' lvalue 
Var {{.*}} 'omp_impex' 'const omp_impex_t':'void **const'
 // CHECK-NEXT: CapturedStmt
 // CHECK: OMPTaskLoopDirective
 // CHECK-NEXT: OMPTransparentClause
-// CHECK-NEXT: ImplicitCastExpr {{.*}} 'omp_impex_t':'void **' <LValueToRValue>
+// CHECK-NEXT: DeclRefExpr {{.*}} 'const omp_impex_t':'void **const' lvalue 
Var {{.*}} 'omp_impex' 'const omp_impex_t':'void **const'
+// CHECK-NEXT: CapturedStmt
+// CHECK: OMPTaskDirective
+// CHECK-NEXT: OMPTransparentClause
+// CHECK-NEXT: DeclRefExpr {{.*}} 'const omp_impex_t':'void **const' lvalue 
Var {{.*}} 'omp_export' 'const omp_impex_t':'void **const'
+// CHECK: OMPTaskLoopDirective
+// CHECK-NEXT: OMPTransparentClause
+// CHECK-NEXT: DeclRefExpr {{.*}} 'const omp_impex_t':'void **const' lvalue 
Var {{.*}} 'omp_impex' 'const omp_impex_t':'void **const'
+// CHECK-NEXT: CapturedStmt
+// CHECK: OMPTaskLoopDirective
+// CHECK-NEXT: OMPTransparentClause
 // CHECK-NEXT: DeclRefExpr {{.*}} 'const omp_impex_t':'void **const' lvalue 
Var {{.*}} 'omp_impex' 'const omp_impex_t':'void **const'
 // CHECK-NEXT: CapturedStmt
 
diff --git a/clang/test/OpenMP/taskloop_codegen.cpp 
b/clang/test/OpenMP/taskloop_codegen.cpp
index b5bbf6e259c35..f401da5c791e9 100644
--- a/clang/test/OpenMP/taskloop_codegen.cpp
+++ b/clang/test/OpenMP/taskloop_codegen.cpp
@@ -265,6 +265,7 @@ void test_threadset()
 
 void test_transparent()
 {
+  int a;
 #pragma omp taskloop transparent priority(10)
   for (int i = 0; i < 10; ++i) {
   }
@@ -283,6 +284,12 @@ void test_transparent()
 #pragma omp taskloop transparent(omp_impex)
   for (int i = 0; i < 10; ++i) {
   }
+#pragma omp taskloop transparent(a)
+  for (int i = 0; i < 10; ++i) {
+  }
+#pragma omp taskloop transparent(a+1)
+  for (int i = 0; i < 10; ++i) {
+  }
 }
 
 #endif // OMP60
@@ -323,107 +330,141 @@ void test_transparent()
 // CHECK6-NEXT:       call void @__kmpc_end_taskgroup(ptr @1, i32 %[[TID0:.*]])
 // CHECK6-NEXT:       ret void
 
-// CHECK6: define void @_Z16test_transparentv
-// CHECK6: entry:
-// CHECK6:  [[AGG_CAPTURED:%.*]] = alloca [[STRUCT_ANON_18:%.*]], align 1
-// CHECK6:  [[TMP:%.*]] = alloca i32, align 4
-// CHECK6:  [[AGG_CAPTURED1:%.*]] = alloca [[STRUCT_ANON_20:%.*]], align 1
-// CHECK6:  [[TMP2:%.*]] = alloca i32, align 4
-// CHECK6:  [[AGG_CAPTURED3:%.*]] = alloca [[STRUCT_ANON_22:%.*]], align 1
-// CHECK6:  [[TMP4:%.*]] = alloca i32, align 4
-// CHECK6:  [[AGG_CAPTURED5:%.*]] = alloca [[STRUCT_ANON_24:%.*]], align 1
-// CHECK6:  [[TMP6:%.*]] = alloca i32, align 4
-// CHECK6:  [[AGGD_CAPTURED9:%.*]] = alloca [[STRUCT_ANON_28:%.*]], align 1
-// CHECK6:  [[TMP10:%.*]] = alloca i32, align 4
-// CHECK6:  [[TMP0:%.*]] = call i32 @__kmpc_global_thread_num(ptr @1)
-// CHECK6:  call void @__kmpc_taskgroup(ptr @1, i32 [[TMP0]])
-// CHECK6:  [[TMP1:%.*]] = call ptr @__kmpc_omp_task_alloc(ptr @1, i32 
[[TMP0]], i32 289, i64 80, i64 1, ptr @.omp_task_entry..[[ENTRY1:[0-9]+]])
-// CHECK6:  [[TMP2:%.*]] = getelementptr inbounds nuw 
%struct.kmp_task_t_with_privates{{.*}}, ptr [[TMP1]], i32 0, i32 0
-// CHECK6:  [[TMP3:%.*]] = getelementptr inbounds nuw 
%struct.kmp_task_t{{.*}}, ptr [[TMP2]], i32 0, i32 4
-// CHECK6:  store i32 10, ptr [[TMP3]], align 8
-// CHECK6:  [[TMP4:%.*]] = getelementptr inbounds nuw %struct.kmp_task_t.2, 
ptr [[TMP2]], i32 0, i32 5
-// CHECK6:  store i64 0, ptr [[TMP4]], align 8
-// CHECK6:  [[TMP5:%.*]] = getelementptr inbounds nuw 
%struct.kmp_task_t{{.*}}, ptr [[TMP2]], i32 0, i32 6
-// ...
[truncated]

``````````

</details>


https://github.com/llvm/llvm-project/pull/185419
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to