1 // RUN: %clang_cc1 -no-opaque-pointers -triple arm-linux-gnueabi -emit-llvm %s -o - | FileCheck %s -check-prefix=ARM
2 // RUN: %clang_cc1 -no-opaque-pointers -triple powerpc-linux-gnu -emit-llvm %s -o - | FileCheck %s -check-prefix=PPC32
3 // RUN: %clang_cc1 -no-opaque-pointers -triple powerpc64-linux-gnu -emit-llvm %s -o - | FileCheck %s -check-prefix=PPC64
4 // RUN: %clang_cc1 -no-opaque-pointers -triple mipsel-linux-gnu -emit-llvm %s -o - | FileCheck %s -check-prefix=MIPS32
5 // RUN: %clang_cc1 -no-opaque-pointers -triple mipsisa32r6el-linux-gnu -emit-llvm %s -o - | FileCheck %s -check-prefix=MIPS32
6 // RUN: %clang_cc1 -no-opaque-pointers -triple mips64el-linux-gnu -emit-llvm %s -o - | FileCheck %s -check-prefix=MIPS64
7 // RUN: %clang_cc1 -no-opaque-pointers -triple mips64el-linux-gnuabi64 -emit-llvm %s -o - | FileCheck %s -check-prefix=MIPS64
8 // RUN: %clang_cc1 -no-opaque-pointers -triple mipsisa64r6el-linux-gnuabi64 -emit-llvm %s -o - | FileCheck %s -check-prefix=MIPS64
9 // RUN: %clang_cc1 -no-opaque-pointers -triple sparc-unknown-eabi -emit-llvm %s -o - | FileCheck %s -check-prefix=SPARCV8 -check-prefix=SPARC
10 // RUN: %clang_cc1 -no-opaque-pointers -triple sparcv9-unknown-eabi -emit-llvm %s -o - | FileCheck %s -check-prefix=SPARCV9 -check-prefix=SPARC
11 
12 unsigned char c1, c2;
13 unsigned short s1, s2;
14 unsigned int i1, i2;
15 unsigned long long ll1, ll2;
16 unsigned char a1[100], a2[100];
17 
18 enum memory_order {
19   memory_order_relaxed,
20   memory_order_consume,
21   memory_order_acquire,
22   memory_order_release,
23   memory_order_acq_rel,
24   memory_order_seq_cst
25 };
26 
27 void test1(void) {
28   (void)__atomic_load(&c1, &c2, memory_order_seq_cst);
29   (void)__atomic_store(&c1, &c2, memory_order_seq_cst);
30   (void)__atomic_load(&s1, &s2, memory_order_seq_cst);
31   (void)__atomic_store(&s1, &s2, memory_order_seq_cst);
32   (void)__atomic_load(&i1, &i2, memory_order_seq_cst);
33   (void)__atomic_store(&i1, &i2, memory_order_seq_cst);
34   (void)__atomic_load(&ll1, &ll2, memory_order_seq_cst);
35   (void)__atomic_store(&ll1, &ll2, memory_order_seq_cst);
36   (void)__atomic_load(&a1, &a2, memory_order_seq_cst);
37   (void)__atomic_store(&a1, &a2, memory_order_seq_cst);
38 
39 // ARM-LABEL: define{{.*}} void @test1
40 // ARM: = call{{.*}} zeroext i8 @__atomic_load_1(i8* noundef @c1
41 // ARM: call{{.*}} void @__atomic_store_1(i8* noundef @c1, i8 noundef zeroext
42 // ARM: = call{{.*}} zeroext i16 @__atomic_load_2(i8* noundef bitcast (i16* @s1 to i8*)
43 // ARM: call{{.*}} void @__atomic_store_2(i8* noundef bitcast (i16* @s1 to i8*), i16 noundef zeroext
44 // ARM: = call{{.*}} i32 @__atomic_load_4(i8* noundef bitcast (i32* @i1 to i8*)
45 // ARM: call{{.*}} void @__atomic_store_4(i8* noundef bitcast (i32* @i1 to i8*), i32 noundef
46 // ARM: = call{{.*}} i64 @__atomic_load_8(i8* noundef bitcast (i64* @ll1 to i8*)
47 // ARM: call{{.*}} void @__atomic_store_8(i8* noundef bitcast (i64* @ll1 to i8*), i64 noundef
48 // ARM: call{{.*}} void @__atomic_load(i32 noundef 100, i8* noundef getelementptr inbounds ([100 x i8], [100 x i8]* @a1, i32 0, i32 0), i8* noundef getelementptr inbounds ([100 x i8], [100 x i8]* @a2, i32 0, i32 0)
49 // ARM: call{{.*}} void @__atomic_store(i32 noundef 100, i8* noundef getelementptr inbounds ([100 x i8], [100 x i8]* @a1, i32 0, i32 0), i8* noundef getelementptr inbounds ([100 x i8], [100 x i8]* @a2, i32 0, i32 0)
50 
51 // PPC32-LABEL: define{{.*}} void @test1
52 // PPC32: = load atomic i8, i8* @c1 seq_cst, align 1
53 // PPC32: store atomic i8 {{.*}}, i8* @c1 seq_cst, align 1
54 // PPC32: = load atomic i16, i16* @s1 seq_cst, align 2
55 // PPC32: store atomic i16 {{.*}}, i16* @s1 seq_cst, align 2
56 // PPC32: = load atomic i32, i32* @i1 seq_cst, align 4
57 // PPC32: store atomic i32 {{.*}}, i32* @i1 seq_cst, align 4
58 // PPC32: = call i64 @__atomic_load_8(i8* noundef bitcast (i64* @ll1 to i8*)
59 // PPC32: call void @__atomic_store_8(i8* noundef bitcast (i64* @ll1 to i8*), i64
60 // PPC32: call void @__atomic_load(i32 noundef 100, i8* noundef getelementptr inbounds ([100 x i8], [100 x i8]* @a1, i32 0, i32 0), i8* noundef getelementptr inbounds ([100 x i8], [100 x i8]* @a2, i32 0, i32 0)
61 // PPC32: call void @__atomic_store(i32 noundef 100, i8* noundef getelementptr inbounds ([100 x i8], [100 x i8]* @a1, i32 0, i32 0), i8* noundef getelementptr inbounds ([100 x i8], [100 x i8]* @a2, i32 0, i32 0)
62 
63 // PPC64-LABEL: define{{.*}} void @test1
64 // PPC64: = load atomic i8, i8* @c1 seq_cst, align 1
65 // PPC64: store atomic i8 {{.*}}, i8* @c1 seq_cst, align 1
66 // PPC64: = load atomic i16, i16* @s1 seq_cst, align 2
67 // PPC64: store atomic i16 {{.*}}, i16* @s1 seq_cst, align 2
68 // PPC64: = load atomic i32, i32* @i1 seq_cst, align 4
69 // PPC64: store atomic i32 {{.*}}, i32* @i1 seq_cst, align 4
70 // PPC64: = load atomic i64, i64* @ll1 seq_cst, align 8
71 // PPC64: store atomic i64 {{.*}}, i64* @ll1 seq_cst, align 8
72 // PPC64: call void @__atomic_load(i64 noundef 100, i8* noundef getelementptr inbounds ([100 x i8], [100 x i8]* @a1, i32 0, i32 0), i8* noundef getelementptr inbounds ([100 x i8], [100 x i8]* @a2, i32 0, i32 0)
73 // PPC64: call void @__atomic_store(i64 noundef 100, i8* noundef getelementptr inbounds ([100 x i8], [100 x i8]* @a1, i32 0, i32 0), i8* noundef getelementptr inbounds ([100 x i8], [100 x i8]* @a2, i32 0, i32 0)
74 
75 // MIPS32-LABEL: define{{.*}} void @test1
76 // MIPS32: = load atomic i8, i8* @c1 seq_cst, align 1
77 // MIPS32: store atomic i8 {{.*}}, i8* @c1 seq_cst, align 1
78 // MIPS32: = load atomic i16, i16* @s1 seq_cst, align 2
79 // MIPS32: store atomic i16 {{.*}}, i16* @s1 seq_cst, align 2
80 // MIPS32: = load atomic i32, i32* @i1 seq_cst, align 4
81 // MIPS32: store atomic i32 {{.*}}, i32* @i1 seq_cst, align 4
82 // MIPS32: call i64 @__atomic_load_8(i8* noundef bitcast (i64* @ll1 to i8*)
83 // MIPS32: call void @__atomic_store_8(i8* noundef bitcast (i64* @ll1 to i8*), i64
84 // MIPS32: call void @__atomic_load(i32 noundef signext 100, i8* noundef getelementptr inbounds ([100 x i8], [100 x i8]* @a1, i32 0, i32 0), i8* noundef getelementptr inbounds ([100 x i8], [100 x i8]* @a2, i32 0, i32 0)
85 // MIPS32: call void @__atomic_store(i32 noundef signext 100, i8* noundef getelementptr inbounds ([100 x i8], [100 x i8]* @a1, i32 0, i32 0), i8* noundef getelementptr inbounds ([100 x i8], [100 x i8]* @a2, i32 0, i32 0)
86 
87 // MIPS64-LABEL: define{{.*}} void @test1
88 // MIPS64: = load atomic i8, i8* @c1 seq_cst, align 1
89 // MIPS64: store atomic i8 {{.*}}, i8* @c1 seq_cst, align 1
90 // MIPS64: = load atomic i16, i16* @s1 seq_cst, align 2
91 // MIPS64: store atomic i16 {{.*}}, i16* @s1 seq_cst, align 2
92 // MIPS64: = load atomic i32, i32* @i1 seq_cst, align 4
93 // MIPS64: store atomic i32 {{.*}}, i32* @i1 seq_cst, align 4
94 // MIPS64: = load atomic i64, i64* @ll1 seq_cst, align 8
95 // MIPS64: store atomic i64 {{.*}}, i64* @ll1 seq_cst, align 8
96 // MIPS64: call void @__atomic_load(i64 noundef zeroext 100, i8* noundef getelementptr inbounds ([100 x i8], [100 x i8]* @a1, i32 0, i32 0)
97 // MIPS64: call void @__atomic_store(i64 noundef zeroext 100, i8* noundef getelementptr inbounds ([100 x i8], [100 x i8]* @a1, i32 0, i32 0), i8* noundef getelementptr inbounds ([100 x i8], [100 x i8]* @a2, i32 0, i32 0)
98 
99 // SPARC-LABEL: define{{.*}} void @test1
100 // SPARC: = load atomic i8, i8* @c1 seq_cst, align 1
101 // SPARC: store atomic i8 {{.*}}, i8* @c1 seq_cst, align 1
102 // SPARC: = load atomic i16, i16* @s1 seq_cst, align 2
103 // SPARC: store atomic i16 {{.*}}, i16* @s1 seq_cst, align 2
104 // SPARC: = load atomic i32, i32* @i1 seq_cst, align 4
105 // SPARC: store atomic i32 {{.*}}, i32* @i1 seq_cst, align 4
106 // SPARCV8: call i64 @__atomic_load_8(i8* noundef bitcast (i64* @ll1 to i8*)
107 // SPARCV8: call void @__atomic_store_8(i8* noundef bitcast (i64* @ll1 to i8*), i64
108 // SPARCV9: load atomic i64, i64* @ll1 seq_cst, align 8
109 // SPARCV9: store atomic i64 {{.*}}, i64* @ll1 seq_cst, align 8
110 // SPARCV8: call void @__atomic_load(i32 noundef 100, i8* noundef getelementptr inbounds ([100 x i8], [100 x i8]* @a1, i32 0, i32 0), i8* noundef getelementptr inbounds ([100 x i8], [100 x i8]* @a2, i32 0, i32 0)
111 // SPARCV8: call void @__atomic_store(i32 noundef 100, i8* noundef getelementptr inbounds ([100 x i8], [100 x i8]* @a1, i32 0, i32 0), i8* noundef getelementptr inbounds ([100 x i8], [100 x i8]* @a2, i32 0, i32 0)
112 }
113