1 // RUN: %clang_cc1 -triple s390x-linux-gnu -O1 -emit-llvm %s -o - | FileCheck %s
2 //
3 // Test __atomic_is_lock_free() and friends.
4
5 #include <stdatomic.h>
6 #include <stdint.h>
7
8 typedef __attribute__((aligned(16))) __int128 __int128_Al16;
9
10 _Atomic __int128 Int128_Atomic;
11 __int128_Al16 Int128_Al16;
12 __int128 Int128;
13 struct { int I[3]; } _Atomic AtomicStruct;
14 _Atomic long double Atomic_fp128; // Also check the alignment of this.
15
16 // Check alignments of the variables. @AtomicStruct gets padded and its size
17 // and alignment becomes 16. Only a power-of-2 size is considered, so 16 (not
18 // 12) needs to be specified with the intrinsics below.
19 //
20 // CHECK: %struct.anon = type { [3 x i32] }
21 // CHECK: @Int128 = {{.*}} i128 0, align 8
22 // CHECK: @Int128_Atomic = {{.*}} i128 0, align 16
23 // CHECK: @Int128_Al16 = {{.*}} i128 0, align 16
24 // CHECK: @AtomicStruct = {{.*}} { %struct.anon, [4 x i8] } zeroinitializer, align 16
25 // CHECK: @Atomic_fp128 = {{.*}} fp128 0xL00000000000000000000000000000000, align 16
26
27
28 // CHECK-LABEL: @fun0
29 // CHECK: ret i1 true
fun0()30 _Bool fun0() {
31 return __atomic_is_lock_free(16, &Int128_Atomic);
32 }
33
34 // CHECK-LABEL: @fun1
35 // CHECK: ret i1 true
fun1()36 _Bool fun1() {
37 return __atomic_always_lock_free(16, &Int128_Atomic);
38 }
39
40 // CHECK-LABEL: @fun2
41 // CHECK: ret i1 true
fun2()42 _Bool fun2() {
43 return __atomic_is_lock_free(16, &Int128_Al16);
44 }
45
46 // CHECK-LABEL: @fun3
47 // CHECK: ret i1 true
fun3()48 _Bool fun3() {
49 return __atomic_always_lock_free(16, &Int128_Al16);
50 }
51
52 // CHECK-LABEL: @fun4
53 // CHECK: call zeroext i1 @__atomic_is_lock_free
fun4()54 _Bool fun4() {
55 return __atomic_is_lock_free(16, &Int128);
56 }
57
58 // CHECK-LABEL: @fun5
59 // CHECK: ret i1 false
fun5()60 _Bool fun5() {
61 return __atomic_always_lock_free(16, &Int128);
62 }
63
64 // CHECK-LABEL: @fun6
65 // CHECK: ret i1 true
fun6()66 _Bool fun6() {
67 return __atomic_is_lock_free(16, 0);
68 }
69
70 // CHECK-LABEL: @fun7
71 // CHECK: ret i1 true
fun7()72 _Bool fun7() {
73 return __atomic_always_lock_free(16, 0);
74 }
75
76 // CHECK-LABEL: @fun8
77 // CHECK: ret i1 true
fun8()78 _Bool fun8() {
79 return __atomic_is_lock_free(16, &AtomicStruct);
80 }
81
82 // CHECK-LABEL: @fun9
83 // CHECK: ret i1 true
fun9()84 _Bool fun9() {
85 return __atomic_always_lock_free(16, &AtomicStruct);
86 }
87
88 // CHECK-LABEL: @fun10
89 // CHECK: ret i1 true
fun10()90 _Bool fun10() {
91 return atomic_is_lock_free(&Int128_Atomic);
92 }
93
94 // CHECK-LABEL: @fun11
95 // CHECK: ret i1 true
fun11()96 _Bool fun11() {
97 return __c11_atomic_is_lock_free(16);
98 }
99