aboutsummaryrefslogtreecommitdiff
path: root/clang/test
diff options
context:
space:
mode:
authorJoseph Huber <huberjn@outlook.com>2024-07-08 12:47:22 -0500
committerGitHub <noreply@github.com>2024-07-08 10:47:22 -0700
commit5ef4e6db96b2a3eca4c84671ac964dc2134035b5 (patch)
treeb770d7280769a4d9415cd69106d2dd30f4c52cd4 /clang/test
parentc22625cb3eaf052e2377881d64640196ff5da3d1 (diff)
downloadllvm-5ef4e6db96b2a3eca4c84671ac964dc2134035b5.zip
llvm-5ef4e6db96b2a3eca4c84671ac964dc2134035b5.tar.gz
llvm-5ef4e6db96b2a3eca4c84671ac964dc2134035b5.tar.bz2
[OpenMP] Correctly code-gen default atomic mem order (#97663)
Summary: The parsing for this was implemented, but we never hooked up the default value to the result of this clause. This patch adds the support by making it default to the requires directive.
Diffstat (limited to 'clang/test')
-rw-r--r--clang/test/OpenMP/requires_default_atomic_mem_order.cpp46
1 files changed, 46 insertions, 0 deletions
diff --git a/clang/test/OpenMP/requires_default_atomic_mem_order.cpp b/clang/test/OpenMP/requires_default_atomic_mem_order.cpp
new file mode 100644
index 0000000..90d2db4
--- /dev/null
+++ b/clang/test/OpenMP/requires_default_atomic_mem_order.cpp
@@ -0,0 +1,46 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 5
+// RUN: %clang_cc1 -emit-llvm -fopenmp -triple=x86_64-unknown-linux-gnu \
+// RUN: -DORDERING=seq_cst -o - %s \
+// RUN: | FileCheck %s --check-prefix=SEQ_CST
+// RUN: %clang_cc1 -emit-llvm -fopenmp -triple=x86_64-unknown-linux-gnu \
+// RUN: -DORDERING=acq_rel -o - %s \
+// RUN: | FileCheck %s --check-prefix=ACQ_REL
+// RUN: %clang_cc1 -emit-llvm -fopenmp -triple=x86_64-unknown-linux-gnu \
+// RUN: -DORDERING=relaxed -o - %s \
+// RUN: | FileCheck %s --check-prefix=RELAXED
+
+#pragma omp requires atomic_default_mem_order(ORDERING)
+
+// SEQ_CST-LABEL: define dso_local void @_Z3fooPi(
+// SEQ_CST-SAME: ptr noundef [[X:%.*]]) #[[ATTR0:[0-9]+]] {
+// SEQ_CST-NEXT: [[ENTRY:.*:]]
+// SEQ_CST-NEXT: [[X_ADDR:%.*]] = alloca ptr, align 8
+// SEQ_CST-NEXT: store ptr [[X]], ptr [[X_ADDR]], align 8
+// SEQ_CST-NEXT: [[TMP0:%.*]] = load ptr, ptr [[X_ADDR]], align 8
+// SEQ_CST-NEXT: [[TMP1:%.*]] = atomicrmw add ptr [[TMP0]], i32 1 seq_cst, align 4
+// SEQ_CST-NEXT: call void @__kmpc_flush(ptr @[[GLOB1:[0-9]+]])
+// SEQ_CST-NEXT: ret void
+//
+// ACQ_REL-LABEL: define dso_local void @_Z3fooPi(
+// ACQ_REL-SAME: ptr noundef [[X:%.*]]) #[[ATTR0:[0-9]+]] {
+// ACQ_REL-NEXT: [[ENTRY:.*:]]
+// ACQ_REL-NEXT: [[X_ADDR:%.*]] = alloca ptr, align 8
+// ACQ_REL-NEXT: store ptr [[X]], ptr [[X_ADDR]], align 8
+// ACQ_REL-NEXT: [[TMP0:%.*]] = load ptr, ptr [[X_ADDR]], align 8
+// ACQ_REL-NEXT: [[TMP1:%.*]] = atomicrmw add ptr [[TMP0]], i32 1 release, align 4
+// ACQ_REL-NEXT: call void @__kmpc_flush(ptr @[[GLOB1:[0-9]+]])
+// ACQ_REL-NEXT: ret void
+//
+// RELAXED-LABEL: define dso_local void @_Z3fooPi(
+// RELAXED-SAME: ptr noundef [[X:%.*]]) #[[ATTR0:[0-9]+]] {
+// RELAXED-NEXT: [[ENTRY:.*:]]
+// RELAXED-NEXT: [[X_ADDR:%.*]] = alloca ptr, align 8
+// RELAXED-NEXT: store ptr [[X]], ptr [[X_ADDR]], align 8
+// RELAXED-NEXT: [[TMP0:%.*]] = load ptr, ptr [[X_ADDR]], align 8
+// RELAXED-NEXT: [[TMP1:%.*]] = atomicrmw add ptr [[TMP0]], i32 1 monotonic, align 4
+// RELAXED-NEXT: ret void
+//
+void foo(int *x) {
+ #pragma omp atomic update
+ *x = *x + 1;
+}