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