1; RUN: opt -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 6define i8* @test_objc_autorelease(i8* %arg0) { 7; CHECK-LABEL: test_objc_autorelease 8; CHECK-NEXT: entry 9; CHECK-NEXT: %0 = notail call i8* @objc_autorelease(i8* %arg0) 10; CHECK-NEXT: ret i8* %0 11entry: 12 %0 = call i8* @llvm.objc.autorelease(i8* %arg0) 13 ret i8* %0 14} 15 16define 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 21entry: 22 call void @llvm.objc.autoreleasePoolPop(i8* %arg0) 23 ret void 24} 25 26define 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 31entry: 32 %0 = call i8* @llvm.objc.autoreleasePoolPush() 33 ret i8* %0 34} 35 36define i8* @test_objc_autoreleaseReturnValue(i8* %arg0) { 37; CHECK-LABEL: test_objc_autoreleaseReturnValue 38; CHECK-NEXT: entry 39; CHECK-NEXT: %0 = tail call i8* @objc_autoreleaseReturnValue(i8* %arg0) 40; CHECK-NEXT: ret i8* %0 41entry: 42 %0 = call i8* @llvm.objc.autoreleaseReturnValue(i8* %arg0) 43 ret i8* %0 44} 45 46define 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 51entry: 52 call void @llvm.objc.copyWeak(i8** %arg0, i8** %arg1) 53 ret void 54} 55 56define 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 61entry: 62 call void @llvm.objc.destroyWeak(i8** %arg0) 63 ret void 64} 65 66define 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 71entry: 72 %0 = call i8* @llvm.objc.initWeak(i8** %arg0, i8* %arg1) 73 ret i8* %0 74} 75 76define 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 81entry: 82 %0 = call i8* @llvm.objc.loadWeak(i8** %arg0) 83 ret i8* %0 84} 85 86define 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 91entry: 92 %0 = call i8* @llvm.objc.loadWeakRetained(i8** %arg0) 93 ret i8* %0 94} 95 96define 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 101entry: 102 call void @llvm.objc.moveWeak(i8** %arg0, i8** %arg1) 103 ret void 104} 105 106define 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 111entry: 112 call void @llvm.objc.release(i8* %arg0) 113 ret void 114} 115 116define i8* @test_objc_retain(i8* %arg0) { 117; CHECK-LABEL: test_objc_retain 118; CHECK-NEXT: entry 119; CHECK-NEXT: %0 = tail call i8* @objc_retain(i8* %arg0) 120; CHECK-NEXT: ret i8* %0 121entry: 122 %0 = call i8* @llvm.objc.retain(i8* %arg0) 123 ret i8* %0 124} 125 126define 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 131entry: 132 %0 = call i8* @llvm.objc.retainAutorelease(i8* %arg0) 133 ret i8* %0 134} 135 136define 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 141entry: 142 %0 = tail call i8* @llvm.objc.retainAutoreleaseReturnValue(i8* %arg0) 143 ret i8* %0 144} 145 146define i8* @test_objc_retainAutoreleasedReturnValue(i8* %arg0) { 147; CHECK-LABEL: test_objc_retainAutoreleasedReturnValue 148; CHECK-NEXT: entry 149; CHECK-NEXT: %0 = tail call i8* @objc_retainAutoreleasedReturnValue(i8* %arg0) 150; CHECK-NEXT: ret i8* %0 151entry: 152 %0 = call i8* @llvm.objc.retainAutoreleasedReturnValue(i8* %arg0) 153 ret i8* %0 154} 155 156define 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 161entry: 162 %0 = call i8* @llvm.objc.retainBlock(i8* %arg0) 163 ret i8* %0 164} 165 166define 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 171entry: 172 call void @llvm.objc.storeStrong(i8** %arg0, i8* %arg1) 173 ret void 174} 175 176define 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 181entry: 182 %0 = call i8* @llvm.objc.storeWeak(i8** %arg0, i8* %arg1) 183 ret i8* %0 184} 185 186define i8* @test_objc_unsafeClaimAutoreleasedReturnValue(i8* %arg0) { 187; CHECK-LABEL: test_objc_unsafeClaimAutoreleasedReturnValue 188; CHECK-NEXT: entry 189; CHECK-NEXT: %0 = tail call i8* @objc_unsafeClaimAutoreleasedReturnValue(i8* %arg0) 190; CHECK-NEXT: ret i8* %0 191entry: 192 %0 = call i8* @llvm.objc.unsafeClaimAutoreleasedReturnValue(i8* %arg0) 193 ret i8* %0 194} 195 196define 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 201entry: 202 %0 = call i8* @llvm.objc.retainedObject(i8* %arg0) 203 ret i8* %0 204} 205 206define 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 211entry: 212 %0 = call i8* @llvm.objc.unretainedObject(i8* %arg0) 213 ret i8* %0 214} 215 216define 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 221entry: 222 %0 = call i8* @llvm.objc.unretainedPointer(i8* %arg0) 223 ret i8* %0 224} 225 226define 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 231entry: 232 %0 = call i8* @llvm.objc.retain.autorelease(i8* %arg0) 233 ret i8* %0 234} 235 236define 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 241entry: 242 %0 = call i32 @llvm.objc.sync.enter(i8* %arg0) 243 ret i32 %0 244} 245 246define 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 251entry: 252 %0 = call i32 @llvm.objc.sync.exit(i8* %arg0) 253 ret i32 %0 254} 255 256declare i8* @llvm.objc.autorelease(i8*) 257declare void @llvm.objc.autoreleasePoolPop(i8*) 258declare i8* @llvm.objc.autoreleasePoolPush() 259declare i8* @llvm.objc.autoreleaseReturnValue(i8*) 260declare void @llvm.objc.copyWeak(i8**, i8**) 261declare void @llvm.objc.destroyWeak(i8**) 262declare extern_weak i8* @llvm.objc.initWeak(i8**, i8*) 263declare i8* @llvm.objc.loadWeak(i8**) 264declare i8* @llvm.objc.loadWeakRetained(i8**) 265declare void @llvm.objc.moveWeak(i8**, i8**) 266declare void @llvm.objc.release(i8*) 267declare i8* @llvm.objc.retain(i8*) 268declare i8* @llvm.objc.retainAutorelease(i8*) 269declare i8* @llvm.objc.retainAutoreleaseReturnValue(i8*) 270declare i8* @llvm.objc.retainAutoreleasedReturnValue(i8*) 271declare i8* @llvm.objc.retainBlock(i8*) 272declare void @llvm.objc.storeStrong(i8**, i8*) 273declare i8* @llvm.objc.storeWeak(i8**, i8*) 274declare i8* @llvm.objc.unsafeClaimAutoreleasedReturnValue(i8*) 275declare i8* @llvm.objc.retainedObject(i8*) 276declare i8* @llvm.objc.unretainedObject(i8*) 277declare i8* @llvm.objc.unretainedPointer(i8*) 278declare i8* @llvm.objc.retain.autorelease(i8*) 279declare i32 @llvm.objc.sync.enter(i8*) 280declare i32 @llvm.objc.sync.exit(i8*) 281 282attributes #0 = { nounwind } 283 284; CHECK: declare i8* @objc_autorelease(i8*) 285; CHECK: declare void @objc_autoreleasePoolPop(i8*) 286; CHECK: declare i8* @objc_autoreleasePoolPush() 287; CHECK: declare i8* @objc_autoreleaseReturnValue(i8*) 288; CHECK: declare void @objc_copyWeak(i8**, i8**) 289; CHECK: declare void @objc_destroyWeak(i8**) 290; CHECK: declare extern_weak i8* @objc_initWeak(i8**, i8*) 291; CHECK: declare i8* @objc_loadWeak(i8**) 292; CHECK: declare i8* @objc_loadWeakRetained(i8**) 293; CHECK: declare void @objc_moveWeak(i8**, i8**) 294; CHECK: declare void @objc_release(i8*) [[NLB:#[0-9]+]] 295; CHECK: declare i8* @objc_retain(i8*) [[NLB]] 296; CHECK: declare i8* @objc_retainAutorelease(i8*) 297; CHECK: declare i8* @objc_retainAutoreleaseReturnValue(i8*) 298; CHECK: declare i8* @objc_retainAutoreleasedReturnValue(i8*) 299; CHECK: declare i8* @objc_retainBlock(i8*) 300; CHECK: declare void @objc_storeStrong(i8**, i8*) 301; CHECK: declare i8* @objc_storeWeak(i8**, i8*) 302; CHECK: declare i8* @objc_unsafeClaimAutoreleasedReturnValue(i8*) 303; CHECK: declare i8* @objc_retainedObject(i8*) 304; CHECK: declare i8* @objc_unretainedObject(i8*) 305; CHECK: declare i8* @objc_unretainedPointer(i8*) 306; CHECK: declare i8* @objc_retain_autorelease(i8*) 307; CHECK: declare i32 @objc_sync_enter(i8*) 308; CHECK: declare i32 @objc_sync_exit(i8*) 309 310; CHECK: attributes #0 = { nounwind } 311; CHECK: attributes [[NLB]] = { nonlazybind } 312