diff options
author | Michael Gottesman <mgottesman@apple.com> | 2013-04-29 06:53:53 +0000 |
---|---|---|
committer | Michael Gottesman <mgottesman@apple.com> | 2013-04-29 06:53:53 +0000 |
commit | f11a6856cc28875133cef0f7bbad2b7de3a83776 (patch) | |
tree | c568dd7ffefea5d671c2bebbbbfc42a7ed6c5225 /test/Transforms/ObjCARC/contract.ll | |
parent | fe7ea985fac4abb4056fa5f020449a2802a81604 (diff) | |
download | external_llvm-f11a6856cc28875133cef0f7bbad2b7de3a83776.zip external_llvm-f11a6856cc28875133cef0f7bbad2b7de3a83776.tar.gz external_llvm-f11a6856cc28875133cef0f7bbad2b7de3a83776.tar.bz2 |
[objc-arc] Apply the RV optimization to retains next to calls in ObjCARCContract instead of ObjCARCOpts.
Turning retains into retainRV calls disrupts the data flow analysis in
ObjCARCOpts. Thus we move it as late as we can by moving it into
ObjCARCContract.
We leave in the conversion from retainRV -> retain in ObjCARCOpt since
it enables the dataflow analysis.
rdar://10813093
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@180698 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Transforms/ObjCARC/contract.ll')
-rw-r--r-- | test/Transforms/ObjCARC/contract.ll | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/test/Transforms/ObjCARC/contract.ll b/test/Transforms/ObjCARC/contract.ll index 77ad39a..3544f88 100644 --- a/test/Transforms/ObjCARC/contract.ll +++ b/test/Transforms/ObjCARC/contract.ll @@ -10,6 +10,7 @@ declare i8* @objc_retainAutoreleasedReturnValue(i8*) declare void @use_pointer(i8*) declare i8* @returner() +declare void @callee() ; CHECK: define void @test0 ; CHECK: call void @use_pointer(i8* %0) @@ -172,6 +173,60 @@ define void @test9(i8* %a, i8* %b) { ret void } + +; Turn objc_retain into objc_retainAutoreleasedReturnValue if its operand +; is a return value. + +; CHECK: define void @test10() +; CHECK: tail call i8* @objc_retainAutoreleasedReturnValue(i8* %p) +define void @test10() { + %p = call i8* @returner() + tail call i8* @objc_retain(i8* %p) nounwind + ret void +} + +; Convert objc_retain to objc_retainAutoreleasedReturnValue if its +; argument is a return value. + +; CHECK: define void @test11( +; CHECK-NEXT: %y = call i8* @returner() +; CHECK-NEXT: tail call i8* @objc_retainAutoreleasedReturnValue(i8* %y) [[NUW]] +; CHECK-NEXT: ret void +define void @test11() { + %y = call i8* @returner() + tail call i8* @objc_retain(i8* %y) nounwind + ret void +} + +; Don't convert objc_retain to objc_retainAutoreleasedReturnValue if its +; argument is not a return value. + +; CHECK: define void @test12( +; CHECK-NEXT: tail call i8* @objc_retain(i8* %y) [[NUW]] +; CHECK-NEXT: ret void +; CHECK-NEXT: } +define void @test12(i8* %y) { + tail call i8* @objc_retain(i8* %y) nounwind + ret void +} + +; Don't Convert objc_retain to objc_retainAutoreleasedReturnValue if it +; isn't next to the call providing its return value. + +; CHECK: define void @test13( +; CHECK-NEXT: %y = call i8* @returner() +; CHECK-NEXT: call void @callee() +; CHECK-NEXT: tail call i8* @objc_retain(i8* %y) [[NUW]] +; CHECK-NEXT: ret void +; CHECK-NEXT: } +define void @test13() { + %y = call i8* @returner() + call void @callee() + tail call i8* @objc_retain(i8* %y) nounwind + ret void +} + + declare void @clang.arc.use(...) nounwind ; CHECK: attributes [[NUW]] = { nounwind } |