Skip to content

Commit ab69f1e

Browse files
committed
Addressed review comments.
1 parent 7fa46c6 commit ab69f1e

File tree

3 files changed

+65
-2
lines changed

3 files changed

+65
-2
lines changed

clang/lib/Parse/ParseOpenMP.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2886,7 +2886,7 @@ StmtResult Parser::ParseOpenMPDeclarativeOrExecutableDirective(
28862886
// OMP5.2 Chapter 7.4: If no otherwise clause is specified the effect is as
28872887
// if one was specified without an associated directive variant.
28882888
if (BestIdx == -1 && Idx == 1) {
2889-
SkipUntil(tok::annot_pragma_openmp_end);
2889+
SkipUntil(tok::annot_pragma_openmp_end,tok::identifier);
28902890
}
28912891
break;
28922892
}

clang/test/OpenMP/metadirective_ast_print.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,11 @@ void foo(void) {
8686
: parallel for)
8787
for (int i=0; i<10; i++)
8888
;
89+
#pragma omp metadirective when(user = {condition(0)} \
90+
: parallel for) when(implementation = {extension(match_none)} \
91+
: parallel) default(parallel for)
92+
for (int i=0; i<10; i++)
93+
;
8994

9095
#pragma omp metadirective when(user = {condition(1)} \
9196
: parallel for) otherwise()
@@ -95,6 +100,11 @@ void foo(void) {
95100
: parallel for)
96101
for (int i=0; i<10; i++)
97102
;
103+
#pragma omp metadirective when(user = {condition(1)} \
104+
: parallel for) when(implementation = {extension(match_none)} \
105+
: parallel) default(parallel for)
106+
for (int i=0; i<10; i++)
107+
;
98108
}
99109

100110
// CHECK: void bar(void);

clang/test/OpenMP/metadirective_otherwise.cpp

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,16 @@ void func1() {
1414
: parallel for)
1515
for (int i = 0; i < 100; i++)
1616
;
17+
18+
#pragma omp metadirective when(user = {condition(0)} \
19+
: parallel for) \
20+
when(implementation = {extension(match_none)} \
21+
: parallel) default(parallel for)
22+
23+
for (int i = 0; i < 100; i++)
24+
;
25+
26+
1727
}
1828

1929
// CHECK-LABEL: define dso_local void @_Z5func1v()
@@ -48,7 +58,7 @@ void func1() {
4858
// CHECK-NEXT: store i32 [[INC6]], ptr [[I1]], align 4
4959
// CHECK-NEXT: br label %[[FOR_COND2]], !llvm.loop [[LOOP5:![0-9]+]]
5060
// CHECK: [[FOR_END7]]:
51-
// CHECK-NEXT: ret void
61+
// CHECK: ret void
5262

5363
void func2() {
5464
#pragma omp metadirective when(user = {condition(1)} \
@@ -69,4 +79,47 @@ void func2() {
6979
// CHECK-NEXT: ret void
7080

7181

82+
void func3() {
83+
#pragma omp metadirective when(user = {condition(0)} \
84+
: parallel for) \
85+
when(implementation = {extension(match_none)} \
86+
: parallel) default(parallel for)
87+
88+
for (int i = 0; i < 100; i++)
89+
;
90+
91+
}
92+
93+
// CHECK-LABEL: define dso_local void @_Z5func3v()
94+
// CHECK: entry
95+
// CHECK-NEXT: call void (ptr, i32, ptr, ...) @__kmpc_fork_call(ptr @1, i32 0, ptr @_Z5func3v.omp_outlined)
96+
// CHECK-NEXT: ret void
97+
// CHECK-NEXT: }
98+
99+
// CHECK-LABEL: define internal void @_Z5func3v.omp_outlined
100+
// CHECK-SAME: (ptr noalias noundef [[DOTGLOBAL_TID_:%.*]],
101+
// CHECK-SAME: ptr noalias noundef [[DOTBOUND_TID_:%.*]])
102+
// CHECK-NEXT: entry
103+
// CHECK-NEXT: [[GLOB_TID__ADDR:%.*]] = alloca ptr, align 8
104+
// CHECK-NEXT: [[BOUND_TID__ADDR:%.*]] = alloca ptr, align 8
105+
// CHECK-NEXT: [[I:%.*]] = alloca i32, align 4
106+
// CHECK-NEXT: store ptr [[DOTGLOBAL_TID_]], ptr [[GLOB_TID__ADDR]], align 8
107+
// CHECK-NEXT: store ptr [[DOTBOUND_TID_]], ptr [[BOUND_TID__ADDR]], align 8
108+
// CHECK-NEXT: store i32 0, ptr [[I]], align 4
109+
// CHECK-NEXT: br label %for.cond
110+
// CHECK:for.cond:
111+
// CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr [[I]], align 4
112+
// CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[TMP0]], 100
113+
// CHECK-NEXT: br i1 [[CMP]], label [[FOR_BODY:%.*]], label [[FOR_END:%.*]]
114+
// CHECK:for.body:
115+
// CHECK-NEXT: br label [[FOR_INC:%.*]]
116+
// CHECK:for.inc:
117+
// CHECK-NEXT: [[TMP1:%.*]] = load i32, ptr [[I]], align 4
118+
// CHECK-NEXT: [[INC:%.*]] = add nsw i32 [[TMP1]], 1
119+
// CHECK-NEXT: store i32 [[INC]], ptr [[I]], align 4
120+
// CHECK-NEXT: br label [[FOR_COND:%.*]]
121+
// CHECK:for.end:
122+
// CHECK-NEXT: ret void
123+
// CHECK-NEXT:}
124+
72125
#endif

0 commit comments

Comments
 (0)