Douglas Gregor | 47bfcca | 2012-04-12 20:42:30 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 %s -emit-llvm -O1 -o - -triple=i686-apple-darwin9 | FileCheck %s |
David Chisnall | 3a3c9b2 | 2012-04-11 15:29:15 +0000 | [diff] [blame] | 2 | struct A { |
| 3 | _Atomic(int) i; |
| 4 | A(int j); |
| 5 | void v(int j); |
| 6 | }; |
| 7 | // Storing to atomic values should be atomic |
| 8 | // CHECK: store atomic i32 |
| 9 | void A::v(int j) { i = j; } |
| 10 | // Initialising atomic values should not be atomic |
| 11 | // CHECK-NOT: store atomic |
| 12 | A::A(int j) : i(j) {} |
David Chisnall | 5d70cfd | 2012-04-11 17:24:05 +0000 | [diff] [blame] | 13 | |
| 14 | struct B { |
| 15 | int i; |
| 16 | B(int x) : i(x) {} |
| 17 | }; |
| 18 | |
| 19 | _Atomic(B) b; |
| 20 | |
| 21 | // CHECK: define void @_Z11atomic_initR1Ai |
| 22 | void atomic_init(A& a, int i) { |
| 23 | // CHECK-NOT: atomic |
Douglas Gregor | 47bfcca | 2012-04-12 20:42:30 +0000 | [diff] [blame] | 24 | // CHECK: tail call void @_ZN1BC1Ei |
Richard Smith | 944b562 | 2012-04-11 18:00:46 +0000 | [diff] [blame] | 25 | __c11_atomic_init(&b, B(i)); |
Douglas Gregor | 47bfcca | 2012-04-12 20:42:30 +0000 | [diff] [blame] | 26 | // CHECK-NEXT: ret void |
David Chisnall | 5d70cfd | 2012-04-11 17:24:05 +0000 | [diff] [blame] | 27 | } |
Douglas Gregor | 47bfcca | 2012-04-12 20:42:30 +0000 | [diff] [blame] | 28 | |
| 29 | // CHECK: define void @_Z16atomic_init_boolPU7_Atomicbb |
| 30 | void atomic_init_bool(_Atomic(bool) *ab, bool b) { |
| 31 | // CHECK-NOT: atomic |
| 32 | // CHECK: {{zext i1.*to i8}} |
| 33 | // CHECK-NEXT: store i8 |
| 34 | __c11_atomic_init(ab, b); |
| 35 | // CHECK-NEXT: ret void |
| 36 | } |
| 37 | |
| 38 | struct AtomicBoolMember { |
| 39 | _Atomic(bool) ab; |
| 40 | AtomicBoolMember(bool b); |
| 41 | }; |
| 42 | |
| 43 | // CHECK: define void @_ZN16AtomicBoolMemberC2Eb |
| 44 | // CHECK: {{zext i1.*to i8}} |
| 45 | // CHECK-NEXT: store i8 |
| 46 | // CHECK-NEXT: ret void |
| 47 | AtomicBoolMember::AtomicBoolMember(bool b) : ab(b) { } |
| 48 | |