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 | 214ca90f8e4232fb20c34a6d3de2c37c8b495102 (patch) | |
| tree | 8a7afb053b9a721b44ba6cead74833a56ec63e58 /llvm/test/Transforms | |
| parent | 9c11815978f351a810a2aa0f348fae57e945b8d4 (diff) | |
| download | bcm5719-llvm-214ca90f8e4232fb20c34a6d3de2c37c8b495102.tar.gz bcm5719-llvm-214ca90f8e4232fb20c34a6d3de2c37c8b495102.zip | |
[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
llvm-svn: 180698
Diffstat (limited to 'llvm/test/Transforms')
| -rw-r--r-- | llvm/test/Transforms/ObjCARC/contract.ll | 55 | ||||
| -rw-r--r-- | llvm/test/Transforms/ObjCARC/move-and-merge-autorelease.ll | 2 | ||||
| -rw-r--r-- | llvm/test/Transforms/ObjCARC/rv.ll | 50 |
3 files changed, 56 insertions, 51 deletions
diff --git a/llvm/test/Transforms/ObjCARC/contract.ll b/llvm/test/Transforms/ObjCARC/contract.ll index 77ad39a01c6..3544f885528 100644 --- a/llvm/test/Transforms/ObjCARC/contract.ll +++ b/llvm/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 } diff --git a/llvm/test/Transforms/ObjCARC/move-and-merge-autorelease.ll b/llvm/test/Transforms/ObjCARC/move-and-merge-autorelease.ll index 8462c70a48e..e5d2f07e45a 100644 --- a/llvm/test/Transforms/ObjCARC/move-and-merge-autorelease.ll +++ b/llvm/test/Transforms/ObjCARC/move-and-merge-autorelease.ll @@ -1,4 +1,4 @@ -; RUN: opt -S -objc-arc < %s | FileCheck %s +; RUN: opt -S -objc-arc -objc-arc-contract < %s | FileCheck %s ; The optimizer should be able to move the autorelease past two phi nodes ; and fold it with the release in bb65. diff --git a/llvm/test/Transforms/ObjCARC/rv.ll b/llvm/test/Transforms/ObjCARC/rv.ll index 589c60f9f3a..e857c9f41bb 100644 --- a/llvm/test/Transforms/ObjCARC/rv.ll +++ b/llvm/test/Transforms/ObjCARC/rv.ll @@ -136,17 +136,6 @@ define i8* @test7b() { ret i8* %p } -; Turn objc_retain into objc_retainAutoreleasedReturnValue if its operand -; is a return value. - -; CHECK: define void @test8() -; CHECK: tail call i8* @objc_retainAutoreleasedReturnValue(i8* %p) -define void @test8() { - %p = call i8* @returner() - call i8* @objc_retain(i8* %p) - ret void -} - ; Don't apply the RV optimization to autorelease if there's no retain. ; CHECK: define i8* @test9(i8* %p) @@ -235,45 +224,6 @@ define void @test15() { ret void } -; Convert objc_retain to objc_retainAutoreleasedReturnValue if its -; argument is a return value. - -; CHECK: define void @test16( -; CHECK-NEXT: %y = call i8* @returner() -; CHECK-NEXT: tail call i8* @objc_retainAutoreleasedReturnValue(i8* %y) [[NUW]] -; CHECK-NEXT: ret void -define void @test16() { - %y = call i8* @returner() - call i8* @objc_retain(i8* %y) - ret void -} - -; Don't convert objc_retain to objc_retainAutoreleasedReturnValue if its -; argument is not a return value. - -; CHECK: define void @test17( -; CHECK-NEXT: tail call i8* @objc_retain(i8* %y) [[NUW]] -; CHECK-NEXT: ret void -define void @test17(i8* %y) { - call i8* @objc_retain(i8* %y) - 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 @test18( -; 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 -define void @test18() { - %y = call i8* @returner() - call void @callee() - call i8* @objc_retain(i8* %y) - ret void -} - ; Delete autoreleaseRV+retainRV pairs. ; CHECK: define i8* @test19(i8* %p) { |

