llvm.org GIT mirror llvm / 7c9e35d
Rewrite objc intrinsics to runtime methods in PreISelIntrinsicLowering instead of SDAG. SelectionDAG currently changes these intrinsics to function calls, but that won't work for other ISel's. Also we want to eventually support nonlazybind and weak linkage coming from the front-end which we can't do in SelectionDAG. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@349552 91177308-0d34-0410-b5e6-96231b3b80d8 Pete Cooper 9 months ago
6 changed file(s) with 399 addition(s) and 286 deletion(s). Raw diff Collapse all Expand all
388388 ///
389389 ModulePass *createLowerEmuTLSPass();
390390
391 /// This pass lowers the \@llvm.load.relative intrinsic to instructions.
392 /// This is unsafe to do earlier because a pass may combine the constant
393 /// initializer into the load, which may result in an overflowing evaluation.
391 /// This pass lowers the \@llvm.load.relative and \@llvm.objc.* intrinsics to
392 /// instructions. This is unsafe to do earlier because a pass may combine the
393 /// constant initializer into the load, which may result in an overflowing
394 /// evaluation.
394395 ModulePass *createPreISelIntrinsicLoweringPass();
395396
396397 /// GlobalMerge - This pass merges internal (by default) globals into structs
66 //
77 //===----------------------------------------------------------------------===//
88 //
9 // This pass implements IR lowering for the llvm.load.relative intrinsic.
9 // This pass implements IR lowering for the llvm.load.relative and llvm.objc.*
10 // intrinsics.
1011 //
1112 //===----------------------------------------------------------------------===//
1213 #ifndef LLVM_CODEGEN_PREISELINTRINSICLOWERING_H
66 //
77 //===----------------------------------------------------------------------===//
88 //
9 // This pass implements IR lowering for the llvm.load.relative intrinsic.
9 // This pass implements IR lowering for the llvm.load.relative and llvm.objc.*
10 // intrinsics.
1011 //
1112 //===----------------------------------------------------------------------===//
1213
1314 #include "llvm/CodeGen/PreISelIntrinsicLowering.h"
1415 #include "llvm/CodeGen/Passes.h"
1516 #include "llvm/IR/Function.h"
17 #include "llvm/IR/Intrinsics.h"
1618 #include "llvm/IR/IRBuilder.h"
1719 #include "llvm/IR/Instructions.h"
1820 #include "llvm/IR/Module.h"
5456 return Changed;
5557 }
5658
59 static bool lowerObjCCall(Function &F, const char *NewFn) {
60 if (F.use_empty())
61 return false;
62
63 // If we haven't already looked up this function, check to see if the
64 // program already contains a function with this name.
65 Module *M = F.getParent();
66 Constant* FCache = M->getOrInsertFunction(NewFn, F.getFunctionType());
67
68 for (auto I = F.use_begin(), E = F.use_end(); I != E;) {
69 auto *CI = dyn_cast(I->getUser());
70 assert(CI->getCalledFunction() && "Cannot lower an indirect call!");
71 ++I;
72
73 IRBuilder<> Builder(CI->getParent(), CI->getIterator());
74 SmallVector Args(CI->arg_begin(), CI->arg_end());
75 CallInst *NewCI = Builder.CreateCall(FCache, Args);
76 NewCI->setName(CI->getName());
77 NewCI->setTailCallKind(CI->getTailCallKind());
78 if (!CI->use_empty())
79 CI->replaceAllUsesWith(NewCI);
80 CI->eraseFromParent();
81 }
82
83 return true;
84 }
85
5786 static bool lowerIntrinsics(Module &M) {
5887 bool Changed = false;
5988 for (Function &F : M) {
60 if (F.getName().startswith("llvm.load.relative."))
89 if (F.getName().startswith("llvm.load.relative.")) {
6190 Changed |= lowerLoadRelative(F);
91 continue;
92 }
93 switch (F.getIntrinsicID()) {
94 default:
95 break;
96 case Intrinsic::objc_autorelease:
97 Changed |= lowerObjCCall(F, "objc_autorelease");
98 break;
99 case Intrinsic::objc_autoreleasePoolPop:
100 Changed |= lowerObjCCall(F, "objc_autoreleasePoolPop");
101 break;
102 case Intrinsic::objc_autoreleasePoolPush:
103 Changed |= lowerObjCCall(F, "objc_autoreleasePoolPush");
104 break;
105 case Intrinsic::objc_autoreleaseReturnValue:
106 Changed |= lowerObjCCall(F, "objc_autoreleaseReturnValue");
107 break;
108 case Intrinsic::objc_copyWeak:
109 Changed |= lowerObjCCall(F, "objc_copyWeak");
110 break;
111 case Intrinsic::objc_destroyWeak:
112 Changed |= lowerObjCCall(F, "objc_destroyWeak");
113 break;
114 case Intrinsic::objc_initWeak:
115 Changed |= lowerObjCCall(F, "objc_initWeak");
116 break;
117 case Intrinsic::objc_loadWeak:
118 Changed |= lowerObjCCall(F, "objc_loadWeak");
119 break;
120 case Intrinsic::objc_loadWeakRetained:
121 Changed |= lowerObjCCall(F, "objc_loadWeakRetained");
122 break;
123 case Intrinsic::objc_moveWeak:
124 Changed |= lowerObjCCall(F, "objc_moveWeak");
125 break;
126 case Intrinsic::objc_release:
127 Changed |= lowerObjCCall(F, "objc_release");
128 break;
129 case Intrinsic::objc_retain:
130 Changed |= lowerObjCCall(F, "objc_retain");
131 break;
132 case Intrinsic::objc_retainAutorelease:
133 Changed |= lowerObjCCall(F, "objc_retainAutorelease");
134 break;
135 case Intrinsic::objc_retainAutoreleaseReturnValue:
136 Changed |= lowerObjCCall(F, "objc_retainAutoreleaseReturnValue");
137 break;
138 case Intrinsic::objc_retainAutoreleasedReturnValue:
139 Changed |= lowerObjCCall(F, "objc_retainAutoreleasedReturnValue");
140 break;
141 case Intrinsic::objc_retainBlock:
142 Changed |= lowerObjCCall(F, "objc_retainBlock");
143 break;
144 case Intrinsic::objc_storeStrong:
145 Changed |= lowerObjCCall(F, "objc_storeStrong");
146 break;
147 case Intrinsic::objc_storeWeak:
148 Changed |= lowerObjCCall(F, "objc_storeWeak");
149 break;
150 case Intrinsic::objc_unsafeClaimAutoreleasedReturnValue:
151 Changed |= lowerObjCCall(F, "objc_unsafeClaimAutoreleasedReturnValue");
152 break;
153 case Intrinsic::objc_retainedObject:
154 Changed |= lowerObjCCall(F, "objc_retainedObject");
155 break;
156 case Intrinsic::objc_unretainedObject:
157 Changed |= lowerObjCCall(F, "objc_unretainedObject");
158 break;
159 case Intrinsic::objc_unretainedPointer:
160 Changed |= lowerObjCCall(F, "objc_unretainedPointer");
161 break;
162 case Intrinsic::objc_retain_autorelease:
163 Changed |= lowerObjCCall(F, "objc_retain_autorelease");
164 break;
165 case Intrinsic::objc_sync_enter:
166 Changed |= lowerObjCCall(F, "objc_sync_enter");
167 break;
168 case Intrinsic::objc_sync_exit:
169 Changed |= lowerObjCCall(F, "objc_sync_exit");
170 break;
171 }
62172 }
63173 return Changed;
64174 }
63626362 // MachineFunction in SelectionDAGISel::PrepareEHLandingPad. We can safely
63636363 // delete it now.
63646364 return nullptr;
6365 case Intrinsic::objc_autorelease:
6366 return "objc_autorelease";
6367 case Intrinsic::objc_autoreleasePoolPop:
6368 return "objc_autoreleasePoolPop";
6369 case Intrinsic::objc_autoreleasePoolPush:
6370 return "objc_autoreleasePoolPush";
6371 case Intrinsic::objc_autoreleaseReturnValue:
6372 return "objc_autoreleaseReturnValue";
6373 case Intrinsic::objc_copyWeak:
6374 return "objc_copyWeak";
6375 case Intrinsic::objc_destroyWeak:
6376 return "objc_destroyWeak";
6377 case Intrinsic::objc_initWeak:
6378 return "objc_initWeak";
6379 case Intrinsic::objc_loadWeak:
6380 return "objc_loadWeak";
6381 case Intrinsic::objc_loadWeakRetained:
6382 return "objc_loadWeakRetained";
6383 case Intrinsic::objc_moveWeak:
6384 return "objc_moveWeak";
6385 case Intrinsic::objc_release:
6386 return "objc_release";
6387 case Intrinsic::objc_retain:
6388 return "objc_retain";
6389 case Intrinsic::objc_retainAutorelease:
6390 return "objc_retainAutorelease";
6391 case Intrinsic::objc_retainAutoreleaseReturnValue:
6392 return "objc_retainAutoreleaseReturnValue";
6393 case Intrinsic::objc_retainAutoreleasedReturnValue:
6394 return "objc_retainAutoreleasedReturnValue";
6395 case Intrinsic::objc_retainBlock:
6396 return "objc_retainBlock";
6397 case Intrinsic::objc_storeStrong:
6398 return "objc_storeStrong";
6399 case Intrinsic::objc_storeWeak:
6400 return "objc_storeWeak";
6401 case Intrinsic::objc_unsafeClaimAutoreleasedReturnValue:
6402 return "objc_unsafeClaimAutoreleasedReturnValue";
6403 case Intrinsic::objc_retainedObject:
6404 return "objc_retainedObject";
6405 case Intrinsic::objc_unretainedObject:
6406 return "objc_unretainedObject";
6407 case Intrinsic::objc_unretainedPointer:
6408 return "objc_unretainedPointer";
6409 case Intrinsic::objc_retain_autorelease:
6410 return "objc_retain_autorelease";
6411 case Intrinsic::objc_sync_enter:
6412 return "objc_sync_enter";
6413 case Intrinsic::objc_sync_exit:
6414 return "objc_sync_exit";
64156365 }
64166366 }
64176367
+0
-230
test/CodeGen/X86/objc-arc.ll less more
None ; RUN: llc < %s -mtriple=x86_64-apple-darwin | FileCheck %s
1
2 ; Make sure calls to the objc intrinsics are translated to calls in to the
3 ; runtime
4
5 define i8* @test_objc_autorelease(i8* %arg0) {
6 ; CHECK-LABEL: test_objc_autorelease
7 ; CHECK: callq _objc_autorelease
8 entry:
9 %0 = call i8* @llvm.objc.autorelease(i8* %arg0)
10 ret i8* %0
11 }
12
13 define void @test_objc_autoreleasePoolPop(i8* %arg0) {
14 ; CHECK-LABEL: test_objc_autoreleasePoolPop
15 ; CHECK: callq _objc_autoreleasePoolPop
16 entry:
17 call void @llvm.objc.autoreleasePoolPop(i8* %arg0)
18 ret void
19 }
20
21 define i8* @test_objc_autoreleasePoolPush() {
22 ; CHECK-LABEL: test_objc_autoreleasePoolPush
23 ; CHECK: callq _objc_autoreleasePoolPush
24 entry:
25 %0 = call i8* @llvm.objc.autoreleasePoolPush()
26 ret i8* %0
27 }
28
29 define i8* @test_objc_autoreleaseReturnValue(i8* %arg0) {
30 ; CHECK-LABEL: test_objc_autoreleaseReturnValue
31 ; CHECK: callq _objc_autoreleaseReturnValue
32 entry:
33 %0 = call i8* @llvm.objc.autoreleaseReturnValue(i8* %arg0)
34 ret i8* %0
35 }
36
37 define void @test_objc_copyWeak(i8** %arg0, i8** %arg1) {
38 ; CHECK-LABEL: test_objc_copyWeak
39 ; CHECK: callq _objc_copyWeak
40 entry:
41 call void @llvm.objc.copyWeak(i8** %arg0, i8** %arg1)
42 ret void
43 }
44
45 define void @test_objc_destroyWeak(i8** %arg0) {
46 ; CHECK-LABEL: test_objc_destroyWeak
47 ; CHECK: callq _objc_destroyWeak
48 entry:
49 call void @llvm.objc.destroyWeak(i8** %arg0)
50 ret void
51 }
52
53 define i8* @test_objc_initWeak(i8** %arg0, i8* %arg1) {
54 ; CHECK-LABEL: test_objc_initWeak
55 ; CHECK: callq _objc_initWeak
56 entry:
57 %0 = call i8* @llvm.objc.initWeak(i8** %arg0, i8* %arg1)
58 ret i8* %0
59 }
60
61 define i8* @test_objc_loadWeak(i8** %arg0) {
62 ; CHECK-LABEL: test_objc_loadWeak
63 ; CHECK: callq _objc_loadWeak
64 entry:
65 %0 = call i8* @llvm.objc.loadWeak(i8** %arg0)
66 ret i8* %0
67 }
68
69 define i8* @test_objc_loadWeakRetained(i8** %arg0) {
70 ; CHECK-LABEL: test_objc_loadWeakRetained
71 ; CHECK: callq _objc_loadWeakRetained
72 entry:
73 %0 = call i8* @llvm.objc.loadWeakRetained(i8** %arg0)
74 ret i8* %0
75 }
76
77 define void @test_objc_moveWeak(i8** %arg0, i8** %arg1) {
78 ; CHECK-LABEL: test_objc_moveWeak
79 ; CHECK: callq _objc_moveWeak
80 entry:
81 call void @llvm.objc.moveWeak(i8** %arg0, i8** %arg1)
82 ret void
83 }
84
85 define void @test_objc_release(i8* %arg0) {
86 ; CHECK-LABEL: test_objc_release
87 ; CHECK: callq _objc_release
88 entry:
89 call void @llvm.objc.release(i8* %arg0)
90 ret void
91 }
92
93 define i8* @test_objc_retain(i8* %arg0) {
94 ; CHECK-LABEL: test_objc_retain
95 ; CHECK: callq _objc_retain
96 entry:
97 %0 = call i8* @llvm.objc.retain(i8* %arg0)
98 ret i8* %0
99 }
100
101 define i8* @test_objc_retainAutorelease(i8* %arg0) {
102 ; CHECK-LABEL: test_objc_retainAutorelease
103 ; CHECK: callq _objc_retainAutorelease
104 entry:
105 %0 = call i8* @llvm.objc.retainAutorelease(i8* %arg0)
106 ret i8* %0
107 }
108
109 define i8* @test_objc_retainAutoreleaseReturnValue(i8* %arg0) {
110 ; CHECK-LABEL: test_objc_retainAutoreleaseReturnValue
111 ; CHECK: callq _objc_retainAutoreleaseReturnValue
112 entry:
113 %0 = call i8* @llvm.objc.retainAutoreleaseReturnValue(i8* %arg0)
114 ret i8* %0
115 }
116
117 define i8* @test_objc_retainAutoreleasedReturnValue(i8* %arg0) {
118 ; CHECK-LABEL: test_objc_retainAutoreleasedReturnValue
119 ; CHECK: callq _objc_retainAutoreleasedReturnValue
120 entry:
121 %0 = call i8* @llvm.objc.retainAutoreleasedReturnValue(i8* %arg0)
122 ret i8* %0
123 }
124
125 define i8* @test_objc_retainBlock(i8* %arg0) {
126 ; CHECK-LABEL: test_objc_retainBlock
127 ; CHECK: callq _objc_retainBlock
128 entry:
129 %0 = call i8* @llvm.objc.retainBlock(i8* %arg0)
130 ret i8* %0
131 }
132
133 define void @test_objc_storeStrong(i8** %arg0, i8* %arg1) {
134 ; CHECK-LABEL: test_objc_storeStrong
135 ; CHECK: callq _objc_storeStrong
136 entry:
137 call void @llvm.objc.storeStrong(i8** %arg0, i8* %arg1)
138 ret void
139 }
140
141 define i8* @test_objc_storeWeak(i8** %arg0, i8* %arg1) {
142 ; CHECK-LABEL: test_objc_storeWeak
143 ; CHECK: callq _objc_storeWeak
144 entry:
145 %0 = call i8* @llvm.objc.storeWeak(i8** %arg0, i8* %arg1)
146 ret i8* %0
147 }
148
149 define i8* @test_objc_objc_unsafeClaimAutoreleasedReturnValue(i8* %arg0) {
150 ; CHECK-LABEL: test_objc_objc_unsafeClaimAutoreleasedReturnValue
151 ; CHECK: callq _objc_unsafeClaimAutoreleasedReturnValue
152 entry:
153 %0 = call i8* @llvm.objc.unsafeClaimAutoreleasedReturnValue(i8* %arg0)
154 ret i8* %0
155 }
156
157 define i8* @test_objc_objc_retainedObject(i8* %arg0) {
158 ; CHECK-LABEL: test_objc_objc_retainedObject
159 ; CHECK: callq _objc_retainedObject
160 entry:
161 %0 = call i8* @llvm.objc.retainedObject(i8* %arg0)
162 ret i8* %0
163 }
164
165 define i8* @test_objc_objc_unretainedObject(i8* %arg0) {
166 ; CHECK-LABEL: test_objc_objc_unretainedObject
167 ; CHECK: callq _objc_unretainedObject
168 entry:
169 %0 = call i8* @llvm.objc.unretainedObject(i8* %arg0)
170 ret i8* %0
171 }
172
173 define i8* @test_objc_objc_unretainedPointer(i8* %arg0) {
174 ; CHECK-LABEL: test_objc_objc_unretainedPointer
175 ; CHECK: callq _objc_unretainedPointer
176 entry:
177 %0 = call i8* @llvm.objc.unretainedPointer(i8* %arg0)
178 ret i8* %0
179 }
180
181 define i8* @test_objc_objc_retain_autorelease(i8* %arg0) {
182 ; CHECK-LABEL: test_objc_objc_retain_autorelease
183 ; CHECK: callq _objc_retain_autorelease
184 entry:
185 %0 = call i8* @llvm.objc.retain.autorelease(i8* %arg0)
186 ret i8* %0
187 }
188
189 define i32 @test_objc_objc_sync_enter(i8* %arg0) {
190 ; CHECK-LABEL: test_objc_objc_sync_enter
191 ; CHECK: callq _objc_sync_enter
192 entry:
193 %0 = call i32 @llvm.objc.sync.enter(i8* %arg0)
194 ret i32 %0
195 }
196
197 define i32 @test_objc_objc_sync_exit(i8* %arg0) {
198 ; CHECK-LABEL: test_objc_objc_sync_exit
199 ; CHECK: callq _objc_sync_exit
200 entry:
201 %0 = call i32 @llvm.objc.sync.exit(i8* %arg0)
202 ret i32 %0
203 }
204
205 declare i8* @llvm.objc.autorelease(i8*)
206 declare void @llvm.objc.autoreleasePoolPop(i8*)
207 declare i8* @llvm.objc.autoreleasePoolPush()
208 declare i8* @llvm.objc.autoreleaseReturnValue(i8*)
209 declare void @llvm.objc.copyWeak(i8**, i8**)
210 declare void @llvm.objc.destroyWeak(i8**)
211 declare i8* @llvm.objc.initWeak(i8**, i8*)
212 declare i8* @llvm.objc.loadWeak(i8**)
213 declare i8* @llvm.objc.loadWeakRetained(i8**)
214 declare void @llvm.objc.moveWeak(i8**, i8**)
215 declare void @llvm.objc.release(i8*)
216 declare i8* @llvm.objc.retain(i8*)
217 declare i8* @llvm.objc.retainAutorelease(i8*)
218 declare i8* @llvm.objc.retainAutoreleaseReturnValue(i8*)
219 declare i8* @llvm.objc.retainAutoreleasedReturnValue(i8*)
220 declare i8* @llvm.objc.retainBlock(i8*)
221 declare void @llvm.objc.storeStrong(i8**, i8*)
222 declare i8* @llvm.objc.storeWeak(i8**, i8*)
223 declare i8* @llvm.objc.unsafeClaimAutoreleasedReturnValue(i8*)
224 declare i8* @llvm.objc.retainedObject(i8*)
225 declare i8* @llvm.objc.unretainedObject(i8*)
226 declare i8* @llvm.objc.unretainedPointer(i8*)
227 declare i8* @llvm.objc.retain.autorelease(i8*)
228 declare i32 @llvm.objc.sync.enter(i8*)
229 declare i32 @llvm.objc.sync.exit(i8*)
0 ; RUN: opt -pre-isel-intrinsic-lowering -S -o - %s | FileCheck %s
1 ; RUN: opt -passes='pre-isel-intrinsic-lowering' -S -o - %s | FileCheck %s
2
3 ; Make sure calls to the objc intrinsics are translated to calls in to the
4 ; runtime
5
6 define i8* @test_objc_autorelease(i8* %arg0) {
7 ; CHECK-LABEL: test_objc_autorelease
8 ; CHECK-NEXT: entry
9 ; CHECK-NEXT: %0 = call i8* @objc_autorelease(i8* %arg0)
10 ; CHECK-NEXT: ret i8* %0
11 entry:
12 %0 = call i8* @llvm.objc.autorelease(i8* %arg0)
13 ret i8* %0
14 }
15
16 define void @test_objc_autoreleasePoolPop(i8* %arg0) {
17 ; CHECK-LABEL: test_objc_autoreleasePoolPop
18 ; CHECK-NEXT: entry
19 ; CHECK-NEXT: call void @objc_autoreleasePoolPop(i8* %arg0)
20 ; CHECK-NEXT: ret void
21 entry:
22 call void @llvm.objc.autoreleasePoolPop(i8* %arg0)
23 ret void
24 }
25
26 define i8* @test_objc_autoreleasePoolPush() {
27 ; CHECK-LABEL: test_objc_autoreleasePoolPush
28 ; CHECK-NEXT: entry
29 ; CHECK-NEXT: %0 = call i8* @objc_autoreleasePoolPush()
30 ; CHECK-NEXT: ret i8* %0
31 entry:
32 %0 = call i8* @llvm.objc.autoreleasePoolPush()
33 ret i8* %0
34 }
35
36 define i8* @test_objc_autoreleaseReturnValue(i8* %arg0) {
37 ; CHECK-LABEL: test_objc_autoreleaseReturnValue
38 ; CHECK-NEXT: entry
39 ; CHECK-NEXT: %0 = call i8* @objc_autoreleaseReturnValue(i8* %arg0)
40 ; CHECK-NEXT: ret i8* %0
41 entry:
42 %0 = call i8* @llvm.objc.autoreleaseReturnValue(i8* %arg0)
43 ret i8* %0
44 }
45
46 define void @test_objc_copyWeak(i8** %arg0, i8** %arg1) {
47 ; CHECK-LABEL: test_objc_copyWeak
48 ; CHECK-NEXT: entry
49 ; CHECK-NEXT: call void @objc_copyWeak(i8** %arg0, i8** %arg1)
50 ; CHECK-NEXT: ret void
51 entry:
52 call void @llvm.objc.copyWeak(i8** %arg0, i8** %arg1)
53 ret void
54 }
55
56 define void @test_objc_destroyWeak(i8** %arg0) {
57 ; CHECK-LABEL: test_objc_destroyWeak
58 ; CHECK-NEXT: entry
59 ; CHECK-NEXT: call void @objc_destroyWeak(i8** %arg0)
60 ; CHECK-NEXT: ret void
61 entry:
62 call void @llvm.objc.destroyWeak(i8** %arg0)
63 ret void
64 }
65
66 define i8* @test_objc_initWeak(i8** %arg0, i8* %arg1) {
67 ; CHECK-LABEL: test_objc_initWeak
68 ; CHECK-NEXT: entry
69 ; CHECK-NEXT: %0 = call i8* @objc_initWeak(i8** %arg0, i8* %arg1)
70 ; CHECK-NEXT: ret i8* %0
71 entry:
72 %0 = call i8* @llvm.objc.initWeak(i8** %arg0, i8* %arg1)
73 ret i8* %0
74 }
75
76 define i8* @test_objc_loadWeak(i8** %arg0) {
77 ; CHECK-LABEL: test_objc_loadWeak
78 ; CHECK-NEXT: entry
79 ; CHECK-NEXT: %0 = call i8* @objc_loadWeak(i8** %arg0)
80 ; CHECK-NEXT: ret i8* %0
81 entry:
82 %0 = call i8* @llvm.objc.loadWeak(i8** %arg0)
83 ret i8* %0
84 }
85
86 define i8* @test_objc_loadWeakRetained(i8** %arg0) {
87 ; CHECK-LABEL: test_objc_loadWeakRetained
88 ; CHECK-NEXT: entry
89 ; CHECK-NEXT: %0 = call i8* @objc_loadWeakRetained(i8** %arg0)
90 ; CHECK-NEXT: ret i8* %0
91 entry:
92 %0 = call i8* @llvm.objc.loadWeakRetained(i8** %arg0)
93 ret i8* %0
94 }
95
96 define void @test_objc_moveWeak(i8** %arg0, i8** %arg1) {
97 ; CHECK-LABEL: test_objc_moveWeak
98 ; CHECK-NEXT: entry
99 ; CHECK-NEXT: call void @objc_moveWeak(i8** %arg0, i8** %arg1)
100 ; CHECK-NEXT: ret void
101 entry:
102 call void @llvm.objc.moveWeak(i8** %arg0, i8** %arg1)
103 ret void
104 }
105
106 define void @test_objc_release(i8* %arg0) {
107 ; CHECK-LABEL: test_objc_release
108 ; CHECK-NEXT: entry
109 ; CHECK-NEXT: call void @objc_release(i8* %arg0)
110 ; CHECK-NEXT: ret void
111 entry:
112 call void @llvm.objc.release(i8* %arg0)
113 ret void
114 }
115
116 define i8* @test_objc_retain(i8* %arg0) {
117 ; CHECK-LABEL: test_objc_retain
118 ; CHECK-NEXT: entry
119 ; CHECK-NEXT: %0 = call i8* @objc_retain(i8* %arg0)
120 ; CHECK-NEXT: ret i8* %0
121 entry:
122 %0 = call i8* @llvm.objc.retain(i8* %arg0)
123 ret i8* %0
124 }
125
126 define i8* @test_objc_retainAutorelease(i8* %arg0) {
127 ; CHECK-LABEL: test_objc_retainAutorelease
128 ; CHECK-NEXT: entry
129 ; CHECK-NEXT: %0 = call i8* @objc_retainAutorelease(i8* %arg0)
130 ; CHECK-NEXT: ret i8* %0
131 entry:
132 %0 = call i8* @llvm.objc.retainAutorelease(i8* %arg0)
133 ret i8* %0
134 }
135
136 define i8* @test_objc_retainAutoreleaseReturnValue(i8* %arg0) {
137 ; CHECK-LABEL: test_objc_retainAutoreleaseReturnValue
138 ; CHECK-NEXT: entry
139 ; CHECK-NEXT: %0 = tail call i8* @objc_retainAutoreleaseReturnValue(i8* %arg0)
140 ; CHECK-NEXT: ret i8* %0
141 entry:
142 %0 = tail call i8* @llvm.objc.retainAutoreleaseReturnValue(i8* %arg0)
143 ret i8* %0
144 }
145
146 define i8* @test_objc_retainAutoreleasedReturnValue(i8* %arg0) {
147 ; CHECK-LABEL: test_objc_retainAutoreleasedReturnValue
148 ; CHECK-NEXT: entry
149 ; CHECK-NEXT: %0 = call i8* @objc_retainAutoreleasedReturnValue(i8* %arg0)
150 ; CHECK-NEXT: ret i8* %0
151 entry:
152 %0 = call i8* @llvm.objc.retainAutoreleasedReturnValue(i8* %arg0)
153 ret i8* %0
154 }
155
156 define i8* @test_objc_retainBlock(i8* %arg0) {
157 ; CHECK-LABEL: test_objc_retainBlock
158 ; CHECK-NEXT: entry
159 ; CHECK-NEXT: %0 = call i8* @objc_retainBlock(i8* %arg0)
160 ; CHECK-NEXT: ret i8* %0
161 entry:
162 %0 = call i8* @llvm.objc.retainBlock(i8* %arg0)
163 ret i8* %0
164 }
165
166 define void @test_objc_storeStrong(i8** %arg0, i8* %arg1) {
167 ; CHECK-LABEL: test_objc_storeStrong
168 ; CHECK-NEXT: entry
169 ; CHECK-NEXT: call void @objc_storeStrong(i8** %arg0, i8* %arg1)
170 ; CHECK-NEXT: ret void
171 entry:
172 call void @llvm.objc.storeStrong(i8** %arg0, i8* %arg1)
173 ret void
174 }
175
176 define i8* @test_objc_storeWeak(i8** %arg0, i8* %arg1) {
177 ; CHECK-LABEL: test_objc_storeWeak
178 ; CHECK-NEXT: entry
179 ; CHECK-NEXT: %0 = call i8* @objc_storeWeak(i8** %arg0, i8* %arg1)
180 ; CHECK-NEXT: ret i8* %0
181 entry:
182 %0 = call i8* @llvm.objc.storeWeak(i8** %arg0, i8* %arg1)
183 ret i8* %0
184 }
185
186 define i8* @test_objc_unsafeClaimAutoreleasedReturnValue(i8* %arg0) {
187 ; CHECK-LABEL: test_objc_unsafeClaimAutoreleasedReturnValue
188 ; CHECK-NEXT: entry
189 ; CHECK-NEXT: %0 = call i8* @objc_unsafeClaimAutoreleasedReturnValue(i8* %arg0)
190 ; CHECK-NEXT: ret i8* %0
191 entry:
192 %0 = call i8* @llvm.objc.unsafeClaimAutoreleasedReturnValue(i8* %arg0)
193 ret i8* %0
194 }
195
196 define i8* @test_objc_retainedObject(i8* %arg0) {
197 ; CHECK-LABEL: test_objc_retainedObject
198 ; CHECK-NEXT: entry
199 ; CHECK-NEXT: %0 = call i8* @objc_retainedObject(i8* %arg0)
200 ; CHECK-NEXT: ret i8* %0
201 entry:
202 %0 = call i8* @llvm.objc.retainedObject(i8* %arg0)
203 ret i8* %0
204 }
205
206 define i8* @test_objc_unretainedObject(i8* %arg0) {
207 ; CHECK-LABEL: test_objc_unretainedObject
208 ; CHECK-NEXT: entry
209 ; CHECK-NEXT: %0 = call i8* @objc_unretainedObject(i8* %arg0)
210 ; CHECK-NEXT: ret i8* %0
211 entry:
212 %0 = call i8* @llvm.objc.unretainedObject(i8* %arg0)
213 ret i8* %0
214 }
215
216 define i8* @test_objc_unretainedPointer(i8* %arg0) {
217 ; CHECK-LABEL: test_objc_unretainedPointer
218 ; CHECK-NEXT: entry
219 ; CHECK-NEXT: %0 = call i8* @objc_unretainedPointer(i8* %arg0)
220 ; CHECK-NEXT: ret i8* %0
221 entry:
222 %0 = call i8* @llvm.objc.unretainedPointer(i8* %arg0)
223 ret i8* %0
224 }
225
226 define i8* @test_objc_retain_autorelease(i8* %arg0) {
227 ; CHECK-LABEL: test_objc_retain_autorelease
228 ; CHECK-NEXT: entry
229 ; CHECK-NEXT: %0 = call i8* @objc_retain_autorelease(i8* %arg0)
230 ; CHECK-NEXT: ret i8* %0
231 entry:
232 %0 = call i8* @llvm.objc.retain.autorelease(i8* %arg0)
233 ret i8* %0
234 }
235
236 define i32 @test_objc_sync_enter(i8* %arg0) {
237 ; CHECK-LABEL: test_objc_sync_enter
238 ; CHECK-NEXT: entry
239 ; CHECK-NEXT: %0 = call i32 @objc_sync_enter(i8* %arg0)
240 ; CHECK-NEXT: ret i32 %0
241 entry:
242 %0 = call i32 @llvm.objc.sync.enter(i8* %arg0)
243 ret i32 %0
244 }
245
246 define i32 @test_objc_sync_exit(i8* %arg0) {
247 ; CHECK-LABEL: test_objc_sync_exit
248 ; CHECK-NEXT: entry
249 ; CHECK-NEXT: %0 = call i32 @objc_sync_exit(i8* %arg0)
250 ; CHECK-NEXT: ret i32 %0
251 entry:
252 %0 = call i32 @llvm.objc.sync.exit(i8* %arg0)
253 ret i32 %0
254 }
255
256 declare i8* @llvm.objc.autorelease(i8*)
257 declare void @llvm.objc.autoreleasePoolPop(i8*)
258 declare i8* @llvm.objc.autoreleasePoolPush()
259 declare i8* @llvm.objc.autoreleaseReturnValue(i8*)
260 declare void @llvm.objc.copyWeak(i8**, i8**)
261 declare void @llvm.objc.destroyWeak(i8**)
262 declare i8* @llvm.objc.initWeak(i8**, i8*)
263 declare i8* @llvm.objc.loadWeak(i8**)
264 declare i8* @llvm.objc.loadWeakRetained(i8**)
265 declare void @llvm.objc.moveWeak(i8**, i8**)
266 declare void @llvm.objc.release(i8*)
267 declare i8* @llvm.objc.retain(i8*)
268 declare i8* @llvm.objc.retainAutorelease(i8*)
269 declare i8* @llvm.objc.retainAutoreleaseReturnValue(i8*)
270 declare i8* @llvm.objc.retainAutoreleasedReturnValue(i8*)
271 declare i8* @llvm.objc.retainBlock(i8*)
272 declare void @llvm.objc.storeStrong(i8**, i8*)
273 declare i8* @llvm.objc.storeWeak(i8**, i8*)
274 declare i8* @llvm.objc.unsafeClaimAutoreleasedReturnValue(i8*)
275 declare i8* @llvm.objc.retainedObject(i8*)
276 declare i8* @llvm.objc.unretainedObject(i8*)
277 declare i8* @llvm.objc.unretainedPointer(i8*)
278 declare i8* @llvm.objc.retain.autorelease(i8*)
279 declare i32 @llvm.objc.sync.enter(i8*)
280 declare i32 @llvm.objc.sync.exit(i8*)