summaryrefslogtreecommitdiffstats
path: root/llvm/test/Transforms
diff options
context:
space:
mode:
authorMichael Gottesman <mgottesman@apple.com>2013-07-07 01:52:55 +0000
committerMichael Gottesman <mgottesman@apple.com>2013-07-07 01:52:55 +0000
commita72630d453b548d3c12d4e9ef54745943bc2b1cc (patch)
tree9864ccbdc71dc40bad2aa99c6b6a96f12c8cbdc8 /llvm/test/Transforms
parent6d715e8699ac9888168e26ff8cd8b81fd837d28a (diff)
downloadbcm5719-llvm-a72630d453b548d3c12d4e9ef54745943bc2b1cc.tar.gz
bcm5719-llvm-a72630d453b548d3c12d4e9ef54745943bc2b1cc.zip
[objc-arc] Teach the ARC optimizer that objc_sync_enter/objc_sync_exit do not modify the ref count of an objc object and additionally are inert for modref purposes.
llvm-svn: 185769
Diffstat (limited to 'llvm/test/Transforms')
-rw-r--r--llvm/test/Transforms/ObjCARC/basic.ll23
-rw-r--r--llvm/test/Transforms/ObjCARC/gvn.ll24
2 files changed, 42 insertions, 5 deletions
diff --git a/llvm/test/Transforms/ObjCARC/basic.ll b/llvm/test/Transforms/ObjCARC/basic.ll
index ca127920659..2bb312bf260 100644
--- a/llvm/test/Transforms/ObjCARC/basic.ll
+++ b/llvm/test/Transforms/ObjCARC/basic.ll
@@ -3037,9 +3037,28 @@ end: ; preds = %if.end125, %if.end1
ret void
}
-!0 = metadata !{}
-
declare i32 @__gxx_personality_v0(...)
+declare i32 @objc_sync_enter(i8*)
+declare i32 @objc_sync_exit(i8*)
+
+; Make sure that we understand that objc_sync_{enter,exit} are IC_User not
+; IC_Call/IC_CallOrUser.
+
+; CHECK: define void @test67
+; CHECK-NEXT: call i32 @objc_sync_enter(i8* %x)
+; CHECK-NEXT: call i32 @objc_sync_exit(i8* %x)
+; CHECK-NEXT: ret void
+; CHECK-NEXT: }
+define void @test67(i8* %x) {
+ call i8* @objc_retain(i8* %x)
+ call i32 @objc_sync_enter(i8* %x)
+ call i32 @objc_sync_exit(i8* %x)
+ call void @objc_release(i8* %x), !clang.imprecise_release !0
+ ret void
+}
+
+!0 = metadata !{}
+
; CHECK: attributes #0 = { nounwind readnone }
; CHECK: attributes [[NUW]] = { nounwind }
diff --git a/llvm/test/Transforms/ObjCARC/gvn.ll b/llvm/test/Transforms/ObjCARC/gvn.ll
index a828b5485f4..0773b69ee1e 100644
--- a/llvm/test/Transforms/ObjCARC/gvn.ll
+++ b/llvm/test/Transforms/ObjCARC/gvn.ll
@@ -3,20 +3,38 @@
@x = common global i8* null, align 8
declare i8* @objc_retain(i8*)
+declare i32 @objc_sync_start(i8*)
+declare i32 @objc_sync_stop(i8*)
; GVN should be able to eliminate this redundant load, with ARC-specific
; alias analysis.
-; CHECK: define i8* @foo(i32 %n)
+; CHECK: define i8* @test0(i32 %n)
; CHECK-NEXT: entry:
; CHECK-NEXT: %s = load i8** @x
; CHECK-NOT: load
; CHECK: ret i8* %s
; CHECK-NEXT: }
-define i8* @foo(i32 %n) nounwind {
+define i8* @test0(i32 %n) nounwind {
entry:
%s = load i8** @x
%0 = tail call i8* @objc_retain(i8* %s) nounwind
%t = load i8** @x
- ret i8* %s
+ ret i8* %t
+}
+
+; CHECK: define i8* @test1(i32 %n)
+; CHECK-NEXT: entry:
+; CHECK-NEXT: %s = load i8** @x
+; CHECK-NEXT: call i32 @objc_sync_start
+; CHECK-NEXT: call i32 @objc_sync_stop
+; CHECK-NEXT: ret i8* %s
+; CHECK-NEXT: }
+define i8* @test1(i32 %n) nounwind {
+entry:
+ %s = load i8** @x
+ %0 = call i32 @objc_sync_start(i8* %s)
+ %t = load i8** @x
+ %1 = call i32 @objc_sync_stop(i8* %s)
+ ret i8* %t
}
OpenPOWER on IntegriCloud