1 ; This file consists of various tests which ensure that the objc-arc-annotations
2 ; are working correctly. In the future, I will use this in other lit tests to
3 ; check the data flow analysis of ARC.
6 ; RUN: opt -S -objc-arc -enable-objc-arc-annotations < %s | FileCheck %s
8 declare i8* @objc_retain(i8*)
9 declare i8* @objc_retainAutoreleasedReturnValue(i8*)
10 declare void @objc_release(i8*)
11 declare i8* @objc_autorelease(i8*)
12 declare i8* @objc_autoreleaseReturnValue(i8*)
13 declare void @objc_autoreleasePoolPop(i8*)
14 declare i8* @objc_autoreleasePoolPush()
15 declare i8* @objc_retainBlock(i8*)
17 declare i8* @objc_retainedObject(i8*)
18 declare i8* @objc_unretainedObject(i8*)
19 declare i8* @objc_unretainedPointer(i8*)
21 declare void @use_pointer(i8*)
22 declare void @callee()
23 declare void @callee_fnptr(void ()*)
24 declare void @invokee()
25 declare i8* @returner()
27 ; Simple retain+release pair deletion, with some intervening control
28 ; flow and harmless instructions.
30 ; CHECK: define void @test0(
32 ; CHECK: call void @llvm.arc.annotation.bottomup.bbstart(i8** @x, i8** @S_None)
33 ; CHECK: %0 = tail call i8* @objc_retain(i8* %a) #0, !llvm.arc.annotation.bottomup ![[ANN0:[0-9]+]], !llvm.arc.annotation.topdown ![[ANN1:[0-9]+]]
34 ; CHECK: call void @llvm.arc.annotation.bottomup.bbend(i8** @x, i8** @S_Use)
35 ; CHECK: call void @llvm.arc.annotation.topdown.bbend(i8** @x, i8** @S_Retain)
37 ; CHECK: call void @llvm.arc.annotation.topdown.bbstart(i8** @x, i8** @S_Retain)
38 ; CHECK: call void @llvm.arc.annotation.bottomup.bbstart(i8** @x, i8** @S_Use)
39 ; CHECK: store float 2.000000e+00, float* %b, !llvm.arc.annotation.bottomup ![[ANN2:[0-9]+]]
40 ; CHECK: call void @llvm.arc.annotation.bottomup.bbend(i8** @x, i8** @S_Release)
41 ; CHECK: call void @llvm.arc.annotation.topdown.bbend(i8** @x, i8** @S_Retain)
43 ; CHECK: call void @llvm.arc.annotation.topdown.bbstart(i8** @x, i8** @S_Retain)
44 ; CHECK: call void @llvm.arc.annotation.bottomup.bbstart(i8** @x, i8** @S_Use)
45 ; CHECK: store i32 7, i32* %x, !llvm.arc.annotation.bottomup ![[ANN2]]
46 ; CHECK: call void @llvm.arc.annotation.bottomup.bbend(i8** @x, i8** @S_Release)
47 ; CHECK: call void @llvm.arc.annotation.topdown.bbend(i8** @x, i8** @S_Retain)
49 ; CHECK: call void @llvm.arc.annotation.topdown.bbstart(i8** @x, i8** @S_Retain)
50 ; CHECK: call void @llvm.arc.annotation.bottomup.bbstart(i8** @x, i8** @S_Release)
51 ; CHECK: call void @objc_release(i8* %c) #0, !llvm.arc.annotation.bottomup ![[ANN3:[0-9]+]], !llvm.arc.annotation.topdown ![[ANN4:[0-9]+]]
52 ; CHECK: call void @llvm.arc.annotation.topdown.bbend(i8** @x, i8** @S_None)
54 define void @test0(i32* %x, i1 %p) nounwind {
56 %a = bitcast i32* %x to i8*
57 %0 = call i8* @objc_retain(i8* %a) nounwind
58 br i1 %p, label %t, label %f
62 %b = bitcast i32* %x to float*
63 store float 2.0, float* %b
71 %c = bitcast i32* %x to i8*
72 call void @objc_release(i8* %c) nounwind
78 ; CHECK: ![[ANN0]] = metadata !{metadata !"(test0,%x)", metadata !"S_Use", metadata !"S_None"}
79 ; CHECK: ![[ANN1]] = metadata !{metadata !"(test0,%x)", metadata !"S_None", metadata !"S_Retain"}
80 ; CHECK: ![[ANN2]] = metadata !{metadata !"(test0,%x)", metadata !"S_Release", metadata !"S_Use"}
81 ; CHECK: ![[ANN3]] = metadata !{metadata !"(test0,%x)", metadata !"S_None", metadata !"S_Release"}
82 ; CHECK: ![[ANN4]] = metadata !{metadata !"(test0,%x)", metadata !"S_Retain", metadata !"S_None"}