diff options
author | Michael Gottesman <mgottesman@apple.com> | 2013-04-05 22:54:28 +0000 |
---|---|---|
committer | Michael Gottesman <mgottesman@apple.com> | 2013-04-05 22:54:28 +0000 |
commit | e7ce2b3f75da1cdb657753592b73cda4252817ef (patch) | |
tree | 6240c62d8501c2d82056ecb9c9fc624089b779fe /test/Transforms/ObjCARC/intrinsic-use.ll | |
parent | 2e80991a7712d51f7637513703fc896f93eea252 (diff) | |
download | external_llvm-e7ce2b3f75da1cdb657753592b73cda4252817ef.zip external_llvm-e7ce2b3f75da1cdb657753592b73cda4252817ef.tar.gz external_llvm-e7ce2b3f75da1cdb657753592b73cda4252817ef.tar.bz2 |
Properly model precise lifetime when given an incomplete dataflow sequence.
The normal dataflow sequence in the ARC optimizer consists of the following
states:
Retain -> CanRelease -> Use -> Release
The optimizer before this patch stored the uses that determine the lifetime of
the retainable object pointer when it bottom up hits a retain or when top down
it hits a release. This is correct for an imprecise lifetime scenario since what
we are trying to do is remove retains/releases while making sure that no
``CanRelease'' (which is usually a call) deallocates the given pointer before we
get to the ``Use'' (since that would cause a segfault).
If we are considering the precise lifetime scenario though, this is not
correct. In such a situation, we *DO* care about the previous sequence, but
additionally, we wish to track the uses resulting from the following incomplete
sequences:
Retain -> CanRelease -> Release (TopDown)
Retain <- Use <- Release (BottomUp)
*NOTE* This patch looks large but the most of it consists of updating
test cases. Additionally this fix exposed an additional bug. I removed
the test case that expressed said bug and will recommit it with the fix
in a little bit.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@178921 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Transforms/ObjCARC/intrinsic-use.ll')
-rw-r--r-- | test/Transforms/ObjCARC/intrinsic-use.ll | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/test/Transforms/ObjCARC/intrinsic-use.ll b/test/Transforms/ObjCARC/intrinsic-use.ll index 9c7b81a..2f7c7c8 100644 --- a/test/Transforms/ObjCARC/intrinsic-use.ll +++ b/test/Transforms/ObjCARC/intrinsic-use.ll @@ -34,7 +34,9 @@ declare void @test0_helper(i8*, i8**) ; CHECK-NEXT: @objc_release(i8* [[VAL1]]) ; CHECK-NEXT: @objc_autorelease(i8* %x) ; CHECK-NEXT: store i8* %x, i8** %out +; CHECK-NEXT: @objc_retain(i8* %x) ; CHECK-NEXT: @objc_release(i8* [[VAL2]]) +; CHECK-NEXT: @objc_release(i8* %x) ; CHECK-NEXT: ret void define void @test0(i8** %out, i8* %x, i8* %y) { entry: @@ -61,3 +63,52 @@ entry: call void @objc_release(i8* %x) nounwind ret void } + +; CHECK: define void @test0a( +; CHECK: @objc_retain(i8* %x) +; CHECK-NEXT: store i8* %y, i8** %temp0 +; CHECK-NEXT: @objc_retain(i8* %y) +; CHECK-NEXT: call void @test0_helper +; CHECK-NEXT: [[VAL1:%.*]] = load i8** %temp0 +; CHECK-NEXT: call void (...)* @clang.arc.use(i8* %y) +; CHECK-NEXT: @objc_retain(i8* [[VAL1]]) +; CHECK-NEXT: @objc_release(i8* %y) +; CHECK-NEXT: store i8* [[VAL1]], i8** %temp1 +; CHECK-NEXT: call void @test0_helper +; CHECK-NEXT: [[VAL2:%.*]] = load i8** %temp1 +; CHECK-NEXT: call void (...)* @clang.arc.use(i8* [[VAL1]]) +; CHECK-NEXT: @objc_retain(i8* [[VAL2]]) +; CHECK-NEXT: @objc_release(i8* [[VAL1]]) +; CHECK-NEXT: @objc_autorelease(i8* %x) +; CHECK-NEXT: @objc_release(i8* [[VAL2]]) +; CHECK-NEXT: store i8* %x, i8** %out +; CHECK-NEXT: ret void +define void @test0a(i8** %out, i8* %x, i8* %y) { +entry: + %temp0 = alloca i8*, align 8 + %temp1 = alloca i8*, align 8 + %0 = call i8* @objc_retain(i8* %x) nounwind + %1 = call i8* @objc_retain(i8* %y) nounwind + store i8* %y, i8** %temp0 + call void @test0_helper(i8* %x, i8** %temp0) + %val1 = load i8** %temp0 + %2 = call i8* @objc_retain(i8* %val1) nounwind + call void (...)* @clang.arc.use(i8* %y) nounwind + call void @objc_release(i8* %y) nounwind, !clang.imprecise_release !0 + store i8* %val1, i8** %temp1 + call void @test0_helper(i8* %x, i8** %temp1) + %val2 = load i8** %temp1 + %3 = call i8* @objc_retain(i8* %val2) nounwind + call void (...)* @clang.arc.use(i8* %val1) nounwind + call void @objc_release(i8* %val1) nounwind, !clang.imprecise_release !0 + %4 = call i8* @objc_retain(i8* %x) nounwind + %5 = call i8* @objc_autorelease(i8* %x) nounwind + store i8* %x, i8** %out + call void @objc_release(i8* %val2) nounwind, !clang.imprecise_release !0 + call void @objc_release(i8* %x) nounwind, !clang.imprecise_release !0 + ret void +} + + +!0 = metadata !{} + |