-
Notifications
You must be signed in to change notification settings - Fork 10.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[OpenMP] Support for nothing
in metadirective
#73690
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
llvmbot
added
clang
Clang issues not falling into any other category
clang:frontend
Language frontend issues, e.g. anything involving "Sema"
clang:openmp
OpenMP related changes to Clang
labels
Nov 28, 2023
@llvm/pr-subscribers-clang @llvm/pr-subscribers-openmp Author: Sandeep Kosuri (sandeepkosuri) Changes
Full diff: https://github.com/llvm/llvm-project/pull/73690.diff 4 Files Affected:
diff --git a/clang/lib/Parse/ParseOpenMP.cpp b/clang/lib/Parse/ParseOpenMP.cpp
index ca70bb241d6f723..fb7e7a979e49f7e 100644
--- a/clang/lib/Parse/ParseOpenMP.cpp
+++ b/clang/lib/Parse/ParseOpenMP.cpp
@@ -2518,12 +2518,14 @@ StmtResult Parser::ParseOpenMPDeclarativeOrExecutableDirective(
switch (DKind) {
case OMPD_nothing:
- if ((StmtCtx & ParsedStmtContext::AllowStandaloneOpenMPDirectives) ==
- ParsedStmtContext())
- Diag(Tok, diag::err_omp_immediate_directive)
- << getOpenMPDirectiveName(DKind) << 0;
ConsumeToken();
- skipUntilPragmaOpenMPEnd(DKind);
+ // If we are parsing the directive within a metadirective, the directive
+ // ends with a ')'.
+ if (ReadDirectiveWithinMetadirective && Tok.is(tok::r_paren))
+ while (Tok.isNot(tok::annot_pragma_openmp_end))
+ ConsumeAnyToken();
+ else
+ skipUntilPragmaOpenMPEnd(DKind);
if (Tok.is(tok::annot_pragma_openmp_end))
ConsumeAnnotationToken();
break;
diff --git a/clang/test/OpenMP/metadirective_ast_print.c b/clang/test/OpenMP/metadirective_ast_print.c
index ddd5b8633cc5013..d9ff7e764521607 100644
--- a/clang/test/OpenMP/metadirective_ast_print.c
+++ b/clang/test/OpenMP/metadirective_ast_print.c
@@ -67,6 +67,16 @@ void foo(void) {
default(parallel for)
for (int i = 0; i < 100; i++)
;
+
+#pragma omp metadirective when(implementation = {extension(match_all)} \
+ : nothing) default(parallel for)
+ for (int i = 0; i < 16; i++)
+ ;
+
+#pragma omp metadirective when(implementation = {extension(match_any)} \
+ : parallel) default(nothing)
+ for (int i = 0; i < 16; i++)
+ ;
}
// CHECK: void bar(void);
@@ -95,5 +105,7 @@ void foo(void) {
// CHECK-NEXT: for (int j = 0; j < 16; j++)
// CHECK-AMDGCN: #pragma omp teams distribute parallel for
// CHECK-AMDGCN-NEXT: for (int i = 0; i < 100; i++)
+// CHECK: for (int i = 0; i < 16; i++)
+// CHECK: for (int i = 0; i < 16; i++)
#endif
diff --git a/clang/test/OpenMP/metadirective_empty.cpp b/clang/test/OpenMP/metadirective_empty.cpp
index 8708aa45b156309..b93ed722cb6e904 100644
--- a/clang/test/OpenMP/metadirective_empty.cpp
+++ b/clang/test/OpenMP/metadirective_empty.cpp
@@ -14,11 +14,17 @@ void func() {
:) default(parallel for)
for (int i = 0; i < N; i++)
;
+
+#pragma omp metadirective when(implementation = {vendor(llvm)} \
+ :nothing) default(parallel for)
+ for (int i = 0; i < N; i++)
+ ;
}
// CHECK-LABEL: void @_Z4funcv()
// CHECK: entry:
// CHECK: [[I:%.+]] = alloca i32,
+// CHECK: [[I1:%.+]] = alloca i32,
// CHECK: store i32 0, ptr [[I]],
// CHECK: br label %[[FOR_COND:.+]]
// CHECK: [[FOR_COND]]:
@@ -33,6 +39,20 @@ void func() {
// CHECK: store i32 [[INC]], ptr [[I]],
// CHECK: br label %[[FOR_COND]],
// CHECK: [[FOR_END]]:
+// CHECK: store i32 0, ptr [[I1]],
+// CHECK: br label %[[FOR_COND1:.+]]
+// CHECK: [[FOR_COND1]]:
+// CHECK: [[TWO:%.+]] = load i32, ptr [[I1]],
+// CHECK: [[CMP1:%.+]] = icmp slt i32 [[TWO]], 1000
+// CHECK: br i1 [[CMP1]], label %[[FOR_BODY1:.+]], label %[[FOR_END1:.+]]
+// CHECK: [[FOR_BODY1]]:
+// CHECK: br label %[[FOR_INC1:.+]]
+// CHECK: [[FOR_INC1]]:
+// CHECK: [[THREE:%.+]] = load i32, ptr [[I1]],
+// CHECK: [[INC1:%.+]] = add nsw i32 [[THREE]], 1
+// CHECK: store i32 [[INC1]], ptr [[I1]],
+// CHECK: br label %[[FOR_COND1]],
+// CHECK: [[FOR_END1]]:
// CHECK: ret void
// CHECK: }
diff --git a/clang/test/OpenMP/nothing_messages.cpp b/clang/test/OpenMP/nothing_messages.cpp
index cd6d0defe492fb4..0e27e3c27076a7b 100644
--- a/clang/test/OpenMP/nothing_messages.cpp
+++ b/clang/test/OpenMP/nothing_messages.cpp
@@ -12,7 +12,6 @@ int mixed() {
x=d;
}
-// expected-error@+2 {{#pragma omp nothing' cannot be an immediate substatement}}
if(!x)
#pragma omp nothing
x=d;
|
alexey-bataev
approved these changes
Nov 28, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
clang:frontend
Language frontend issues, e.g. anything involving "Sema"
clang:openmp
OpenMP related changes to Clang
clang
Clang issues not falling into any other category
openmp
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
nothing
to work properly insidemetadirective
.