1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108
|
; RUN: opt -passes=objc-arc -S < %s | FileCheck %s
declare void @llvm.objc.release(ptr %x)
declare ptr @llvm.objc.retain(ptr %x)
declare ptr @llvm.objc.autorelease(ptr %x)
declare ptr @llvm.objc.autoreleaseReturnValue(ptr %x)
declare ptr @llvm.objc.retainAutoreleasedReturnValue(ptr %x)
declare ptr @llvm.objc.unsafeClaimAutoreleasedReturnValue(ptr %x)
declare ptr @tmp(ptr)
; Never tail call objc_autorelease.
; CHECK: define ptr @test0(ptr %x) [[NUW:#[0-9]+]] {
; CHECK: %tmp0 = call ptr @llvm.objc.autorelease(ptr %x) [[NUW]]
; CHECK: %tmp1 = call ptr @llvm.objc.autorelease(ptr %x) [[NUW]]
; CHECK: }
define ptr @test0(ptr %x) nounwind {
entry:
%tmp0 = call ptr @llvm.objc.autorelease(ptr %x)
%tmp1 = tail call ptr @llvm.objc.autorelease(ptr %x)
ret ptr %x
}
; Always tail call autoreleaseReturnValue.
; CHECK: define ptr @test1(ptr %x) [[NUW]] {
; CHECK: %tmp0 = tail call ptr @llvm.objc.autoreleaseReturnValue(ptr %x) [[NUW]]
; CHECK: %tmp1 = tail call ptr @llvm.objc.autoreleaseReturnValue(ptr %x) [[NUW]]
; CHECK: }
define ptr @test1(ptr %x) nounwind {
entry:
%tmp0 = call ptr @llvm.objc.autoreleaseReturnValue(ptr %x)
%tmp1 = tail call ptr @llvm.objc.autoreleaseReturnValue(ptr %x)
ret ptr %x
}
; Always tail call objc_retain.
; CHECK: define ptr @test2(ptr %x) [[NUW]] {
; CHECK: %tmp0 = tail call ptr @llvm.objc.retain(ptr %x) [[NUW]]
; CHECK: %tmp1 = tail call ptr @llvm.objc.retain(ptr %x) [[NUW]]
; CHECK: }
define ptr @test2(ptr %x) nounwind {
entry:
%tmp0 = call ptr @llvm.objc.retain(ptr %x)
%tmp1 = tail call ptr @llvm.objc.retain(ptr %x)
ret ptr %x
}
; Always tail call objc_retainAutoreleasedReturnValue unless it's annotated with
; notail.
; CHECK: define ptr @test3(ptr %x) [[NUW]] {
; CHECK: %tmp0 = tail call ptr @llvm.objc.retainAutoreleasedReturnValue(ptr %y) [[NUW]]
; CHECK: %tmp1 = tail call ptr @llvm.objc.retainAutoreleasedReturnValue(ptr %z) [[NUW]]
; CHECK: %tmp2 = notail call ptr @llvm.objc.retainAutoreleasedReturnValue(ptr %z2) [[NUW]]
; CHECK: }
define ptr @test3(ptr %x) nounwind {
entry:
%y = call ptr @tmp(ptr %x)
%tmp0 = call ptr @llvm.objc.retainAutoreleasedReturnValue(ptr %y)
%z = call ptr @tmp(ptr %x)
%tmp1 = tail call ptr @llvm.objc.retainAutoreleasedReturnValue(ptr %z)
%z2 = call ptr @tmp(ptr %x)
%tmp2 = notail call ptr @llvm.objc.retainAutoreleasedReturnValue(ptr %z2)
ret ptr %x
}
; By itself, we should never change whether or not objc_release is tail called.
; CHECK: define void @test4(ptr %x) [[NUW]] {
; CHECK: call void @llvm.objc.release(ptr %x) [[NUW]]
; CHECK: tail call void @llvm.objc.release(ptr %x) [[NUW]]
; CHECK: }
define void @test4(ptr %x) nounwind {
entry:
call void @llvm.objc.release(ptr %x)
tail call void @llvm.objc.release(ptr %x)
ret void
}
; If we convert a tail called @llvm.objc.autoreleaseReturnValue to an
; @llvm.objc.autorelease, ensure that the tail call is removed.
; CHECK: define ptr @test5(ptr %x) [[NUW]] {
; CHECK: %tmp0 = call ptr @llvm.objc.autorelease(ptr %x) [[NUW]]
; CHECK: }
define ptr @test5(ptr %x) nounwind {
entry:
%tmp0 = tail call ptr @llvm.objc.autoreleaseReturnValue(ptr %x)
ret ptr %tmp0
}
; Always tail call llvm.objc.unsafeClaimAutoreleasedReturnValue.
; CHECK: define ptr @test6(ptr %x) [[NUW]] {
; CHECK: %tmp0 = tail call ptr @llvm.objc.unsafeClaimAutoreleasedReturnValue(ptr %y) [[NUW]]
; CHECK: %tmp1 = tail call ptr @llvm.objc.unsafeClaimAutoreleasedReturnValue(ptr %z) [[NUW]]
; CHECK: }
define ptr @test6(ptr %x) nounwind {
entry:
%y = call ptr @tmp(ptr %x)
%tmp0 = call ptr @llvm.objc.unsafeClaimAutoreleasedReturnValue(ptr %y)
%z = call ptr @tmp(ptr %x)
%tmp1 = tail call ptr @llvm.objc.unsafeClaimAutoreleasedReturnValue(ptr %z)
ret ptr %x
}
; CHECK: attributes [[NUW]] = { nounwind }
|