llvm-project
63 строки · 1.8 Кб
1// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -fobjc-runtime-has-weak -fblocks -fobjc-arc -o - %s | FileCheck %s
2
3// A test to ensure that we generate fused calls at -O0.
4
5@class Test0;
6Test0 *test0(void) {
7extern Test0 *test0_helper;
8return test0_helper;
9
10// CHECK: [[LD:%.*]] = load ptr, ptr @test0_helper
11// CHECK-NEXT: [[T1:%.*]] = tail call ptr @llvm.objc.retainAutoreleaseReturnValue(ptr [[LD]])
12// CHECK-NEXT: ret ptr [[T1]]
13}
14
15id test1(void) {
16extern id test1_helper;
17return test1_helper;
18
19// CHECK: [[LD:%.*]] = load ptr, ptr @test1_helper
20// CHECK-NEXT: [[T0:%.*]] = tail call ptr @llvm.objc.retainAutoreleaseReturnValue(ptr [[LD]])
21// CHECK-NEXT: ret ptr [[T0]]
22}
23
24void test2(void) {
25// CHECK: [[X:%.*]] = alloca ptr
26// CHECK-NEXT: store ptr null, ptr [[X]]
27// CHECK-NEXT: call void @llvm.objc.destroyWeak(ptr [[X]])
28// CHECK-NEXT: ret void
29__weak id x;
30}
31
32id test3(void) {
33extern id test3_helper(void);
34// CHECK: [[T0:%.*]] = call ptr @test3_helper()
35// CHECK-NEXT: ret ptr [[T0]]
36return test3_helper();
37}
38
39@interface Test4 { id x; } @end
40@interface Test4_sub : Test4 { id y; } @end
41Test4 *test4(void) {
42extern Test4_sub *test4_helper(void);
43// CHECK: [[T0:%.*]] = call ptr @test4_helper()
44// CHECK-NEXT: ret ptr [[T0]]
45return test4_helper();
46}
47
48@class Test5;
49void test5(void) {
50Test5 *x, *y;
51if ((x = y))
52y = 0;
53
54// CHECK-LABEL: define{{.*}} void @test5()
55// CHECK: [[X:%.*]] = alloca ptr,
56// CHECK-NEXT: [[Y:%.*]] = alloca ptr,
57// CHECK-NEXT: store ptr null, ptr [[X]],
58// CHECK-NEXT: store ptr null, ptr [[Y]],
59// CHECK-NEXT: [[T0:%.*]] = load ptr, ptr [[Y]],
60// CHECK-NEXT: call void @llvm.objc.storeStrong(ptr [[X]], ptr [[T0]])
61// CHECK-NEXT: [[T3:%.*]] = icmp ne ptr [[T0]], null
62// CHECK-NEXT: br i1 [[T3]],
63}
64