diff options
author | Dan Gohman <gohman@apple.com> | 2011-10-17 22:53:25 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2011-10-17 22:53:25 +0000 |
commit | a974beaa1f63394a67c38c66ff0f39a759c7998f (patch) | |
tree | 4e9f7d7952796d1c49af0fd679f0108320d0bb44 /test/Transforms/ObjCARC | |
parent | fa1ee880520d8da1168278c65575241487f871df (diff) | |
download | external_llvm-a974beaa1f63394a67c38c66ff0f39a759c7998f.zip external_llvm-a974beaa1f63394a67c38c66ff0f39a759c7998f.tar.gz external_llvm-a974beaa1f63394a67c38c66ff0f39a759c7998f.tar.bz2 |
Teach the ARC optimizer about the !clang.arc.copy_on_escape metadata
tag on objc_retainBlock calls, which indicates that they may be
optimized away. rdar://10211286.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@142298 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Transforms/ObjCARC')
-rw-r--r-- | test/Transforms/ObjCARC/retain-block-alloca.ll | 46 |
1 files changed, 41 insertions, 5 deletions
diff --git a/test/Transforms/ObjCARC/retain-block-alloca.ll b/test/Transforms/ObjCARC/retain-block-alloca.ll index 468da91..01f2087 100644 --- a/test/Transforms/ObjCARC/retain-block-alloca.ll +++ b/test/Transforms/ObjCARC/retain-block-alloca.ll @@ -1,11 +1,6 @@ ; RUN: opt -S -objc-arc < %s | FileCheck %s ; rdar://10209613 -; CHECK: define void @test -; CHECK: %3 = call i8* @objc_retainBlock(i8* %2) nounwind -; CHECK: @objc_msgSend -; CHECK-NEXT: @objc_release(i8* %3) - %0 = type opaque %struct.__block_descriptor = type { i64, i64 } @@ -13,6 +8,10 @@ @__block_descriptor_tmp = external hidden constant { i64, i64, i8*, i8*, i8*, i8* } @"\01L_OBJC_SELECTOR_REFERENCES_" = external hidden global i8*, section "__DATA, __objc_selrefs, literal_pointers, no_dead_strip" +; CHECK: define void @test( +; CHECK: %3 = call i8* @objc_retainBlock(i8* %2) nounwind +; CHECK: @objc_msgSend +; CHECK-NEXT: @objc_release(i8* %3) define void @test(%0* %array) uwtable { entry: %block = alloca <{ i8*, i32, i32, i8*, %struct.__block_descriptor*, %0* }>, align 8 @@ -41,6 +40,43 @@ entry: ret void } +; Same as test, but the objc_retainBlock has a clang.arc.copy_on_escape +; tag so it's safe to delete. + +; CHECK: define void @test_with_COE( +; CHECK-NOT: @objc_retainBlock +; CHECK: @objc_msgSend +; CHECK: @objc_release +; CHECK-NOT: @objc_release +; CHECK: } +define void @test_with_COE(%0* %array) uwtable { +entry: + %block = alloca <{ i8*, i32, i32, i8*, %struct.__block_descriptor*, %0* }>, align 8 + %0 = bitcast %0* %array to i8* + %1 = tail call i8* @objc_retain(i8* %0) nounwind + %block.isa = getelementptr inbounds <{ i8*, i32, i32, i8*, %struct.__block_descriptor*, %0* }>* %block, i64 0, i32 0 + store i8* bitcast (i8** @_NSConcreteStackBlock to i8*), i8** %block.isa, align 8 + %block.flags = getelementptr inbounds <{ i8*, i32, i32, i8*, %struct.__block_descriptor*, %0* }>* %block, i64 0, i32 1 + store i32 1107296256, i32* %block.flags, align 8 + %block.reserved = getelementptr inbounds <{ i8*, i32, i32, i8*, %struct.__block_descriptor*, %0* }>* %block, i64 0, i32 2 + store i32 0, i32* %block.reserved, align 4 + %block.invoke = getelementptr inbounds <{ i8*, i32, i32, i8*, %struct.__block_descriptor*, %0* }>* %block, i64 0, i32 3 + store i8* bitcast (void (i8*)* @__test_block_invoke_0 to i8*), i8** %block.invoke, align 8 + %block.descriptor = getelementptr inbounds <{ i8*, i32, i32, i8*, %struct.__block_descriptor*, %0* }>* %block, i64 0, i32 4 + store %struct.__block_descriptor* bitcast ({ i64, i64, i8*, i8*, i8*, i8* }* @__block_descriptor_tmp to %struct.__block_descriptor*), %struct.__block_descriptor** %block.descriptor, align 8 + %block.captured = getelementptr inbounds <{ i8*, i32, i32, i8*, %struct.__block_descriptor*, %0* }>* %block, i64 0, i32 5 + store %0* %array, %0** %block.captured, align 8 + %2 = bitcast <{ i8*, i32, i32, i8*, %struct.__block_descriptor*, %0* }>* %block to i8* + %3 = call i8* @objc_retainBlock(i8* %2) nounwind, !clang.arc.copy_on_escape !0 + %tmp2 = load i8** @"\01L_OBJC_SELECTOR_REFERENCES_", align 8 + call void bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to void (i8*, i8*, i8*)*)(i8* %0, i8* %tmp2, i8* %3) + call void @objc_release(i8* %3) nounwind + %strongdestroy = load %0** %block.captured, align 8 + %4 = bitcast %0* %strongdestroy to i8* + call void @objc_release(i8* %4) nounwind, !clang.imprecise_release !0 + ret void +} + declare i8* @objc_retain(i8*) declare void @__test_block_invoke_0(i8* nocapture) uwtable |