1 ; Test that calls to ARC runtime functions are converted to intrinsic calls if
2 ; the bitcode has the arm64 retainAutoreleasedReturnValueMarker metadata.
4 ; upgrade-arc-runtime-calls.bc and upgrade-mrr-runtime-calls.bc are identical
5 ; except that the former has the arm64 retainAutoreleasedReturnValueMarker
6 ; metadata. upgrade-arc-runtime-calls-new.bc has the new module flag format of
7 ; marker, it should not be upgraded.
9 ; RUN: llvm-dis < %S/upgrade-arc-runtime-calls.bc | FileCheck -check-prefixes=ARC %s
10 ; RUN: llvm-dis < %S/upgrade-mrr-runtime-calls.bc | FileCheck -check-prefixes=NOUPGRADE %s
11 ; RUN: llvm-dis < %S/upgrade-arc-runtime-calls-new.bc | FileCheck -check-prefixes=NOUPGRADE %s
13 define void @testRuntimeCalls(i8* %a, i8** %b, i8** %c, i32* %d, i32** %e) personality i32 (...)* @__gxx_personality_v0 {
15 %v0 = tail call i8* @objc_autorelease(i8* %a) #0
16 tail call void @objc_autoreleasePoolPop(i8* %a) #0
17 %v1 = tail call i8* @objc_autoreleasePoolPush() #0
18 %v2 = tail call i8* @objc_autoreleaseReturnValue(i8* %a) #0
19 tail call void @objc_copyWeak(i8** %b, i8** %c) #0
20 tail call void @objc_destroyWeak(i8** %b) #0
21 %v3 = tail call i32* @objc_initWeak(i32** %e, i32* %d) #0
22 %v4 = tail call i8* @objc_loadWeak(i8** %b) #0
23 %v5 = tail call i8* @objc_loadWeakRetained(i8** %b) #0
24 tail call void @objc_moveWeak(i8** %b, i8** %c) #0
25 tail call void @objc_release(i8* %a) #0
26 %v6 = tail call i8* @objc_retain(i8* %a) #0
27 %v7 = tail call i8* @objc_retainAutorelease(i8* %a) #0
28 %v8 = tail call i8* @objc_retainAutoreleaseReturnValue(i8* %a) #0
29 %v9 = tail call i8* @objc_retainAutoreleasedReturnValue(i8* %a) #0
30 %v10 = tail call i8* @objc_retainBlock(i8* %a) #0
31 tail call void @objc_storeStrong(i8** %b, i8* %a) #0
32 %v11 = tail call i8* @objc_storeWeak(i8** %b, i8* %a) #0
33 tail call void (...) @clang.arc.use(i8* %a) #0
34 %v12 = tail call i8* @objc_unsafeClaimAutoreleasedReturnValue(i8* %a) #0
35 %v13 = tail call i8* @objc_retainedObject(i8* %a) #0
36 %v14 = tail call i8* @objc_unretainedObject(i8* %a) #0
37 %v15 = tail call i8* @objc_unretainedPointer(i8* %a) #0
38 %v16 = tail call i8* @objc_retain.autorelease(i8* %a) #0
39 %v17 = tail call i32 @objc_sync.enter(i8* %a) #0
40 %v18 = tail call i32 @objc_sync.exit(i8* %a) #0
41 tail call void @objc_arc_annotation_topdown_bbstart(i8** %b, i8** %c) #0
42 tail call void @objc_arc_annotation_topdown_bbend(i8** %b, i8** %c) #0
43 tail call void @objc_arc_annotation_bottomup_bbstart(i8** %b, i8** %c) #0
44 tail call void @objc_arc_annotation_bottomup_bbend(i8** %b, i8** %c) #0
45 invoke void @objc_autoreleasePoolPop(i8* %a)
46 to label %normalBlock unwind label %unwindBlock
50 %ll = landingpad { i8*, i32 }
55 // Check that auto-upgrader converts function calls to intrinsic calls. Note that
56 // the auto-upgrader doesn't touch invoke instructions.
58 // ARC: define void @testRuntimeCalls(i8* %[[A:.*]], i8** %[[B:.*]], i8** %[[C:.*]], i32* %[[D:.*]], i32** %[[E:.*]]) personality
59 // ARC: %[[V0:.*]] = tail call i8* @llvm.objc.autorelease(i8* %[[A]])
60 // ARC-NEXT: tail call void @llvm.objc.autoreleasePoolPop(i8* %[[A]])
61 // ARC-NEXT: %[[V1:.*]] = tail call i8* @llvm.objc.autoreleasePoolPush()
62 // ARC-NEXT: %[[V2:.*]] = tail call i8* @llvm.objc.autoreleaseReturnValue(i8* %[[A]])
63 // ARC-NEXT: tail call void @llvm.objc.copyWeak(i8** %[[B]], i8** %[[C]])
64 // ARC-NEXT: tail call void @llvm.objc.destroyWeak(i8** %[[B]])
65 // ARC-NEXT: %[[V100:.*]] = bitcast i32** %[[E]] to i8**
66 // ARC-NEXT: %[[V101:.*]] = bitcast i32* %[[D]] to i8*
67 // ARC-NEXT: %[[V102:.*]] = tail call i8* @llvm.objc.initWeak(i8** %[[V100]], i8* %[[V101]])
68 // ARC-NEXT: %[[V103:.*]] = bitcast i8* %[[V102]] to i32*
69 // ARC-NEXT: %[[V4:.*]] = tail call i8* @llvm.objc.loadWeak(i8** %[[B]])
70 // ARC-NEXT: %[[V5:.*]] = tail call i8* @llvm.objc.loadWeakRetained(i8** %[[B]])
71 // ARC-NEXT: tail call void @llvm.objc.moveWeak(i8** %[[B]], i8** %[[C]])
72 // ARC-NEXT: tail call void @llvm.objc.release(i8* %[[A]])
73 // ARC-NEXT: %[[V6:.*]] = tail call i8* @llvm.objc.retain(i8* %[[A]])
74 // ARC-NEXT: %[[V7:.*]] = tail call i8* @llvm.objc.retainAutorelease(i8* %[[A]])
75 // ARC-NEXT: %[[V8:.*]] = tail call i8* @llvm.objc.retainAutoreleaseReturnValue(i8* %[[A]])
76 // ARC-NEXT: %[[V9:.*]] = tail call i8* @llvm.objc.retainAutoreleasedReturnValue(i8* %[[A]])
77 // ARC-NEXT: %[[V10:.*]] = tail call i8* @llvm.objc.retainBlock(i8* %[[A]])
78 // ARC-NEXT: tail call void @llvm.objc.storeStrong(i8** %[[B]], i8* %[[A]])
79 // ARC-NEXT: %[[V11:.*]] = tail call i8* @llvm.objc.storeWeak(i8** %[[B]], i8* %[[A]])
80 // ARC-NEXT: tail call void (...) @llvm.objc.clang.arc.use(i8* %[[A]])
81 // ARC-NEXT: %[[V12:.*]] = tail call i8* @llvm.objc.unsafeClaimAutoreleasedReturnValue(i8* %[[A]])
82 // ARC-NEXT: %[[V13:.*]] = tail call i8* @llvm.objc.retainedObject(i8* %[[A]])
83 // ARC-NEXT: %[[V14:.*]] = tail call i8* @llvm.objc.unretainedObject(i8* %[[A]])
84 // ARC-NEXT: %[[V15:.*]] = tail call i8* @llvm.objc.unretainedPointer(i8* %[[A]])
85 // ARC-NEXT: %[[V16:.*]] = tail call i8* @objc_retain.autorelease(i8* %[[A]])
86 // ARC-NEXT: %[[V17:.*]] = tail call i32 @objc_sync.enter(i8* %[[A]])
87 // ARC-NEXT: %[[V18:.*]] = tail call i32 @objc_sync.exit(i8* %[[A]])
88 // ARC-NEXT: tail call void @llvm.objc.arc.annotation.topdown.bbstart(i8** %[[B]], i8** %[[C]])
89 // ARC-NEXT: tail call void @llvm.objc.arc.annotation.topdown.bbend(i8** %[[B]], i8** %[[C]])
90 // ARC-NEXT: tail call void @llvm.objc.arc.annotation.bottomup.bbstart(i8** %[[B]], i8** %[[C]])
91 // ARC-NEXT: tail call void @llvm.objc.arc.annotation.bottomup.bbend(i8** %[[B]], i8** %[[C]])
92 // ARC-NEXT: invoke void @objc_autoreleasePoolPop(i8* %[[A]])
94 // NOUPGRADE: define void @testRuntimeCalls(i8* %[[A:.*]], i8** %[[B:.*]], i8** %[[C:.*]], i32* %[[D:.*]], i32** %[[E:.*]]) personality
95 // NOUPGRADE: %[[V0:.*]] = tail call i8* @objc_autorelease(i8* %[[A]])
96 // NOUPGRADE-NEXT: tail call void @objc_autoreleasePoolPop(i8* %[[A]])
97 // NOUPGRADE-NEXT: %[[V1:.*]] = tail call i8* @objc_autoreleasePoolPush()
98 // NOUPGRADE-NEXT: %[[V2:.*]] = tail call i8* @objc_autoreleaseReturnValue(i8* %[[A]])
99 // NOUPGRADE-NEXT: tail call void @objc_copyWeak(i8** %[[B]], i8** %[[C]])
100 // NOUPGRADE-NEXT: tail call void @objc_destroyWeak(i8** %[[B]])
101 // NOUPGRADE-NEXT: %[[V3:.*]] = tail call i32* @objc_initWeak(i32** %[[E]], i32* %[[D]])
102 // NOUPGRADE-NEXT: %[[V4:.*]] = tail call i8* @objc_loadWeak(i8** %[[B]])
103 // NOUPGRADE-NEXT: %[[V5:.*]] = tail call i8* @objc_loadWeakRetained(i8** %[[B]])
104 // NOUPGRADE-NEXT: tail call void @objc_moveWeak(i8** %[[B]], i8** %[[C]])
105 // NOUPGRADE-NEXT: tail call void @objc_release(i8* %[[A]])
106 // NOUPGRADE-NEXT: %[[V6:.*]] = tail call i8* @objc_retain(i8* %[[A]])
107 // NOUPGRADE-NEXT: %[[V7:.*]] = tail call i8* @objc_retainAutorelease(i8* %[[A]])
108 // NOUPGRADE-NEXT: %[[V8:.*]] = tail call i8* @objc_retainAutoreleaseReturnValue(i8* %[[A]])
109 // NOUPGRADE-NEXT: %[[V9:.*]] = tail call i8* @objc_retainAutoreleasedReturnValue(i8* %[[A]])
110 // NOUPGRADE-NEXT: %[[V10:.*]] = tail call i8* @objc_retainBlock(i8* %[[A]])
111 // NOUPGRADE-NEXT: tail call void @objc_storeStrong(i8** %[[B]], i8* %[[A]])
112 // NOUPGRADE-NEXT: %[[V11:.*]] = tail call i8* @objc_storeWeak(i8** %[[B]], i8* %[[A]])
113 // NOUPGRADE-NEXT: tail call void (...) @llvm.objc.clang.arc.use(i8* %[[A]])
114 // NOUPGRADE-NEXT: %[[V12:.*]] = tail call i8* @objc_unsafeClaimAutoreleasedReturnValue(i8* %[[A]])
115 // NOUPGRADE-NEXT: %[[V13:.*]] = tail call i8* @objc_retainedObject(i8* %[[A]])
116 // NOUPGRADE-NEXT: %[[V14:.*]] = tail call i8* @objc_unretainedObject(i8* %[[A]])
117 // NOUPGRADE-NEXT: %[[V15:.*]] = tail call i8* @objc_unretainedPointer(i8* %[[A]])
118 // NOUPGRADE-NEXT: %[[V16:.*]] = tail call i8* @objc_retain.autorelease(i8* %[[A]])
119 // NOUPGRADE-NEXT: %[[V17:.*]] = tail call i32 @objc_sync.enter(i8* %[[A]])
120 // NOUPGRADE-NEXT: %[[V18:.*]] = tail call i32 @objc_sync.exit(i8* %[[A]])
121 // NOUPGRADE-NEXT: tail call void @objc_arc_annotation_topdown_bbstart(i8** %[[B]], i8** %[[C]])
122 // NOUPGRADE-NEXT: tail call void @objc_arc_annotation_topdown_bbend(i8** %[[B]], i8** %[[C]])
123 // NOUPGRADE-NEXT: tail call void @objc_arc_annotation_bottomup_bbstart(i8** %[[B]], i8** %[[C]])
124 // NOUPGRADE-NEXT: tail call void @objc_arc_annotation_bottomup_bbend(i8** %[[B]], i8** %[[C]])
125 // NOUPGRADE-NEXT: invoke void @objc_autoreleasePoolPop(i8* %[[A]])