annotate clang/test/CodeGen/atomic-ops-libcall.c @ 207:2e18cbf3894f

LLVM12
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Tue, 08 Jun 2021 06:07:14 +0900
parents 1d019706d866
children c4bab56944e8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
150
anatofuz
parents:
diff changeset
1 // RUN: %clang_cc1 < %s -triple armv5e-none-linux-gnueabi -emit-llvm -O1 | FileCheck %s
anatofuz
parents:
diff changeset
2
anatofuz
parents:
diff changeset
3 // FIXME: This file should not be checking -O1 output.
anatofuz
parents:
diff changeset
4 // Ie, it is testing many IR optimizer passes as part of front-end verification.
anatofuz
parents:
diff changeset
5
anatofuz
parents:
diff changeset
6 enum memory_order {
anatofuz
parents:
diff changeset
7 memory_order_relaxed, memory_order_consume, memory_order_acquire,
anatofuz
parents:
diff changeset
8 memory_order_release, memory_order_acq_rel, memory_order_seq_cst
anatofuz
parents:
diff changeset
9 };
anatofuz
parents:
diff changeset
10
anatofuz
parents:
diff changeset
11 int *test_c11_atomic_fetch_add_int_ptr(_Atomic(int *) *p) {
anatofuz
parents:
diff changeset
12 // CHECK: test_c11_atomic_fetch_add_int_ptr
anatofuz
parents:
diff changeset
13 // CHECK: {{%[^ ]*}} = call i32 @__atomic_fetch_add_4(i8* {{%[0-9]+}}, i32 12, i32 5)
anatofuz
parents:
diff changeset
14 return __c11_atomic_fetch_add(p, 3, memory_order_seq_cst);
anatofuz
parents:
diff changeset
15 }
anatofuz
parents:
diff changeset
16
anatofuz
parents:
diff changeset
17 int *test_c11_atomic_fetch_sub_int_ptr(_Atomic(int *) *p) {
anatofuz
parents:
diff changeset
18 // CHECK: test_c11_atomic_fetch_sub_int_ptr
anatofuz
parents:
diff changeset
19 // CHECK: {{%[^ ]*}} = call i32 @__atomic_fetch_sub_4(i8* {{%[0-9]+}}, i32 20, i32 5)
anatofuz
parents:
diff changeset
20 return __c11_atomic_fetch_sub(p, 5, memory_order_seq_cst);
anatofuz
parents:
diff changeset
21 }
anatofuz
parents:
diff changeset
22
anatofuz
parents:
diff changeset
23 int test_c11_atomic_fetch_add_int(_Atomic(int) *p) {
anatofuz
parents:
diff changeset
24 // CHECK: test_c11_atomic_fetch_add_int
anatofuz
parents:
diff changeset
25 // CHECK: {{%[^ ]*}} = call i32 @__atomic_fetch_add_4(i8* {{%[0-9]+}}, i32 3, i32 5)
anatofuz
parents:
diff changeset
26 return __c11_atomic_fetch_add(p, 3, memory_order_seq_cst);
anatofuz
parents:
diff changeset
27 }
anatofuz
parents:
diff changeset
28
anatofuz
parents:
diff changeset
29 int test_c11_atomic_fetch_sub_int(_Atomic(int) *p) {
anatofuz
parents:
diff changeset
30 // CHECK: test_c11_atomic_fetch_sub_int
anatofuz
parents:
diff changeset
31 // CHECK: {{%[^ ]*}} = call i32 @__atomic_fetch_sub_4(i8* {{%[0-9]+}}, i32 5, i32 5)
anatofuz
parents:
diff changeset
32 return __c11_atomic_fetch_sub(p, 5, memory_order_seq_cst);
anatofuz
parents:
diff changeset
33 }
anatofuz
parents:
diff changeset
34
anatofuz
parents:
diff changeset
35 int *fp2a(int **p) {
anatofuz
parents:
diff changeset
36 // CHECK: @fp2a
anatofuz
parents:
diff changeset
37 // CHECK: {{%[^ ]*}} = call i32 @__atomic_fetch_sub_4(i8* {{%[0-9]+}}, i32 4, i32 0)
anatofuz
parents:
diff changeset
38 // Note, the GNU builtins do not multiply by sizeof(T)!
anatofuz
parents:
diff changeset
39 return __atomic_fetch_sub(p, 4, memory_order_relaxed);
anatofuz
parents:
diff changeset
40 }
anatofuz
parents:
diff changeset
41
anatofuz
parents:
diff changeset
42 int test_atomic_fetch_add(int *p) {
anatofuz
parents:
diff changeset
43 // CHECK: test_atomic_fetch_add
anatofuz
parents:
diff changeset
44 // CHECK: {{%[^ ]*}} = call i32 @__atomic_fetch_add_4(i8* {{%[0-9]+}}, i32 55, i32 5)
anatofuz
parents:
diff changeset
45 return __atomic_fetch_add(p, 55, memory_order_seq_cst);
anatofuz
parents:
diff changeset
46 }
anatofuz
parents:
diff changeset
47
anatofuz
parents:
diff changeset
48 int test_atomic_fetch_sub(int *p) {
anatofuz
parents:
diff changeset
49 // CHECK: test_atomic_fetch_sub
anatofuz
parents:
diff changeset
50 // CHECK: {{%[^ ]*}} = call i32 @__atomic_fetch_sub_4(i8* {{%[0-9]+}}, i32 55, i32 5)
anatofuz
parents:
diff changeset
51 return __atomic_fetch_sub(p, 55, memory_order_seq_cst);
anatofuz
parents:
diff changeset
52 }
anatofuz
parents:
diff changeset
53
anatofuz
parents:
diff changeset
54 int test_atomic_fetch_and(int *p) {
anatofuz
parents:
diff changeset
55 // CHECK: test_atomic_fetch_and
anatofuz
parents:
diff changeset
56 // CHECK: {{%[^ ]*}} = call i32 @__atomic_fetch_and_4(i8* {{%[0-9]+}}, i32 55, i32 5)
anatofuz
parents:
diff changeset
57 return __atomic_fetch_and(p, 55, memory_order_seq_cst);
anatofuz
parents:
diff changeset
58 }
anatofuz
parents:
diff changeset
59
anatofuz
parents:
diff changeset
60 int test_atomic_fetch_or(int *p) {
anatofuz
parents:
diff changeset
61 // CHECK: test_atomic_fetch_or
anatofuz
parents:
diff changeset
62 // CHECK: {{%[^ ]*}} = call i32 @__atomic_fetch_or_4(i8* {{%[0-9]+}}, i32 55, i32 5)
anatofuz
parents:
diff changeset
63 return __atomic_fetch_or(p, 55, memory_order_seq_cst);
anatofuz
parents:
diff changeset
64 }
anatofuz
parents:
diff changeset
65
anatofuz
parents:
diff changeset
66 int test_atomic_fetch_xor(int *p) {
anatofuz
parents:
diff changeset
67 // CHECK: test_atomic_fetch_xor
anatofuz
parents:
diff changeset
68 // CHECK: {{%[^ ]*}} = call i32 @__atomic_fetch_xor_4(i8* {{%[0-9]+}}, i32 55, i32 5)
anatofuz
parents:
diff changeset
69 return __atomic_fetch_xor(p, 55, memory_order_seq_cst);
anatofuz
parents:
diff changeset
70 }
anatofuz
parents:
diff changeset
71
anatofuz
parents:
diff changeset
72 int test_atomic_fetch_nand(int *p) {
anatofuz
parents:
diff changeset
73 // CHECK: test_atomic_fetch_nand
anatofuz
parents:
diff changeset
74 // CHECK: {{%[^ ]*}} = call i32 @__atomic_fetch_nand_4(i8* {{%[0-9]+}}, i32 55, i32 5)
anatofuz
parents:
diff changeset
75 return __atomic_fetch_nand(p, 55, memory_order_seq_cst);
anatofuz
parents:
diff changeset
76 }
anatofuz
parents:
diff changeset
77
anatofuz
parents:
diff changeset
78 int test_atomic_add_fetch(int *p) {
anatofuz
parents:
diff changeset
79 // CHECK: test_atomic_add_fetch
anatofuz
parents:
diff changeset
80 // CHECK: [[CALL:%[^ ]*]] = call i32 @__atomic_fetch_add_4(i8* {{%[0-9]+}}, i32 55, i32 5)
anatofuz
parents:
diff changeset
81 // CHECK: {{%[^ ]*}} = add i32 [[CALL]], 55
anatofuz
parents:
diff changeset
82 return __atomic_add_fetch(p, 55, memory_order_seq_cst);
anatofuz
parents:
diff changeset
83 }
anatofuz
parents:
diff changeset
84
anatofuz
parents:
diff changeset
85 int test_atomic_sub_fetch(int *p) {
anatofuz
parents:
diff changeset
86 // CHECK: test_atomic_sub_fetch
anatofuz
parents:
diff changeset
87 // CHECK: [[CALL:%[^ ]*]] = call i32 @__atomic_fetch_sub_4(i8* {{%[0-9]+}}, i32 55, i32 5)
anatofuz
parents:
diff changeset
88 // CHECK: {{%[^ ]*}} = add i32 [[CALL]], -55
anatofuz
parents:
diff changeset
89 return __atomic_sub_fetch(p, 55, memory_order_seq_cst);
anatofuz
parents:
diff changeset
90 }
anatofuz
parents:
diff changeset
91
anatofuz
parents:
diff changeset
92 int test_atomic_and_fetch(int *p) {
anatofuz
parents:
diff changeset
93 // CHECK: test_atomic_and_fetch
anatofuz
parents:
diff changeset
94 // CHECK: [[CALL:%[^ ]*]] = call i32 @__atomic_fetch_and_4(i8* {{%[0-9]+}}, i32 55, i32 5)
anatofuz
parents:
diff changeset
95 // CHECK: {{%[^ ]*}} = and i32 [[CALL]], 55
anatofuz
parents:
diff changeset
96 return __atomic_and_fetch(p, 55, memory_order_seq_cst);
anatofuz
parents:
diff changeset
97 }
anatofuz
parents:
diff changeset
98
anatofuz
parents:
diff changeset
99 int test_atomic_or_fetch(int *p) {
anatofuz
parents:
diff changeset
100 // CHECK: test_atomic_or_fetch
anatofuz
parents:
diff changeset
101 // CHECK: [[CALL:%[^ ]*]] = call i32 @__atomic_fetch_or_4(i8* {{%[0-9]+}}, i32 55, i32 5)
anatofuz
parents:
diff changeset
102 // CHECK: {{%[^ ]*}} = or i32 [[CALL]], 55
anatofuz
parents:
diff changeset
103 return __atomic_or_fetch(p, 55, memory_order_seq_cst);
anatofuz
parents:
diff changeset
104 }
anatofuz
parents:
diff changeset
105
anatofuz
parents:
diff changeset
106 int test_atomic_xor_fetch(int *p) {
anatofuz
parents:
diff changeset
107 // CHECK: test_atomic_xor_fetch
anatofuz
parents:
diff changeset
108 // CHECK: [[CALL:%[^ ]*]] = call i32 @__atomic_fetch_xor_4(i8* {{%[0-9]+}}, i32 55, i32 5)
anatofuz
parents:
diff changeset
109 // CHECK: {{%[^ ]*}} = xor i32 [[CALL]], 55
anatofuz
parents:
diff changeset
110 return __atomic_xor_fetch(p, 55, memory_order_seq_cst);
anatofuz
parents:
diff changeset
111 }
anatofuz
parents:
diff changeset
112
anatofuz
parents:
diff changeset
113 int test_atomic_nand_fetch(int *p) {
anatofuz
parents:
diff changeset
114 // CHECK: test_atomic_nand_fetch
anatofuz
parents:
diff changeset
115 // CHECK: [[CALL:%[^ ]*]] = call i32 @__atomic_fetch_nand_4(i8* {{%[0-9]+}}, i32 55, i32 5)
anatofuz
parents:
diff changeset
116 // FIXME: We should not be checking optimized IR. It changes independently of clang.
anatofuz
parents:
diff changeset
117 // FIXME-CHECK: [[AND:%[^ ]*]] = and i32 [[CALL]], 55
anatofuz
parents:
diff changeset
118 // FIXME-CHECK: {{%[^ ]*}} = xor i32 [[AND]], -1
anatofuz
parents:
diff changeset
119 return __atomic_nand_fetch(p, 55, memory_order_seq_cst);
anatofuz
parents:
diff changeset
120 }