Skip to content

Commit fd5bf30

Browse files
Added support for seq_cst clause for flush directive
1 parent 4b44639 commit fd5bf30

File tree

7 files changed

+31
-23
lines changed

7 files changed

+31
-23
lines changed

clang/include/clang/AST/OpenMPClause.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2645,8 +2645,8 @@ class OMPCompareClause final : public OMPClause {
26452645
}
26462646
};
26472647

2648-
/// This represents 'seq_cst' clause in the '#pragma omp atomic'
2649-
/// directive.
2648+
/// This represents 'seq_cst' clause in the '#pragma omp atomic|flush'
2649+
/// directives.
26502650
///
26512651
/// \code
26522652
/// #pragma omp atomic seq_cst

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11360,7 +11360,7 @@ def err_omp_atomic_weak_no_equality : Error<"expected '==' operator for 'weak' c
1136011360
def err_omp_atomic_several_clauses : Error<
1136111361
"directive '#pragma omp atomic' cannot contain more than one 'read', 'write', 'update', 'capture', or 'compare' clause">;
1136211362
def err_omp_several_mem_order_clauses : Error<
11363-
"directive '#pragma omp %0' cannot contain more than one %select{'seq_cst', 'relaxed', |}1'acq_rel', 'acquire' or 'release' clause">;
11363+
"directive '#pragma omp %0' cannot contain more than one %select{'seq_cst', 'relaxed', |}1'seq_cst', 'acq_rel', 'acquire' or 'release' clause">;
1136411364
def err_omp_atomic_incompatible_mem_order_clause : Error<
1136511365
"directive '#pragma omp atomic%select{ %0|}1' cannot be used with '%2' clause">;
1136611366
def note_omp_previous_mem_order_clause : Note<

clang/lib/Sema/SemaOpenMP.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11105,7 +11105,8 @@ StmtResult SemaOpenMP::ActOnOpenMPFlushDirective(ArrayRef<OMPClause *> Clauses,
1110511105
for (const OMPClause *C : Clauses) {
1110611106
if (C->getClauseKind() == OMPC_acq_rel ||
1110711107
C->getClauseKind() == OMPC_acquire ||
11108-
C->getClauseKind() == OMPC_release) {
11108+
C->getClauseKind() == OMPC_release ||
11109+
C->getClauseKind() == OMPC_seq_cst /*OpenMP 5.1*/) {
1110911110
if (MemOrderKind != OMPC_unknown) {
1111011111
Diag(C->getBeginLoc(), diag::err_omp_several_mem_order_clauses)
1111111112
<< getOpenMPDirectiveName(OMPD_flush) << 1

clang/test/OpenMP/flush_ast_print.cpp

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
// RUN: %clang_cc1 -verify -fopenmp -ast-print %s | FileCheck %s
2-
// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -emit-pch -o %t %s
3-
// RUN: %clang_cc1 -fopenmp -std=c++11 -include-pch %t -verify %s -ast-print | FileCheck %s
1+
// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=51 -ast-print %s | FileCheck %s
2+
// RUN: %clang_cc1 -fopenmp -fopenmp-version=51 -x c++ -std=c++11 -emit-pch -o %t %s
3+
// RUN: %clang_cc1 -fopenmp -fopenmp-version=51 -std=c++11 -include-pch %t -verify %s -ast-print | FileCheck %s
44

5-
// RUN: %clang_cc1 -verify -fopenmp-simd -ast-print %s | FileCheck %s
6-
// RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -emit-pch -o %t %s
7-
// RUN: %clang_cc1 -fopenmp-simd -std=c++11 -include-pch %t -verify %s -ast-print | FileCheck %s
5+
// RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-version=51 -ast-print %s | FileCheck %s
6+
// RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=51 -x c++ -std=c++11 -emit-pch -o %t %s
7+
// RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=51 -std=c++11 -include-pch %t -verify %s -ast-print | FileCheck %s
88
// expected-no-diagnostics
99

1010
#ifndef HEADER
@@ -19,6 +19,7 @@ T tmain(T argc) {
1919
#pragma omp flush acq_rel
2020
#pragma omp flush acquire
2121
#pragma omp flush release
22+
#pragma omp flush seq_cst
2223
#pragma omp flush(a)
2324
return a + argc;
2425
}
@@ -27,18 +28,21 @@ T tmain(T argc) {
2728
// CHECK-NEXT: #pragma omp flush acq_rel{{$}}
2829
// CHECK-NEXT: #pragma omp flush acquire{{$}}
2930
// CHECK-NEXT: #pragma omp flush release{{$}}
31+
// CHECK-NEXT: #pragma omp flush seq_cst{{$}}
3032
// CHECK-NEXT: #pragma omp flush (a)
3133
// CHECK: static int a;
3234
// CHECK-NEXT: #pragma omp flush
3335
// CHECK-NEXT: #pragma omp flush acq_rel{{$}}
3436
// CHECK-NEXT: #pragma omp flush acquire{{$}}
3537
// CHECK-NEXT: #pragma omp flush release{{$}}
38+
// CHECK-NEXT: #pragma omp flush seq_cst{{$}}
3639
// CHECK-NEXT: #pragma omp flush (a)
3740
// CHECK: static char a;
3841
// CHECK-NEXT: #pragma omp flush
3942
// CHECK-NEXT: #pragma omp flush acq_rel{{$}}
4043
// CHECK-NEXT: #pragma omp flush acquire{{$}}
4144
// CHECK-NEXT: #pragma omp flush release{{$}}
45+
// CHECK-NEXT: #pragma omp flush seq_cst{{$}}
4246
// CHECK-NEXT: #pragma omp flush (a)
4347

4448
int main(int argc, char **argv) {
@@ -48,11 +52,13 @@ int main(int argc, char **argv) {
4852
#pragma omp flush acq_rel
4953
#pragma omp flush acquire
5054
#pragma omp flush release
55+
#pragma omp flush seq_cst
5156
#pragma omp flush(a)
5257
// CHECK-NEXT: #pragma omp flush
5358
// CHECK-NEXT: #pragma omp flush acq_rel
5459
// CHECK-NEXT: #pragma omp flush acquire{{$}}
5560
// CHECK-NEXT: #pragma omp flush release
61+
// CHECK-NEXT: #pragma omp flush seq_cst
5662
// CHECK-NEXT: #pragma omp flush (a)
5763
return tmain(argc) + tmain(argv[0][0]) + a;
5864
}

clang/test/OpenMP/flush_codegen.cpp

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
// RUN: %clang_cc1 -verify -fopenmp -x c++ -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck %s
2-
// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -emit-pch -o %t %s
3-
// RUN: %clang_cc1 -fopenmp -x c++ -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -debug-info-kind=limited -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
4-
// RUN: %clang_cc1 -verify -fopenmp -fopenmp-enable-irbuilder -x c++ -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck %s
5-
// RUN: %clang_cc1 -fopenmp -fopenmp-enable-irbuilder -x c++ -std=c++11 -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -emit-pch -o %t %s
6-
// RUN: %clang_cc1 -fopenmp -fopenmp-enable-irbuilder -x c++ -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -debug-info-kind=limited -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
1+
// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=51 -x c++ -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck %s
2+
// RUN: %clang_cc1 -fopenmp -fopenmp-version=51 -x c++ -std=c++11 -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -emit-pch -o %t %s
3+
// RUN: %clang_cc1 -fopenmp -fopenmp-version=51 -x c++ -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -debug-info-kind=limited -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
4+
// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=51 -fopenmp-enable-irbuilder -x c++ -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck %s
5+
// RUN: %clang_cc1 -fopenmp -fopenmp-version=51 -fopenmp-enable-irbuilder -x c++ -std=c++11 -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -emit-pch -o %t %s
6+
// RUN: %clang_cc1 -fopenmp -fopenmp-version=51 -fopenmp-enable-irbuilder -x c++ -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -debug-info-kind=limited -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
77

8-
// RUN: %clang_cc1 -verify -fopenmp-simd -x c++ -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck --check-prefix SIMD-ONLY0 %s
9-
// RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -emit-pch -o %t %s
10-
// RUN: %clang_cc1 -fopenmp-simd -x c++ -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -debug-info-kind=limited -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s
8+
// RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-version=51 -x c++ -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck --check-prefix SIMD-ONLY0 %s
9+
// RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=51 -x c++ -std=c++11 -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -emit-pch -o %t %s
10+
// RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=51 -x c++ -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -debug-info-kind=limited -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s
1111
// SIMD-ONLY0-NOT: {{__kmpc|__tgt}}
1212
// expected-no-diagnostics
1313
#ifndef HEADER
@@ -17,6 +17,7 @@ template <class T>
1717
T tmain(T argc) {
1818
static T a;
1919
#pragma omp flush
20+
#pragma omp flush seq_cst
2021
#pragma omp flush acq_rel
2122
#pragma omp flush acquire
2223
#pragma omp flush release
@@ -28,6 +29,7 @@ T tmain(T argc) {
2829
int main() {
2930
static int a;
3031
#pragma omp flush
32+
#pragma omp flush seq_cst
3133
#pragma omp flush acq_rel
3234
#pragma omp flush acquire
3335
#pragma omp flush release

clang/test/OpenMP/flush_messages.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,14 +134,12 @@ label1 : {
134134
#pragma omp flush(argc) flush(argc) // expected-warning {{extra tokens at the end of '#pragma omp flush' are ignored}}
135135
#pragma omp parallel flush(argc) // expected-warning {{extra tokens at the end of '#pragma omp parallel' are ignored}}
136136
;
137-
#pragma omp flush seq_cst // expected-error {{unexpected OpenMP clause 'seq_cst' in directive '#pragma omp flush'}}
138137
#pragma omp flush acq_rel // omp45-error {{unexpected OpenMP clause 'acq_rel' in directive '#pragma omp flush'}}
139138
#pragma omp flush acquire // omp45-error {{unexpected OpenMP clause 'acquire' in directive '#pragma omp flush'}}
140139
#pragma omp flush release // omp45-error {{unexpected OpenMP clause 'release' in directive '#pragma omp flush'}}
141140
#pragma omp flush relaxed // expected-error {{unexpected OpenMP clause 'relaxed' in directive '#pragma omp flush'}}
142-
#pragma omp flush seq_cst // expected-error {{unexpected OpenMP clause 'seq_cst' in directive '#pragma omp flush'}}
143-
#pragma omp flush acq_rel acquire // omp45-error {{unexpected OpenMP clause 'acq_rel' in directive '#pragma omp flush'}} omp45-error {{unexpected OpenMP clause 'acquire' in directive '#pragma omp flush'}} omp51-error {{directive '#pragma omp flush' cannot contain more than one 'acq_rel', 'acquire' or 'release' clause}} omp51-note {{'acq_rel' clause used here}}
144-
#pragma omp flush release acquire // omp45-error {{unexpected OpenMP clause 'release' in directive '#pragma omp flush'}} omp45-error {{unexpected OpenMP clause 'acquire' in directive '#pragma omp flush'}} omp51-error {{directive '#pragma omp flush' cannot contain more than one 'acq_rel', 'acquire' or 'release' clause}} omp51-note {{'release' clause used here}}
141+
#pragma omp flush acq_rel acquire // omp45-error {{unexpected OpenMP clause 'acq_rel' in directive '#pragma omp flush'}} omp45-error {{unexpected OpenMP clause 'acquire' in directive '#pragma omp flush'}} omp51-error {{directive '#pragma omp flush' cannot contain more than one 'seq_cst', 'acq_rel', 'acquire' or 'release' clause}} omp51-note {{'acq_rel' clause used here}}
142+
#pragma omp flush release acquire // omp45-error {{unexpected OpenMP clause 'release' in directive '#pragma omp flush'}} omp45-error {{unexpected OpenMP clause 'acquire' in directive '#pragma omp flush'}} omp51-error {{directive '#pragma omp flush' cannot contain more than one 'seq_cst', 'acq_rel', 'acquire' or 'release' clause}} omp51-note {{'release' clause used here}}
145143
#pragma omp flush acq_rel (argc) // omp45-error {{unexpected OpenMP clause 'acq_rel' in directive '#pragma omp flush'}} expected-warning {{extra tokens at the end of '#pragma omp flush' are ignored}}
146144
#pragma omp flush(argc) acq_rel // omp45-error {{unexpected OpenMP clause 'acq_rel' in directive '#pragma omp flush'}} omp51-error {{'flush' directive with memory order clause 'acq_rel' cannot have the list}} omp51-note {{memory order clause 'acq_rel' is specified here}}
147145
return tmain(argc);

llvm/include/llvm/Frontend/OpenMP/OMP.td

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -750,6 +750,7 @@ def OMP_Flush : Directive<"flush"> {
750750
// OMPKinds.def.
751751
VersionedClause<OMPC_Flush>,
752752
VersionedClause<OMPC_Release, 50>,
753+
VersionedClause<OMPC_SeqCst, 51>,
753754
];
754755
let association = AS_None;
755756
let category = CA_Executable;

0 commit comments

Comments
 (0)