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