1 // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -fobjc-arc -fobjc-runtime-has-weak -o - %s | FileCheck %s
3 // CHECK: %[[STRUCT_TRIVIAL:.*]] = type { i32 }
4 // CHECK: %[[STRUCT_TRIVIALBIG:.*]] = type { [64 x i32] }
5 // CHECK: %[[STRUCT_STRONG:.*]] = type { ptr }
6 // CHECK: %[[STRUCT_WEAK:.*]] = type { ptr }
24 // CHECK: define{{.*}} i32 @testTrivial()
25 // CHECK: %[[RETVAL:.*]] = alloca %[[STRUCT_TRIVIAL]], align 4
26 // CHECK-NEXT: call void @func0(ptr noundef %[[RETVAL]])
30 void func0(Trivial *);
32 Trivial testTrivial(void) {
38 void func1(TrivialBig *);
40 // CHECK: define{{.*}} void @testTrivialBig(ptr dead_on_unwind noalias writable sret(%[[STRUCT_TRIVIALBIG]]) align 4 %[[AGG_RESULT:.*]])
41 // CHECK: call void @func1(ptr noundef %[[AGG_RESULT]])
42 // CHECK-NEXT: ret void
44 TrivialBig testTrivialBig(void) {
50 // CHECK: define{{.*}} ptr @testStrong()
51 // CHECK: %[[RETVAL:.*]] = alloca %[[STRUCT_STRONG]], align 8
52 // CHECK: %[[NRVO:.*]] = alloca i1, align 1
53 // CHECK: call void @__default_constructor_8_s0(ptr %[[RETVAL]])
54 // CHECK: store i1 true, ptr %[[NRVO]], align 1
55 // CHECK: %[[NRVO_VAL:.*]] = load i1, ptr %[[NRVO]], align 1
56 // CHECK: br i1 %[[NRVO_VAL]],
58 // CHECK: call void @__destructor_8_s0(ptr %[[RETVAL]])
61 // CHECK: %[[COERCE_DIVE:.*]] = getelementptr inbounds nuw %[[STRUCT_STRONG]], ptr %[[RETVAL]], i32 0, i32 0
62 // CHECK: %[[V2:.*]] = load ptr, ptr %[[COERCE_DIVE]], align 8
63 // CHECK: ret ptr %[[V2]]
65 Strong testStrong(void) {
70 // CHECK: define{{.*}} void @testWeak(ptr dead_on_unwind noalias writable sret(%[[STRUCT_WEAK]]) align 8 %[[AGG_RESULT:.*]])
71 // CHECK: %[[NRVO:.*]] = alloca i1, align 1
72 // CHECK: call void @__default_constructor_8_w0(ptr %[[AGG_RESULT]])
73 // CHECK: store i1 true, ptr %[[NRVO]], align 1
74 // CHECK: %[[NRVO_VAL:.*]] = load i1, ptr %[[NRVO]], align 1
75 // CHECK: br i1 %[[NRVO_VAL]],
77 // CHECK: call void @__destructor_8_w0(ptr %[[AGG_RESULT]])
88 // CHECK: define{{.*}} void @testWeak2(
89 // CHECK: call void @__default_constructor_8_w0(
90 // CHECK: call void @__default_constructor_8_w0(
91 // CHECK: call void @__copy_constructor_8_8_w0(
92 // CHECK: call void @__copy_constructor_8_8_w0(
93 // CHECK: call void @__destructor_8_w0(
94 // CHECK: call void @__destructor_8_w0(
96 Weak testWeak2(int c) {
104 // CHECK: define internal void @"\01-[C1 foo1]"(ptr dead_on_unwind noalias writable sret(%[[STRUCT_WEAK]]) align 8 %[[AGG_RESULT:.*]], ptr noundef %{{.*}}, ptr noundef %{{.*}})
105 // CHECK: %[[NRVO:.*]] = alloca i1, align 1
106 // CHECK: call void @__default_constructor_8_w0(ptr %[[AGG_RESULT]])
107 // CHECK: store i1 true, ptr %[[NRVO]], align 1
108 // CHECK: %[[NRVO_VAL:.*]] = load i1, ptr %[[NRVO]], align 1
109 // CHECK: br i1 %[[NRVO_VAL]],
111 // CHECK: call void @__destructor_8_w0(ptr %[[AGG_RESULT]])
117 __attribute__((objc_root_class))