llvm/test/Transforms/ObjCARC/weak-dce.ll
Arnold Schwaighofer 3036182e99 BasicAA: Use reachabilty instead of dominance for checking value equality in phi
cycles

This allows the value equality check to work even if we don't have a dominator
tree. Also add some more comments.

I was worried about compile time impacts and did not implement reachability but
used the dominance check in the initial patch. The trade-off was that the
dominator tree was required.
The llvm utility function isPotentiallyReachable cuts off the recursive search
after 32 visits. Testing did not show any compile time regressions showing my
worries unjustfied.

No compile time or performance regressions at O3 -flto -mavx on test-suite +
externals.

Addresses review comments from r198290.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@198400 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-03 05:47:03 +00:00

47 lines
1.5 KiB
LLVM

; RUN: opt -S -basicaa -objc-arc < %s | FileCheck %s
; rdar://11434915
; Delete the weak calls and replace them with just the net retain.
; CHECK: define void @test0(i8* %p) {
; CHECK-NEXT: call i8* @objc_retain(i8* %p)
; CHECK-NEXT: ret void
define void @test0(i8* %p) {
%weakBlock = alloca i8*, align 8
%tmp7 = call i8* @objc_initWeak(i8** %weakBlock, i8* %p) nounwind
%tmp26 = call i8* @objc_loadWeakRetained(i8** %weakBlock) nounwind
call void @objc_destroyWeak(i8** %weakBlock) nounwind
ret void
}
; CHECK: define i8* @test1(i8* %p) {
; CHECK-NEXT: call i8* @objc_retain(i8* %p)
; CHECK-NEXT: ret i8* %p
define i8* @test1(i8* %p) {
%weakBlock = alloca i8*, align 8
%tmp7 = call i8* @objc_initWeak(i8** %weakBlock, i8* %p) nounwind
%tmp26 = call i8* @objc_loadWeakRetained(i8** %weakBlock) nounwind
call void @objc_destroyWeak(i8** %weakBlock) nounwind
ret i8* %tmp26
}
; CHECK: define i8* @test2(i8* %p, i8* %q) {
; CHECK-NEXT: call i8* @objc_retain(i8* %q)
; CHECK-NEXT: ret i8* %q
define i8* @test2(i8* %p, i8* %q) {
%weakBlock = alloca i8*, align 8
%tmp7 = call i8* @objc_initWeak(i8** %weakBlock, i8* %p) nounwind
%tmp19 = call i8* @objc_storeWeak(i8** %weakBlock, i8* %q) nounwind
%tmp26 = call i8* @objc_loadWeakRetained(i8** %weakBlock) nounwind
call void @objc_destroyWeak(i8** %weakBlock) nounwind
ret i8* %tmp26
}
declare i8* @objc_initWeak(i8**, i8*)
declare void @objc_destroyWeak(i8**)
declare i8* @objc_loadWeakRetained(i8**)
declare i8* @objc_storeWeak(i8** %weakBlock, i8* %q)