SimplifyCFG: don't remove unreachable default switch destinations
[oota-llvm.git] / test / Transforms / ObjCARC / arc-annotations.ll
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.
4
5 ; REQUIRES: asserts
6 ; RUN: opt -S -objc-arc -enable-objc-arc-annotations < %s | FileCheck %s
7
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*)
16
17 declare i8* @objc_retainedObject(i8*)
18 declare i8* @objc_unretainedObject(i8*)
19 declare i8* @objc_unretainedPointer(i8*)
20
21 declare void @use_pointer(i8*)
22 declare void @callee()
23 declare void @callee_fnptr(void ()*)
24 declare void @invokee()
25 declare i8* @returner()
26
27 ; Simple retain+release pair deletion, with some intervening control
28 ; flow and harmless instructions.
29
30 ; CHECK-LABEL: define void @test0(
31 ; CHECK: entry:
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)
36 ; CHECK: t:
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)
42 ; CHECK: f:
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)
48 ; CHECK: return:
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)
53 ; CHECK: }
54 define void @test0(i32* %x, i1 %p) nounwind {
55 entry:
56   %a = bitcast i32* %x to i8*
57   %0 = call i8* @objc_retain(i8* %a) nounwind
58   br i1 %p, label %t, label %f
59
60 t:
61   store i8 3, i8* %a
62   %b = bitcast i32* %x to float*
63   store float 2.0, float* %b
64   br label %return
65
66 f:
67   store i32 7, i32* %x
68   br label %return
69
70 return:
71   %c = bitcast i32* %x to i8*
72   call void @objc_release(i8* %c) nounwind
73   ret void
74 }
75
76 !0 = !{}
77
78 ; CHECK: ![[ANN0]] = !{!"(test0,%x)", !"S_Use", !"S_None"}
79 ; CHECK: ![[ANN1]] = !{!"(test0,%x)", !"S_None", !"S_Retain"}
80 ; CHECK: ![[ANN2]] = !{!"(test0,%x)", !"S_Release", !"S_Use"}
81 ; CHECK: ![[ANN3]] = !{!"(test0,%x)", !"S_None", !"S_Release"}
82 ; CHECK: ![[ANN4]] = !{!"(test0,%x)", !"S_Retain", !"S_None"}
83