[clang] [OpenMP][Clang] Support transparent clause with no argument provided. (PR #177684)
Zahira Ammarguellat via cfe-commits
cfe-commits at lists.llvm.org
Mon Feb 2 09:50:23 PST 2026
https://github.com/zahiraam updated https://github.com/llvm/llvm-project/pull/177684
>From a8c26d3a4fc030742349d8785259347f76f7978e Mon Sep 17 00:00:00 2001
From: Zahira Ammarguellat <zahira.ammarguellat at intel.com>
Date: Fri, 23 Jan 2026 13:38:50 -0800
Subject: [PATCH 1/5] [OpenMP][Clang] Support transparent clause with implicit
omp_impex when no argument is provided
---
clang/lib/AST/OpenMPClause.cpp | 5 ++++-
clang/lib/Parse/ParseOpenMP.cpp | 9 ++++++++-
clang/lib/Sema/SemaOpenMP.cpp | 4 ++++
clang/test/OpenMP/task_ast_print.cpp | 9 +++------
clang/test/OpenMP/task_codegen.cpp | 8 ++++++++
clang/test/OpenMP/taskloop_ast_print.cpp | 12 ++++++++----
clang/test/OpenMP/taskloop_codegen.cpp | 3 +++
7 files changed, 38 insertions(+), 12 deletions(-)
diff --git a/clang/lib/AST/OpenMPClause.cpp b/clang/lib/AST/OpenMPClause.cpp
index 62d78660570de..9e7a8a48372c7 100644
--- a/clang/lib/AST/OpenMPClause.cpp
+++ b/clang/lib/AST/OpenMPClause.cpp
@@ -2057,7 +2057,10 @@ void OMPClausePrinter::VisitOMPThreadsetClause(OMPThreadsetClause *Node) {
void OMPClausePrinter::VisitOMPTransparentClause(OMPTransparentClause *Node) {
OS << "transparent(";
- Node->getImpexType()->printPretty(OS, nullptr, Policy, 0);
+ if (Node->getImpexType())
+ Node->getImpexType()->printPretty(OS, nullptr, Policy, 0);
+ else
+ OS << "omp_impex";
OS << ")";
}
diff --git a/clang/lib/Parse/ParseOpenMP.cpp b/clang/lib/Parse/ParseOpenMP.cpp
index ec62df83a203e..b7f2af9ca7b1f 100644
--- a/clang/lib/Parse/ParseOpenMP.cpp
+++ b/clang/lib/Parse/ParseOpenMP.cpp
@@ -3213,7 +3213,14 @@ OMPClause *Parser::ParseOpenMPClause(OpenMPDirectiveKind DKind,
<< getOpenMPClauseName(CKind) << 0;
ErrorFound = true;
}
-
+ const Token CurTok = PP.LookAhead(0);
+ if (CKind == OMPC_transparent && CurTok.is(tok::annot_pragma_openmp_end)) {
+ SourceLocation Loc = ConsumeToken();
+ SourceLocation LLoc = Tok.getLocation();
+ Clause = Actions.OpenMP().ActOnOpenMPTransparentClause(nullptr, LLoc,
+ LLoc, Loc);
+ break;
+ }
if ((CKind == OMPC_ordered || CKind == OMPC_partial) &&
PP.LookAhead(/*N=*/0).isNot(tok::l_paren))
Clause = ParseOpenMPClause(CKind, WrongDirective);
diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index 084abaf487bb8..55ebcb69cc8c7 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -17476,6 +17476,10 @@ OMPClause *SemaOpenMP::ActOnOpenMPTransparentClause(Expr *ImpexTypeArg,
SourceLocation StartLoc,
SourceLocation LParenLoc,
SourceLocation EndLoc) {
+ if (!ImpexTypeArg) {
+ return new (getASTContext())
+ OMPTransparentClause(ImpexTypeArg, StartLoc, LParenLoc, EndLoc);
+ }
QualType Ty = ImpexTypeArg->getType();
if (const auto *TT = Ty->getAs<TypedefType>()) {
diff --git a/clang/test/OpenMP/task_ast_print.cpp b/clang/test/OpenMP/task_ast_print.cpp
index 4c59a7c7fafa1..d7c1da3db537c 100644
--- a/clang/test/OpenMP/task_ast_print.cpp
+++ b/clang/test/OpenMP/task_ast_print.cpp
@@ -16,12 +16,6 @@
typedef void *omp_depend_t;
typedef unsigned long omp_event_handle_t;
-typedef void **omp_impex_t;
-extern const omp_impex_t omp_not_impex;
-extern const omp_impex_t omp_import;
-extern const omp_impex_t omp_export;
-extern const omp_impex_t omp_impex;
-
void foo() {}
struct S1 {
@@ -250,6 +244,7 @@ int main(int argc, char **argv) {
#pragma omp task threadset(omp_team)
foo();
+#pragma omp task transparent
#pragma omp task transparent(omp_not_impex)
#pragma omp task transparent(omp_import)
#pragma omp task transparent(omp_export)
@@ -273,9 +268,11 @@ int main(int argc, char **argv) {
// CHECK60: #pragma omp task transparent(omp_import)
// CHECK60: #pragma omp taskloop transparent(omp_impex)
// CHECK60: #pragma omp task transparent(omp_import)
+ // CHECK60: #pragma omp taskloop transparent(omp_impex)
// CHECK60: #pragma omp task threadset(omp_pool)
// CHECK60: #pragma omp task threadset(omp_team)
// CHECK60-NEXT: foo();
+ // CHECK60: #pragma omp task transparent(omp_impex)
// CHECK60: #pragma omp task transparent(omp_not_impex)
// CHECK60-NEXT: #pragma omp task transparent(omp_import)
// CHECK60-NEXT: #pragma omp task transparent(omp_export)
diff --git a/clang/test/OpenMP/task_codegen.cpp b/clang/test/OpenMP/task_codegen.cpp
index faa9c3dfbcf61..5483d690e50a2 100644
--- a/clang/test/OpenMP/task_codegen.cpp
+++ b/clang/test/OpenMP/task_codegen.cpp
@@ -240,6 +240,8 @@ void test_threadset()
void test_transparent()
{
+#pragma omp task transparent
+ {}
#pragma omp task transparent(omp_not_impex)
{}
#pragma omp task transparent(omp_import)
@@ -10308,6 +10310,7 @@ void test_transparent()
// CHECK6-NEXT: [[AGG_CAPTURED2:%.*]] = alloca [[STRUCT_ANON_29:%.*]], align 1
// CHECK6-NEXT: [[AGG_CAPTURED5:%.*]] = alloca [[STRUCT_ANON_31:%.*]], align 1
// CHECK6-NEXT: [[AGG_CAPTURED8:%.*]] = alloca [[STRUCT_ANON_33:%.*]], align 1
+// CHECK6-NEXT: [[AGG_CAPTURED11:%.*]] = alloca [[STRUCT_ANON_35:%.*]], align 1
// CHECK6-NEXT: [[V:%.*]] = alloca ptr, align 8
// CHECK6-NEXT: [[AGG_CAPTURED11:%.*]] = alloca [[STRUCT_ANON_35:%.*]], align 1
//CHECK6-NEXT: [[AGG_CAPTURED14:%.*]] = alloca [[STRUCT_ANON_37:%.*]], align 1
@@ -10348,5 +10351,10 @@ void test_transparent()
// CHECK6-NEXT: [[TMP19:%.*]] = getelementptr inbounds nuw %struct.kmp_task_t_with_privates{{.*}}, ptr [[TMP18]], i32 0, i32 0
// CHECK6-NEXT: [[OMP_GLOBAL_THREAD_NUM19:%.*]] = call i32 @__kmpc_global_thread_num(ptr @43)
// CHECK6-NEXT: [[TMP20:%.*]] = call i32 @__kmpc_omp_task(ptr @1, i32 [[OMP_GLOBAL_THREAD_NUM19]], ptr [[TMP18]])
+// CHECK6-NEXT: [[OMP_GLOBAL_THREAD_NUM21:%.*]] = call i32 @__kmpc_global_thread_num(ptr @45)
+// CHECK6-NEXT: [[TMP21:%.*]] = call ptr @__kmpc_omp_task_alloc(ptr @1, i32 [[OMP_GLOBAL_THREAD_NUM21]], i32 257, i64 40, i64 1, ptr @.omp_task_entry..[[ENTRY43:[0-9]+]])
+// CHECK6-NEXT: [[TMP22:%.*]] = getelementptr inbounds nuw %struct.kmp_task_t_with_privates{{.*}}, ptr [[TMP21]], i32 0, i32 0
+// CHECK6-NEXT: [[OMP_GLOBAL_THREAD_NUM22:%.*]] = call i32 @__kmpc_global_thread_num(ptr @45)
+// CHECK6-NEXT: [[TMP23:%.*]] = call i32 @__kmpc_omp_task(ptr @1, i32 [[OMP_GLOBAL_THREAD_NUM22]], ptr [[TMP21]])
// CHECK6-NEXT: ret void
// CHECK6-NEXT:}
diff --git a/clang/test/OpenMP/taskloop_ast_print.cpp b/clang/test/OpenMP/taskloop_ast_print.cpp
index 9bca586937347..e1d978cbd00d2 100644
--- a/clang/test/OpenMP/taskloop_ast_print.cpp
+++ b/clang/test/OpenMP/taskloop_ast_print.cpp
@@ -104,14 +104,17 @@ int main(int argc, char **argv) {
}
}
-#pragma omp taskloop transparent(omp_not_impex)
+#pragma omp taskloop transparent
for (int i = 0; i < 10; ++i) {
-#pragma omp task transparent(omp_import)
+#pragma omp taskloop transparent(omp_not_impex)
for (int i = 0; i < 10; ++i) {
-#pragma omp task transparent(omp_export)
+#pragma omp task transparent(omp_import)
for (int i = 0; i < 10; ++i) {
+#pragma omp task transparent(omp_export)
+ for (int i = 0; i < 10; ++i) {
#pragma omp task transparent(omp_impex)
- foo();
+ foo();
+ }
}
}
}
@@ -122,6 +125,7 @@ int main(int argc, char **argv) {
// CHECK60-NEXT: for (int j = 0; j < 10; ++j) {
// CHECK60-NEXT: foo();
+// CHECK60: #pragma omp taskloop transparent(omp_impex)
// CHECK60: #pragma omp taskloop transparent(omp_not_impex)
// CHECK60-NEXT: for (int i = 0; i < 10; ++i) {
// CHECK60-NEXT: #pragma omp task transparent(omp_import)
diff --git a/clang/test/OpenMP/taskloop_codegen.cpp b/clang/test/OpenMP/taskloop_codegen.cpp
index 9073a2376f5b4..a9e7da82bec48 100644
--- a/clang/test/OpenMP/taskloop_codegen.cpp
+++ b/clang/test/OpenMP/taskloop_codegen.cpp
@@ -265,6 +265,9 @@ void test_threadset()
void test_transparent()
{
+#pragma omp taskloop transparent
+ for (int i = 0; i < 10; ++i) {
+ }
#pragma omp taskloop transparent(omp_not_impex)
for (int i = 0; i < 10; ++i) {
}
>From 1186849f5199fafae88fab83d6e6bc25a2570446 Mon Sep 17 00:00:00 2001
From: Zahira Ammarguellat <zahira.ammarguellat at intel.com>
Date: Mon, 26 Jan 2026 06:54:01 -0800
Subject: [PATCH 2/5] Fix build error
---
clang/lib/Parse/ParseOpenMP.cpp | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/clang/lib/Parse/ParseOpenMP.cpp b/clang/lib/Parse/ParseOpenMP.cpp
index b7f2af9ca7b1f..d12c53ac82d45 100644
--- a/clang/lib/Parse/ParseOpenMP.cpp
+++ b/clang/lib/Parse/ParseOpenMP.cpp
@@ -3213,8 +3213,8 @@ OMPClause *Parser::ParseOpenMPClause(OpenMPDirectiveKind DKind,
<< getOpenMPClauseName(CKind) << 0;
ErrorFound = true;
}
- const Token CurTok = PP.LookAhead(0);
- if (CKind == OMPC_transparent && CurTok.is(tok::annot_pragma_openmp_end)) {
+ if (CKind == OMPC_transparent &&
+ PP.LookAhead(0).is(tok::annot_pragma_openmp_end)) {
SourceLocation Loc = ConsumeToken();
SourceLocation LLoc = Tok.getLocation();
Clause = Actions.OpenMP().ActOnOpenMPTransparentClause(nullptr, LLoc,
>From 359685c441bd790e2cd1bc39166914bb4a937bee Mon Sep 17 00:00:00 2001
From: Zahira Ammarguellat <zahira.ammarguellat at intel.com>
Date: Mon, 26 Jan 2026 11:15:41 -0800
Subject: [PATCH 3/5] Fix format
---
clang/lib/Parse/ParseOpenMP.cpp | 1 +
clang/test/OpenMP/taskloop_ast_print.cpp | 6 +++---
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/clang/lib/Parse/ParseOpenMP.cpp b/clang/lib/Parse/ParseOpenMP.cpp
index d12c53ac82d45..6946c27de9801 100644
--- a/clang/lib/Parse/ParseOpenMP.cpp
+++ b/clang/lib/Parse/ParseOpenMP.cpp
@@ -3213,6 +3213,7 @@ OMPClause *Parser::ParseOpenMPClause(OpenMPDirectiveKind DKind,
<< getOpenMPClauseName(CKind) << 0;
ErrorFound = true;
}
+
if (CKind == OMPC_transparent &&
PP.LookAhead(0).is(tok::annot_pragma_openmp_end)) {
SourceLocation Loc = ConsumeToken();
diff --git a/clang/test/OpenMP/taskloop_ast_print.cpp b/clang/test/OpenMP/taskloop_ast_print.cpp
index e1d978cbd00d2..7805620f845a3 100644
--- a/clang/test/OpenMP/taskloop_ast_print.cpp
+++ b/clang/test/OpenMP/taskloop_ast_print.cpp
@@ -111,10 +111,10 @@ int main(int argc, char **argv) {
#pragma omp task transparent(omp_import)
for (int i = 0; i < 10; ++i) {
#pragma omp task transparent(omp_export)
- for (int i = 0; i < 10; ++i) {
+ for (int i = 0; i < 10; ++i) {
#pragma omp task transparent(omp_impex)
- foo();
- }
+ foo();
+ }
}
}
}
>From 0fb09f628c3a2725de499c6fb680dfd4d7fc53e7 Mon Sep 17 00:00:00 2001
From: Zahira Ammarguellat <zahira.ammarguellat at intel.com>
Date: Tue, 27 Jan 2026 13:05:06 -0800
Subject: [PATCH 4/5] Addressed review comments
---
clang/lib/Parse/ParseOpenMP.cpp | 3 +-
clang/test/OpenMP/task_ast_print.cpp | 4 +
clang/test/OpenMP/task_codegen.cpp | 26 ++++-
clang/test/OpenMP/taskloop_ast_print.cpp | 34 +++---
clang/test/OpenMP/taskloop_codegen.cpp | 130 +++++++++++++++--------
5 files changed, 131 insertions(+), 66 deletions(-)
diff --git a/clang/lib/Parse/ParseOpenMP.cpp b/clang/lib/Parse/ParseOpenMP.cpp
index 6946c27de9801..66ce28bcacb1d 100644
--- a/clang/lib/Parse/ParseOpenMP.cpp
+++ b/clang/lib/Parse/ParseOpenMP.cpp
@@ -3215,7 +3215,8 @@ OMPClause *Parser::ParseOpenMPClause(OpenMPDirectiveKind DKind,
}
if (CKind == OMPC_transparent &&
- PP.LookAhead(0).is(tok::annot_pragma_openmp_end)) {
+ (PP.LookAhead(0).isNot(tok::l_paren) ||
+ PP.LookAhead(0).is(tok::annot_pragma_openmp_end))) {
SourceLocation Loc = ConsumeToken();
SourceLocation LLoc = Tok.getLocation();
Clause = Actions.OpenMP().ActOnOpenMPTransparentClause(nullptr, LLoc,
diff --git a/clang/test/OpenMP/task_ast_print.cpp b/clang/test/OpenMP/task_ast_print.cpp
index d7c1da3db537c..5ed43d802b5a1 100644
--- a/clang/test/OpenMP/task_ast_print.cpp
+++ b/clang/test/OpenMP/task_ast_print.cpp
@@ -244,6 +244,8 @@ int main(int argc, char **argv) {
#pragma omp task threadset(omp_team)
foo();
+#pragma omp task transparent shared(x)
+#pragma omp task transparent(omp_export) shared(x)
#pragma omp task transparent
#pragma omp task transparent(omp_not_impex)
#pragma omp task transparent(omp_import)
@@ -272,6 +274,8 @@ int main(int argc, char **argv) {
// CHECK60: #pragma omp task threadset(omp_pool)
// CHECK60: #pragma omp task threadset(omp_team)
// CHECK60-NEXT: foo();
+ // CHECK60: #pragma omp task transparent(omp_impex) shared(x)
+ // CHECK60: #pragma omp task transparent(omp_export) shared(x)
// CHECK60: #pragma omp task transparent(omp_impex)
// CHECK60: #pragma omp task transparent(omp_not_impex)
// CHECK60-NEXT: #pragma omp task transparent(omp_import)
diff --git a/clang/test/OpenMP/task_codegen.cpp b/clang/test/OpenMP/task_codegen.cpp
index 5483d690e50a2..764605e910338 100644
--- a/clang/test/OpenMP/task_codegen.cpp
+++ b/clang/test/OpenMP/task_codegen.cpp
@@ -240,6 +240,11 @@ void test_threadset()
void test_transparent()
{
+ int x;
+#pragma omp task transparent shared(x)
+ {}
+#pragma omp task transparent(omp_not_impex) shared(x)
+ {}
#pragma omp task transparent
{}
#pragma omp task transparent(omp_not_impex)
@@ -10306,15 +10311,18 @@ void test_transparent()
// CHECK6-LABEL: define void @_Z16test_transparentv() #1 {
// CHECK6-NEXT: entry:
+// CHECK6-NEXT: [[X:.*]] = alloca i32, align 4
// CHECK6-NEXT: [[AGG_CAPTURED:%.*]] = alloca [[STRUCT_ANON_27:%.*]], align 1
// CHECK6-NEXT: [[AGG_CAPTURED2:%.*]] = alloca [[STRUCT_ANON_29:%.*]], align 1
// CHECK6-NEXT: [[AGG_CAPTURED5:%.*]] = alloca [[STRUCT_ANON_31:%.*]], align 1
// CHECK6-NEXT: [[AGG_CAPTURED8:%.*]] = alloca [[STRUCT_ANON_33:%.*]], align 1
// CHECK6-NEXT: [[AGG_CAPTURED11:%.*]] = alloca [[STRUCT_ANON_35:%.*]], align 1
-// CHECK6-NEXT: [[V:%.*]] = alloca ptr, align 8
-// CHECK6-NEXT: [[AGG_CAPTURED11:%.*]] = alloca [[STRUCT_ANON_35:%.*]], align 1
//CHECK6-NEXT: [[AGG_CAPTURED14:%.*]] = alloca [[STRUCT_ANON_37:%.*]], align 1
-// CHECK6-NEXT: [[AGG_CAPTURED17:%.*]] = alloca [[STRUCT_ANON_39:%.*]], align 1
+// CHECK6-NEXT: [[AGG_CAPTURED17:%.*]] = alloca [[STRUCT_ANON_39:%.*]], align 1
+// CHECK6-NEXT: [[V:%.*]] = alloca ptr, align 8
+// CHECK6-NEXT: [[AGG_CAPTURED20:%.*]] = alloca [[STRUCT_ANON_41:%.*]], align 1
+// CHECK6-NEXT: [[AGG_CAPTURED23:%.*]] = alloca [[STRUCT_ANON_43:%.*]], align 1
+// CHECK6-NEXT: [[AGG_CAPTURED26:%.*]] = alloca [[STRUCT_ANON_45:%.*]], align 1
// CHECK6-NEXT: [[OMP_GLOBAL_THREAD_NUM:%.*]] = call i32 @__kmpc_global_thread_num(ptr @31)
// CHECK6-NEXT: [[TMP0:%.*]] = call ptr @__kmpc_omp_task_alloc(ptr @1, i32 [[OMP_GLOBAL_THREAD_NUM]], i32 257, i64 40, i64 1, ptr @.omp_task_entry..[[ENTRY1:[0-9]+]])
// CHECK6-NEXT: [[TMP1:%.*]] = getelementptr inbounds nuw %struct.kmp_task_t_with_privates{{.*}}, ptr [[TMP0]], i32 0, i32 0
@@ -10356,5 +10364,17 @@ void test_transparent()
// CHECK6-NEXT: [[TMP22:%.*]] = getelementptr inbounds nuw %struct.kmp_task_t_with_privates{{.*}}, ptr [[TMP21]], i32 0, i32 0
// CHECK6-NEXT: [[OMP_GLOBAL_THREAD_NUM22:%.*]] = call i32 @__kmpc_global_thread_num(ptr @45)
// CHECK6-NEXT: [[TMP23:%.*]] = call i32 @__kmpc_omp_task(ptr @1, i32 [[OMP_GLOBAL_THREAD_NUM22]], ptr [[TMP21]])
+
+// CHECK6-NEXT: [[OMP_GLOBAL_THREAD_NUM24:%.*]] = call i32 @__kmpc_global_thread_num(ptr @47)
+// CHECK6-NEXT: [[TMP24:%.*]] = call ptr @__kmpc_omp_task_alloc(ptr @1, i32 [[OMP_GLOBAL_THREAD_NUM24]], i32 257, i64 40, i64 1, ptr @.omp_task_entry..[[ENTRY45:[0-9]+]])
+// CHECK6-NEXT: [[TMP25:%.*]] = getelementptr inbounds nuw %struct.kmp_task_t_with_privates{{.*}}, ptr [[TMP24]], i32 0, i32 0
+// CHECK6-NEXT: [[OMP_GLOBAL_THREAD_NUM25:%.*]] = call i32 @__kmpc_global_thread_num(ptr @47)
+// CHECK6-NEXT: [[TMP26:%.*]] = call i32 @__kmpc_omp_task(ptr @1, i32 [[OMP_GLOBAL_THREAD_NUM25]], ptr [[TMP24]])
+// CHECK6-NEXT: [[OMP_GLOBAL_THREAD_NUM27:%.*]] = call i32 @__kmpc_global_thread_num(ptr @49)
+// CHECK6-NEXT: [[TMP27:%.*]] = call ptr @__kmpc_omp_task_alloc(ptr @1, i32 [[OMP_GLOBAL_THREAD_NUM27]], i32 257, i64 40, i64 1, ptr @.omp_task_entry..[[ENTRY47:[0-9]+]])
+// CHECK6-NEXT: [[TMP28:%.*]] = getelementptr inbounds nuw %struct.kmp_task_t_with_privates{{.*}}, ptr [[TMP27]], i32 0, i32 0
+// CHECK6-NEXT: [[OMP_GLOBAL_THREAD_NUM28:%.*]] = call i32 @__kmpc_global_thread_num(ptr @49)
+// CHECK6-NEXT: [[TMP29:%.*]] = call i32 @__kmpc_omp_task(ptr @1, i32 [[OMP_GLOBAL_THREAD_NUM28]], ptr [[TMP27]])
+
// CHECK6-NEXT: ret void
// CHECK6-NEXT:}
diff --git a/clang/test/OpenMP/taskloop_ast_print.cpp b/clang/test/OpenMP/taskloop_ast_print.cpp
index 7805620f845a3..ff39f525435d4 100644
--- a/clang/test/OpenMP/taskloop_ast_print.cpp
+++ b/clang/test/OpenMP/taskloop_ast_print.cpp
@@ -104,17 +104,20 @@ int main(int argc, char **argv) {
}
}
-#pragma omp taskloop transparent
+#pragma omp taskloop transparent priority(10)
for (int i = 0; i < 10; ++i) {
-#pragma omp taskloop transparent(omp_not_impex)
+#pragma omp taskloop transparent
for (int i = 0; i < 10; ++i) {
-#pragma omp task transparent(omp_import)
+#pragma omp taskloop transparent(omp_not_impex)
for (int i = 0; i < 10; ++i) {
+#pragma omp task transparent(omp_import)
+ for (int i = 0; i < 10; ++i) {
#pragma omp task transparent(omp_export)
- for (int i = 0; i < 10; ++i) {
+ for (int i = 0; i < 10; ++i) {
#pragma omp task transparent(omp_impex)
- foo();
- }
+ foo();
+ }
+ }
}
}
}
@@ -125,15 +128,16 @@ int main(int argc, char **argv) {
// CHECK60-NEXT: for (int j = 0; j < 10; ++j) {
// CHECK60-NEXT: foo();
-// CHECK60: #pragma omp taskloop transparent(omp_impex)
-// CHECK60: #pragma omp taskloop transparent(omp_not_impex)
-// CHECK60-NEXT: for (int i = 0; i < 10; ++i) {
-// CHECK60-NEXT: #pragma omp task transparent(omp_import)
-// CHECK60-NEXT: for (int i = 0; i < 10; ++i) {
-// CHECK60-NEXT: #pragma omp task transparent(omp_export)
-// CHECK60-NEXT: for (int i = 0; i < 10; ++i) {
-// CHECK60-NEXT: #pragma omp task transparent(omp_impex)
-// CHECK60-NEXT: foo();
+ // CHECK60: #pragma omp taskloop transparent(omp_impex) priority(10)
+ // CHECK60: #pragma omp taskloop transparent(omp_impex)
+ // CHECK60: #pragma omp taskloop transparent(omp_not_impex)
+ // CHECK60-NEXT: for (int i = 0; i < 10; ++i) {
+ // CHECK60-NEXT: #pragma omp task transparent(omp_import)
+ // CHECK60-NEXT: for (int i = 0; i < 10; ++i) {
+ // CHECK60-NEXT: #pragma omp task transparent(omp_export)
+ // CHECK60-NEXT: for (int i = 0; i < 10; ++i) {
+ // CHECK60-NEXT: #pragma omp task transparent(omp_impex)
+ // CHECK60-NEXT: foo();
return (tmain<int, 5>(argc) + tmain<char, 1>(argv[0][0]));
}
diff --git a/clang/test/OpenMP/taskloop_codegen.cpp b/clang/test/OpenMP/taskloop_codegen.cpp
index a9e7da82bec48..b5bbf6e259c35 100644
--- a/clang/test/OpenMP/taskloop_codegen.cpp
+++ b/clang/test/OpenMP/taskloop_codegen.cpp
@@ -265,6 +265,9 @@ void test_threadset()
void test_transparent()
{
+#pragma omp taskloop transparent priority(10)
+ for (int i = 0; i < 10; ++i) {
+ }
#pragma omp taskloop transparent
for (int i = 0; i < 10; ++i) {
}
@@ -330,62 +333,95 @@ void test_transparent()
// 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 257, i64 80, i64 1, ptr @.omp_task_entry..[[ENTRY1:[0-9]+]])
+// 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 5
-// CHECK6: store i64 0, ptr [[TMP3]], align 8
-// CHECK6: [[TMP4:%.*]] = getelementptr inbounds nuw %struct.kmp_task_t{{.*}}, ptr [[TMP2]], i32 0, i32 6
-// CHECK6: store i64 9, ptr [[TMP4]], align 8
-// CHECK6: [[TMP5:%.*]] = getelementptr inbounds nuw %struct.kmp_task_t{{.*}}, ptr [[TMP2]], i32 0, i32 7
-// CHECK6: store i64 1, ptr [[TMP5]], align 8
-// CHECK6: [[TMP6:%.*]] = getelementptr inbounds nuw %struct.kmp_task_t{{.*}}, ptr [[TMP2]], i32 0, i32 9
-// CHECK6: call void @llvm.memset.p0.i64(ptr align 8 [[TMP6]], i8 0, i64 8, i1 false)
-// CHECK6: [[TMP7:%.*]] = load i64, ptr [[TMP5]], align 8
-// CHECK6: call void @__kmpc_taskloop(ptr @1, i32 [[TMP0]], ptr [[TMP1]], i32 1, ptr [[TMP3]], ptr [[TMP4]], i64 [[TMP7]], i32 1, i32 0, i64 0, ptr null)
+// 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
+// CHECK6: store i64 9, ptr [[TMP5]], align 8
+// CHECK6: [[TMP6:%.*]] = getelementptr inbounds nuw %struct.kmp_task_t{{.*}}, ptr [[TMP2]], i32 0, i32 7
+// CHECK6: store i64 1, ptr [[TMP6]], align 8
+// CHECK6: [[TMP7:%.*]] = getelementptr inbounds nuw %struct.kmp_task_t{{.*}}, ptr [[TMP2]], i32 0, i32 9
+// CHECK6: call void @llvm.memset.p0.i64(ptr align 8 [[TMP7]], i8 0, i64 8, i1 false)
+// CHECK6: [[TMP8:%.*]] = load i64, ptr [[TMP6]], align 8
+// CHECK6: call void @__kmpc_taskloop(ptr @1, i32 [[TMP0]], ptr [[TMP1]], i32 1, ptr [[TMP4]], ptr [[TMP5]], i64 [[TMP8]], i32 1, i32 0, i64 0, ptr null)
+// CHECK6: call void @__kmpc_end_taskgroup(ptr @1, i32 [[TMP0]])
+// CHECK6: call void @__kmpc_taskgroup(ptr @1, i32 [[TMP0]])
+// CHECK6: [[TMP9:%.*]] = call ptr @__kmpc_omp_task_alloc(ptr @1, i32 [[TMP0]], i32 257, i64 80, i64 1, ptr @.omp_task_entry..[[ENTRY2:[0-9]+]])
+// CHECK6: [[TMP10:%.*]] = getelementptr inbounds nuw %struct.kmp_task_t_with_privates{{.*}}, ptr [[TMP9]], i32 0, i32 0
+// CHECK6: [[TMP11:%.*]] = getelementptr inbounds nuw %struct.kmp_task_t{{.*}}, ptr [[TMP10]], i32 0, i32 5
+// CHECK6: store i64 0, ptr [[TMP11]], align 8
+// CHECK6: [[TMP12:%.*]] = getelementptr inbounds nuw %struct.kmp_task_t{{.*}}, ptr [[TMP10]], i32 0, i32 6
+// CHECK6: store i64 9, ptr [[TMP12]], align 8
+// CHECK6: [[TMP13:%.*]] = getelementptr inbounds nuw %struct.kmp_task_t{{.*}}, ptr [[TMP10]], i32 0, i32 7
+// CHECK6: store i64 1, ptr [[TMP13]], align 8
+// CHECK6: [[TMP14:%.*]] = getelementptr inbounds nuw %struct.kmp_task_t{{.*}}, ptr [[TMP10]], i32 0, i32 9
+// CHECK6: call void @llvm.memset.p0.i64(ptr align 8 [[TMP14]], i8 0, i64 8, i1 false)
+// CHECK6: [[TMP15:%.*]] = load i64, ptr [[TMP13]], align 8
+// CHECK6: call void @__kmpc_taskloop(ptr @1, i32 [[TMP0]], ptr [[TMP9]], i32 1, ptr [[TMP11]], ptr [[TMP12]], i64 [[TMP15]], i32 1, i32 0, i64 0, ptr null)
// CHECK6: call void @__kmpc_end_taskgroup(ptr @1, i32 [[TMP0]])
// CHECK6: call void @__kmpc_taskgroup(ptr @1, i32 [[TMP0]])
-// CHECK6: [[TMP8:%.*]] = call ptr @__kmpc_omp_task_alloc(ptr @1, i32 [[TMP0]], i32 257, i64 80, i64 1, ptr @.omp_task_entry..[[ENTRY2:[0-9]+]])
-// CHECK6: [[TMP9:%.*]] = getelementptr inbounds nuw %struct.kmp_task_t_with_privates{{.*}}, ptr [[TMP8]], i32 0, i32 0
-// CHECK6: [[TMP10:%.*]] = getelementptr inbounds nuw %struct.kmp_task_t{{.*}}, ptr [[TMP9]], i32 0, i32 5
-// CHECK6: store i64 0, ptr [[TMP10]], align 8
-// CHECK6: [[TMP11:%.*]] = getelementptr inbounds nuw %struct.kmp_task_t{{.*}}, ptr [[TMP9]], i32 0, i32 6
-// CHECK6: store i64 9, ptr [[TMP11]], align 8
-// CHECK6: [[TMP12:%.*]] = getelementptr inbounds nuw %struct.kmp_task_t{{.*}}, ptr [[TMP9]], i32 0, i32 7
-// CHECK6: store i64 1, ptr [[TMP12]], align 8
-// CHECK6: [[TMP13:%.*]] = getelementptr inbounds nuw %struct.kmp_task_t{{.*}}, ptr [[TMP9]], i32 0, i32 9
-// CHECK6: call void @llvm.memset.p0.i64(ptr align 8 [[TMP13]], i8 0, i64 8, i1 false)
-// CHECK6: [[TMP14:%.*]] = load i64, ptr [[TMP12]], align 8
-// CHECK6: call void @__kmpc_taskloop(ptr @1, i32 [[TMP0]], ptr [[TMP8]], i32 1, ptr [[TMP10]], ptr [[TMP11]], i64 [[TMP14]], i32 1, i32 0, i64 0, ptr null)
+// CHECK6: [[TMP16:%.*]] = call ptr @__kmpc_omp_task_alloc(ptr @1, i32 [[TMP0]], i32 257, i64 80, i64 1, ptr @.omp_task_entry..22)
+// CHECK6: [[TMP17:%.*]] = getelementptr inbounds nuw %struct.kmp_task_t_with_privates{{.*}}, ptr [[TMP16]], i32 0, i32 0
+// CHECK6: [[TMP18:%.*]] = getelementptr inbounds nuw %struct.kmp_task_t{{.*}}, ptr [[TMP17]], i32 0, i32 5
+// CHECK6: store i64 0, ptr [[TMP18]], align 8
+// CHECK6: [[TMP19:%.*]] = getelementptr inbounds nuw %struct.kmp_task_t{{.*}}, ptr [[TMP17]], i32 0, i32 6
+// CHECK6: store i64 9, ptr [[TMP19]], align 8
+// CHECK6: [[TMP20:%.*]] = getelementptr inbounds nuw %struct.kmp_task_t{{.*}}, ptr [[TMP17]], i32 0, i32 7
+// CHECK6: store i64 1, ptr [[TMP20]], align 8
+// CHECK6: [[TMP21:%.*]] = getelementptr inbounds nuw %struct.kmp_task_t{{.*}}, ptr [[TMP17]], i32 0, i32 9
+// CHECK6: call void @llvm.memset.p0.i64(ptr align 8 [[TMP21]], i8 0, i64 8, i1 false)
+// CHECK6: [[TMP22:%.*]] = load i64, ptr [[TMP20]], align 8
+// CHECK6: call void @__kmpc_taskloop(ptr @1, i32 [[TMP0]], ptr [[TMP16]], i32 1, ptr [[TMP18]], ptr [[TMP19]], i64 [[TMP22]], i32 1, i32 0, i64 0, ptr null)
// CHECK6: call void @__kmpc_end_taskgroup(ptr @1, i32 [[TMP0]])
// CHECK6: call void @__kmpc_taskgroup(ptr @1, i32 [[TMP0]])
-// CHECK6: [[TMP15:%.*]] = call ptr @__kmpc_omp_task_alloc(ptr @1, i32 [[TMP0]], i32 257, i64 80, i64 1, ptr @.omp_task_entry..22)
-// CHECK6: [[TMP16:%.*]] = getelementptr inbounds nuw %struct.kmp_task_t_with_privates{{.*}}, ptr [[TMP15]], i32 0, i32 0
-// CHECK6: [[TMP17:%.*]] = getelementptr inbounds nuw %struct.kmp_task_t{{.*}}, ptr [[TMP16]], i32 0, i32 5
-// CHECK6: store i64 0, ptr [[TMP17]], align 8
-// CHECK6: [[TMP18:%.*]] = getelementptr inbounds nuw %struct.kmp_task_t{{.*}}, ptr [[TMP16]], i32 0, i32 6
-// CHECK6: store i64 9, ptr [[TMP18]], align 8
-// CHECK6: [[TMP19:%.*]] = getelementptr inbounds nuw %struct.kmp_task_t{{.*}}, ptr [[TMP16]], i32 0, i32 7
-// CHECK6: store i64 1, ptr [[TMP19]], align 8
-// CHECK6: [[TMP20:%.*]] = getelementptr inbounds nuw %struct.kmp_task_t{{.*}}, ptr [[TMP16]], i32 0, i32 9
-// CHECK6: call void @llvm.memset.p0.i64(ptr align 8 [[TMP20]], i8 0, i64 8, i1 false)
-// CHECK6: [[TMP21:%.*]] = load i64, ptr [[TMP19]], align 8
-// CHECK6: call void @__kmpc_taskloop(ptr @1, i32 [[TMP0]], ptr [[TMP15]], i32 1, ptr [[TMP17]], ptr [[TMP18]], i64 [[TMP21]], i32 1, i32 0, i64 0, ptr null)
+// CHECK6: [[TMP23:%.*]] = call ptr @__kmpc_omp_task_alloc(ptr @1, i32 [[TMP0]], i32 257, i64 80, i64 1, ptr @.omp_task_entry..24)
+// CHECK6: [[TMP24:%.*]] = getelementptr inbounds nuw %struct.kmp_task_t_with_privates{{.*}}, ptr [[TMP23]], i32 0, i32 0
+// CHECK6: [[TMP25:%.*]] = getelementptr inbounds nuw %struct.kmp_task_t{{.*}}, ptr [[TMP24]], i32 0, i32 5
+// CHECK6: store i64 0, ptr [[TMP25]], align 8
+// CHECK6: [[TMP26:%.*]] = getelementptr inbounds nuw %struct.kmp_task_t{{.*}}, ptr [[TMP24]], i32 0, i32 6
+// CHECK6: store i64 9, ptr [[TMP26]], align 8
+// CHECK6: [[TMP27:%.*]] = getelementptr inbounds nuw %struct.kmp_task_t{{.*}}, ptr [[TMP24]], i32 0, i32 7
+// CHECK6: store i64 1, ptr [[TMP27]], align 8
+// CHECK6: [[TMP28:%.*]] = getelementptr inbounds nuw %struct.kmp_task_t{{.*}}, ptr [[TMP24]], i32 0, i32 9
+// CHECK6: call void @llvm.memset.p0.i64(ptr align 8 [[TMP28]], i8 0, i64 8, i1 false)
+// CHECK6: [[TMP29:%.*]] = load i64, ptr [[TMP27]], align 8
+// CHECK6: call void @__kmpc_taskloop(ptr @1, i32 [[TMP0]], ptr [[TMP23]], i32 1, ptr [[TMP25]], ptr [[TMP26]], i64 [[TMP29]], i32 1, i32 0, i64 0, ptr null)
+// CHECK6: call void @__kmpc_end_taskgroup(ptr @1, i32 [[TMP0]])
+
+// CHECK6: call void @__kmpc_taskgroup(ptr @1, i32 [[TMP0]])
+// CHECK6: [[TMP30:%.*]] = call ptr @__kmpc_omp_task_alloc(ptr @1, i32 [[TMP0]], i32 257, i64 80, i64 1, ptr @.omp_task_entry..[[ENTRY26:[0-9]+]])
+// CHECK6: [[TMP31:%.*]] = getelementptr inbounds nuw %struct.kmp_task_t_with_privates.27, ptr [[TMP30]], i32 0, i32 0
+// CHECK6: [[TMP32:%.*]] = getelementptr inbounds nuw %struct.kmp_task_t.2, ptr [[TMP31]], i32 0, i32 5
+// CHECK6: store i64 0, ptr [[TMP32]], align 8
+// CHECK6: [[TMP33:%.*]] = getelementptr inbounds nuw %struct.kmp_task_t.2, ptr [[TMP31]], i32 0, i32 6
+// CHECK6: store i64 9, ptr [[TMP33]], align 8
+// CHECK6: [[TMP34:%.*]] = getelementptr inbounds nuw %struct.kmp_task_t.2, ptr [[TMP31]], i32 0, i32 7
+// CHECK6: store i64 1, ptr [[TMP34]], align 8
+// CHECK6: [[TMP35:%.*]] = getelementptr inbounds nuw %struct.kmp_task_t.2, ptr [[TMP31]], i32 0, i32 9
+// CHECK6: call void @llvm.memset.p0.i64(ptr align 8 [[TMP35]], i8 0, i64 8, i1 false)
+// CHECK6: [[TMP36:%.*]] = load i64, ptr [[TMP34]], align 8
+// CHECK6: call void @__kmpc_taskloop(ptr @1, i32 [[TMP0]], ptr [[TMP30]], i32 1, ptr [[TMP32]], ptr [[TMP33]], i64 [[TMP36]], i32 1, i32 0, i64 0, ptr null)
// CHECK6: call void @__kmpc_end_taskgroup(ptr @1, i32 [[TMP0]])
// CHECK6: call void @__kmpc_taskgroup(ptr @1, i32 [[TMP0]])
-// CHECK6: [[TMP22:%.*]] = call ptr @__kmpc_omp_task_alloc(ptr @1, i32 [[TMP0]], i32 257, i64 80, i64 1, ptr @.omp_task_entry..24)
-// CHECK6: [[TMP23:%.*]] = getelementptr inbounds nuw %struct.kmp_task_t_with_privates{{.*}}, ptr [[TMP22]], i32 0, i32 0
-// CHECK6: [[TMP24:%.*]] = getelementptr inbounds nuw %struct.kmp_task_t{{.*}}, ptr [[TMP23]], i32 0, i32 5
-// CHECK6: store i64 0, ptr [[TMP24]], align 8
-// CHECK6: [[TMP25:%.*]] = getelementptr inbounds nuw %struct.kmp_task_t{{.*}}, ptr [[TMP23]], i32 0, i32 6
-// CHECK6: store i64 9, ptr [[TMP25]], align 8
-// CHECK6: [[TMP26:%.*]] = getelementptr inbounds nuw %struct.kmp_task_t{{.*}}, ptr [[TMP23]], i32 0, i32 7
-// CHECK6: store i64 1, ptr [[TMP26]], align 8
-// CHECK6: [[TMP27:%.*]] = getelementptr inbounds nuw %struct.kmp_task_t{{.*}}, ptr [[TMP23]], i32 0, i32 9
-// CHECK6: call void @llvm.memset.p0.i64(ptr align 8 [[TMP27]], i8 0, i64 8, i1 false)
-// CHECK6: [[TMP28:%.*]] = load i64, ptr [[TMP26]], align 8
-// CHECK6: call void @__kmpc_taskloop(ptr @1, i32 [[TMP0]], ptr [[TMP22]], i32 1, ptr [[TMP24]], ptr [[TMP25]], i64 [[TMP28]], i32 1, i32 0, i64 0, ptr null)
+// CHECK6: [[TMP37:%.*]] = call ptr @__kmpc_omp_task_alloc(ptr @1, i32 [[TMP0]], i32 257, i64 80, i64 1, ptr @.omp_task_entry..[[ENTRY28:[0-9]+]])
+// CHECK6: [[TMP38:%.*]] = getelementptr inbounds nuw %struct.kmp_task_t_with_privates.29, ptr [[TMP37]], i32 0, i32 0
+// CHECK6: [[TMP39:%.*]] = getelementptr inbounds nuw %struct.kmp_task_t.2, ptr [[TMP38]], i32 0, i32 5
+// CHECK6: store i64 0, ptr [[TMP39]], align 8
+// CHECK6: [[TMP40:%.*]] = getelementptr inbounds nuw %struct.kmp_task_t.2, ptr [[TMP38]], i32 0, i32 6
+// CHECK6: store i64 9, ptr [[TMP40]], align 8
+// CHECK6: [[TMP41:%.*]] = getelementptr inbounds nuw %struct.kmp_task_t.2, ptr [[TMP38]], i32 0, i32 7
+// CHECK6: store i64 1, ptr [[TMP41]], align 8
+// CHECK6: [[TMP42:%.*]] = getelementptr inbounds nuw %struct.kmp_task_t.2, ptr [[TMP38]], i32 0, i32 9
+// CHECK6: call void @llvm.memset.p0.i64(ptr align 8 [[TMP42]], i8 0, i64 8, i1 false)
+// CHECK6: [[TMP43:%.*]] = load i64, ptr [[TMP41]], align 8
+// CHECK6: call void @__kmpc_taskloop(ptr @1, i32 [[TMP0]], ptr [[TMP37]], i32 1, ptr [[TMP39]], ptr [[TMP40]], i64 [[TMP43]], i32 1, i32 0, i64 0, ptr null)
// CHECK6: call void @__kmpc_end_taskgroup(ptr @1, i32 [[TMP0]])
// CHECK6: ret void
// CHECK6:}
>From 7cfb54895025dd01481f1720a40f8e62012c8ebe Mon Sep 17 00:00:00 2001
From: Zahira Ammarguellat <zahira.ammarguellat at intel.com>
Date: Mon, 2 Feb 2026 09:50:02 -0800
Subject: [PATCH 5/5] Addressed review comments
---
clang/lib/Parse/ParseOpenMP.cpp | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/clang/lib/Parse/ParseOpenMP.cpp b/clang/lib/Parse/ParseOpenMP.cpp
index 66ce28bcacb1d..b41803d23cb25 100644
--- a/clang/lib/Parse/ParseOpenMP.cpp
+++ b/clang/lib/Parse/ParseOpenMP.cpp
@@ -3214,9 +3214,7 @@ OMPClause *Parser::ParseOpenMPClause(OpenMPDirectiveKind DKind,
ErrorFound = true;
}
- if (CKind == OMPC_transparent &&
- (PP.LookAhead(0).isNot(tok::l_paren) ||
- PP.LookAhead(0).is(tok::annot_pragma_openmp_end))) {
+ if (CKind == OMPC_transparent && PP.LookAhead(0).isNot(tok::l_paren)) {
SourceLocation Loc = ConsumeToken();
SourceLocation LLoc = Tok.getLocation();
Clause = Actions.OpenMP().ActOnOpenMPTransparentClause(nullptr, LLoc,
More information about the cfe-commits
mailing list