1 // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -fobjc-runtime-has-weak -fblocks -fobjc-arc -o - %s | FileCheck %s 2 3 // CHECK: [[A:.*]] = type { i64, [10 x i8*] } 4 5 // CHECK: [[LAYOUT0:@.*]] = internal global [3 x i8] c" 9\00" 6 7 // rdar://13045269 8 // If a __block variable requires extended layout information *and* 9 // a copy/dispose helper, be sure to adjust the offsets used in copy/dispose. 10 namespace test0 { 11 struct A { 12 unsigned long count; 13 id data[10]; 14 }; 15 16 void foo() { 17 __block A v; 18 } 19 // CHECK: define void @_ZN5test03fooEv() 20 // CHECK: [[V:%.*]] = alloca [[BYREF_A:%.*]], align 8 21 // CHECK: [[T0:%.*]] = getelementptr inbounds [[BYREF_A]]* [[V]], i32 0, i32 4 22 // CHECK-NEXT: store i8* bitcast (void (i8*, i8*)* [[COPY_HELPER:@.*]] to i8*), i8** [[T0]] 23 // CHECK-NEXT: [[T0:%.*]] = getelementptr inbounds [[BYREF_A]]* [[V]], i32 0, i32 5 24 // CHECK-NEXT: store i8* bitcast (void (i8*)* [[DISPOSE_HELPER:@.*]] to i8*), i8** [[T0]] 25 // CHECK-NEXT: [[T0:%.*]] = getelementptr inbounds [[BYREF_A]]* [[V]], i32 0, i32 6 26 // CHECK-NEXT: store i8* getelementptr inbounds ([3 x i8]* [[LAYOUT0]], i32 0, i32 0), i8** [[T0]] 27 // CHECK-NEXT: [[T0:%.*]] = getelementptr inbounds [[BYREF_A]]* [[V]], i32 0, i32 7 28 // CHECK-NEXT: call void @_ZN5test01AC1Ev([[A]]* [[T0]]) 29 // CHECK-NEXT: [[T0:%.*]] = getelementptr inbounds [[BYREF_A]]* [[V]], i32 0, i32 7 30 // CHECK-NEXT: [[T1:%.*]] = bitcast [[BYREF_A]]* [[V]] to i8* 31 // CHECK-NEXT: call void @_Block_object_dispose(i8* [[T1]], i32 8) 32 // CHECK-NEXT: call void @_ZN5test01AD1Ev([[A]]* [[T0]]) 33 // CHECK-NEXT: ret void 34 35 // CHECK: define internal void [[COPY_HELPER]]( 36 // CHECK: [[T0:%.*]] = bitcast i8* {{.*}} to [[BYREF_A]]* 37 // CHECK-NEXT: [[T1:%.*]] = getelementptr inbounds [[BYREF_A]]* [[T0]], i32 0, i32 7 38 // CHECK-NEXT: load 39 // CHECK-NEXT: [[T2:%.*]] = bitcast i8* {{.*}} to [[BYREF_A]]* 40 // CHECK-NEXT: [[T3:%.*]] = getelementptr inbounds [[BYREF_A]]* [[T2]], i32 0, i32 7 41 // CHECK-NEXT: call void @_ZN5test01AC1ERKS0_([[A]]* [[T1]], [[A]]* [[T3]]) 42 // CHECK-NEXT: ret void 43 44 // CHECK: define internal void [[DISPOSE_HELPER]]( 45 // CHECK: [[T0:%.*]] = bitcast i8* {{.*}} to [[BYREF_A]]* 46 // CHECK-NEXT: [[T1:%.*]] = getelementptr inbounds [[BYREF_A]]* [[T0]], i32 0, i32 7 47 // CHECK-NEXT: call void @_ZN5test01AD1Ev([[A]]* [[T1]]) 48 // CHECK-NEXT: ret void 49 } 50