summaryrefslogtreecommitdiffstats
path: root/llvm/test
diff options
context:
space:
mode:
authorMichael Gottesman <mgottesman@apple.com>2013-03-28 20:11:19 +0000
committerMichael Gottesman <mgottesman@apple.com>2013-03-28 20:11:19 +0000
commit158fdf699e3e25b55e3661518782e47768d5bf9a (patch)
treeff0b289491fbcf83a2f59a1faf84a55c279850f2 /llvm/test
parent3a52abf553570c400fdc00596c19bb4d317ab660 (diff)
downloadbcm5719-llvm-158fdf699e3e25b55e3661518782e47768d5bf9a.tar.gz
bcm5719-llvm-158fdf699e3e25b55e3661518782e47768d5bf9a.zip
[ObjCARC] Strength reduce objc_retainBlock -> objc_retain if the objc_retainBlock is optimizable.
If an objc_retainBlock has the copy_on_escape metadata attached to it AND if the block pointer argument only escapes down the stack, we are allowed to strength reduce the objc_retainBlock to to an objc_retain and thus optimize it. Current there is logic in the ARC data flow analysis to handle this case which is complicated and involved making distinctions in between objc_retainBlock and objc_retain in certain places and considering them the same in others. This patch simplifies said code by: 1. Performing the strength reduction in the initial ARC peephole analysis (ObjCARCOpts::OptimizeIndividualCalls). 2. Changes the ARC dataflow analysis (which runs after the peephole analysis) to consider all objc_retainBlock calls to not be optimizable (since if the call was optimizable, we would have strength reduced it already). This patch leaves in the infrastructure in the ARC dataflow analysis to handle this case, which due to 2 will just be dead code. I am doing this on purpose to separate the removal of the old code from the testing of the new code. <rdar://problem/13249661>. llvm-svn: 178284
Diffstat (limited to 'llvm/test')
-rw-r--r--llvm/test/Transforms/ObjCARC/basic.ll4
-rw-r--r--llvm/test/Transforms/ObjCARC/no-objc-arc-exceptions.ll7
2 files changed, 6 insertions, 5 deletions
diff --git a/llvm/test/Transforms/ObjCARC/basic.ll b/llvm/test/Transforms/ObjCARC/basic.ll
index 4c24ebf8652..bf6ccc8a7fc 100644
--- a/llvm/test/Transforms/ObjCARC/basic.ll
+++ b/llvm/test/Transforms/ObjCARC/basic.ll
@@ -795,10 +795,10 @@ entry:
ret void
}
-; Don't optimize objc_retainBlock.
+; Don't optimize objc_retainBlock, but do strength reduce it.
; CHECK: define void @test23b
-; CHECK: @objc_retainBlock
+; CHECK: @objc_retain
; CHECK: @objc_release
; CHECK: }
define void @test23b(i8* %p) {
diff --git a/llvm/test/Transforms/ObjCARC/no-objc-arc-exceptions.ll b/llvm/test/Transforms/ObjCARC/no-objc-arc-exceptions.ll
index 9728f6e0d94..58b5bbe9c7e 100644
--- a/llvm/test/Transforms/ObjCARC/no-objc-arc-exceptions.ll
+++ b/llvm/test/Transforms/ObjCARC/no-objc-arc-exceptions.ll
@@ -59,11 +59,12 @@ lpad: ; preds = %entry
resume { i8*, i32 } %t8
}
-; There is no !clang.arc.no_objc_arc_exceptions
-; metadata here, so the optimizer shouldn't eliminate anything.
+; There is no !clang.arc.no_objc_arc_exceptions metadata here, so the optimizer
+; shouldn't eliminate anything, but *CAN* strength reduce the objc_retainBlock
+; to an objc_retain.
; CHECK: define void @test0_no_metadata(
-; CHECK: call i8* @objc_retainBlock(
+; CHECK: call i8* @objc_retain(
; CHECK: invoke
; CHECK: call void @objc_release(
; CHECK: }
OpenPOWER on IntegriCloud