2017-02-14 07:09:56 +08:00
|
|
|
// RUN: %clang_cc1 -std=gnu++98 -triple x86_64-apple-darwin10 -emit-llvm -fobjc-runtime-has-weak -fblocks -fobjc-arc -o - %s | FileCheck %s
|
2013-01-22 11:56:22 +08:00
|
|
|
|
|
|
|
// CHECK: [[A:.*]] = type { i64, [10 x i8*] }
|
|
|
|
|
2016-09-21 02:38:54 +08:00
|
|
|
// CHECK: [[LAYOUT0:@.*]] = private unnamed_addr constant [3 x i8] c" 9\00"
|
2013-01-22 11:56:22 +08:00
|
|
|
|
|
|
|
// rdar://13045269
|
|
|
|
// If a __block variable requires extended layout information *and*
|
|
|
|
// a copy/dispose helper, be sure to adjust the offsets used in copy/dispose.
|
|
|
|
namespace test0 {
|
|
|
|
struct A {
|
|
|
|
unsigned long count;
|
|
|
|
id data[10];
|
|
|
|
};
|
|
|
|
|
|
|
|
void foo() {
|
|
|
|
__block A v;
|
|
|
|
}
|
2013-08-15 14:47:53 +08:00
|
|
|
// CHECK-LABEL: define void @_ZN5test03fooEv()
|
2013-01-22 11:56:22 +08:00
|
|
|
// CHECK: [[V:%.*]] = alloca [[BYREF_A:%.*]], align 8
|
2015-02-28 03:18:17 +08:00
|
|
|
// CHECK: [[T0:%.*]] = getelementptr inbounds [[BYREF_A]], [[BYREF_A]]* [[V]], i32 0, i32 4
|
2013-01-22 11:56:22 +08:00
|
|
|
// CHECK-NEXT: store i8* bitcast (void (i8*, i8*)* [[COPY_HELPER:@.*]] to i8*), i8** [[T0]]
|
2015-02-28 03:18:17 +08:00
|
|
|
// CHECK-NEXT: [[T0:%.*]] = getelementptr inbounds [[BYREF_A]], [[BYREF_A]]* [[V]], i32 0, i32 5
|
2013-01-22 11:56:22 +08:00
|
|
|
// CHECK-NEXT: store i8* bitcast (void (i8*)* [[DISPOSE_HELPER:@.*]] to i8*), i8** [[T0]]
|
2015-02-28 03:18:17 +08:00
|
|
|
// CHECK-NEXT: [[T0:%.*]] = getelementptr inbounds [[BYREF_A]], [[BYREF_A]]* [[V]], i32 0, i32 6
|
2015-03-14 02:21:46 +08:00
|
|
|
// CHECK-NEXT: store i8* getelementptr inbounds ([3 x i8], [3 x i8]* [[LAYOUT0]], i32 0, i32 0), i8** [[T0]]
|
2015-02-28 03:18:17 +08:00
|
|
|
// CHECK-NEXT: [[T0:%.*]] = getelementptr inbounds [[BYREF_A]], [[BYREF_A]]* [[V]], i32 0, i32 7
|
2013-01-22 11:56:22 +08:00
|
|
|
// CHECK-NEXT: call void @_ZN5test01AC1Ev([[A]]* [[T0]])
|
2015-02-28 03:18:17 +08:00
|
|
|
// CHECK-NEXT: [[T0:%.*]] = getelementptr inbounds [[BYREF_A]], [[BYREF_A]]* [[V]], i32 0, i32 7
|
2013-01-22 11:56:22 +08:00
|
|
|
// CHECK-NEXT: [[T1:%.*]] = bitcast [[BYREF_A]]* [[V]] to i8*
|
|
|
|
// CHECK-NEXT: call void @_Block_object_dispose(i8* [[T1]], i32 8)
|
|
|
|
// CHECK-NEXT: call void @_ZN5test01AD1Ev([[A]]* [[T0]])
|
|
|
|
// CHECK-NEXT: ret void
|
|
|
|
|
|
|
|
// CHECK: define internal void [[COPY_HELPER]](
|
|
|
|
// CHECK: [[T0:%.*]] = bitcast i8* {{.*}} to [[BYREF_A]]*
|
2015-02-28 03:18:17 +08:00
|
|
|
// CHECK-NEXT: [[T1:%.*]] = getelementptr inbounds [[BYREF_A]], [[BYREF_A]]* [[T0]], i32 0, i32 7
|
2013-01-22 11:56:22 +08:00
|
|
|
// CHECK-NEXT: load
|
|
|
|
// CHECK-NEXT: [[T2:%.*]] = bitcast i8* {{.*}} to [[BYREF_A]]*
|
2015-02-28 03:18:17 +08:00
|
|
|
// CHECK-NEXT: [[T3:%.*]] = getelementptr inbounds [[BYREF_A]], [[BYREF_A]]* [[T2]], i32 0, i32 7
|
2014-07-18 23:52:10 +08:00
|
|
|
// CHECK-NEXT: call void @_ZN5test01AC1ERKS0_([[A]]* [[T1]], [[A]]* dereferenceable({{[0-9]+}}) [[T3]])
|
2013-01-22 11:56:22 +08:00
|
|
|
// CHECK-NEXT: ret void
|
|
|
|
|
|
|
|
// CHECK: define internal void [[DISPOSE_HELPER]](
|
|
|
|
// CHECK: [[T0:%.*]] = bitcast i8* {{.*}} to [[BYREF_A]]*
|
2015-02-28 03:18:17 +08:00
|
|
|
// CHECK-NEXT: [[T1:%.*]] = getelementptr inbounds [[BYREF_A]], [[BYREF_A]]* [[T0]], i32 0, i32 7
|
2013-01-22 11:56:22 +08:00
|
|
|
// CHECK-NEXT: call void @_ZN5test01AD1Ev([[A]]* [[T1]])
|
|
|
|
// CHECK-NEXT: ret void
|
|
|
|
}
|