summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrancis Visoiu Mistrih <francisvm@yahoo.com>2019-11-04 16:45:21 -0800
committerFrancis Visoiu Mistrih <francisvm@yahoo.com>2019-11-05 06:39:22 -0800
commit68f39de042ef34ef17d93c18e80d42f2e1a970ab (patch)
treea62cc763ebacd5404044f1df7f4ef762f31fa45f
parent0016c1f40043e67068230208fd8f34657ad44b99 (diff)
downloadbcm5719-llvm-68f39de042ef34ef17d93c18e80d42f2e1a970ab.tar.gz
bcm5719-llvm-68f39de042ef34ef17d93c18e80d42f2e1a970ab.zip
[NFC][ObjC][ARC] Add tests for OptimizeRetainRVCall
Add tests for bitcasts + zero GEPs, and pre-commit tests for lifetime markers.
-rw-r--r--llvm/test/Transforms/ObjCARC/post-inlining.ll68
1 files changed, 68 insertions, 0 deletions
diff --git a/llvm/test/Transforms/ObjCARC/post-inlining.ll b/llvm/test/Transforms/ObjCARC/post-inlining.ll
index 0304d59c8b9..65b1153c136 100644
--- a/llvm/test/Transforms/ObjCARC/post-inlining.ll
+++ b/llvm/test/Transforms/ObjCARC/post-inlining.ll
@@ -46,3 +46,71 @@ entry:
call void @use_pointer(i8* %p)
ret void
}
+
+; Check that we can delete the autoreleaseRV+retainAutoreleasedRV pair even in
+; presence of instructions added by the inliner as part of the return sequence.
+
+; 1) Noop instructions: bitcasts and zero-indices GEPs.
+
+; CHECK-LABEL: define i8* @testNoop(
+; CHECK: entry:
+; CHECK-NEXT: %noop0 = bitcast i8* %call.i to i64*
+; CHECK-NEXT: %noop1 = getelementptr i8, i8* %call.i, i32 0
+; CHECK-NEXT: ret i8* %call.i
+; CHECK-NEXT: }
+define i8* @testNoop(i8* %call.i) {
+entry:
+ %0 = tail call i8* @llvm.objc.autoreleaseReturnValue(i8* %call.i) nounwind
+ %noop0 = bitcast i8* %call.i to i64*
+ %noop1 = getelementptr i8, i8* %call.i, i32 0
+ %1 = tail call i8* @llvm.objc.retainAutoreleasedReturnValue(i8* %call.i) nounwind
+ ret i8* %call.i
+}
+
+; 2) Lifetime markers.
+
+declare void @llvm.lifetime.start.p0i8(i64, i8*)
+declare void @llvm.lifetime.end.p0i8(i64, i8*)
+
+; CHECK-LABEL: define i8* @testLifetime(
+; CHECK: entry:
+; CHECK-NEXT: %obj = alloca i8
+; CHECK-NEXT: call void @llvm.lifetime.start.p0i8(i64 8, i8* %obj)
+; CHECK-NEXT: %0 = tail call i8* @llvm.objc.autoreleaseReturnValue(i8* %call.i)
+; CHECK-NEXT: call void @llvm.lifetime.end.p0i8(i64 8, i8* %obj)
+; CHECK-NEXT: %1 = tail call i8* @llvm.objc.retain(i8* %call.i)
+; CHECK-NEXT: ret i8* %call.i
+; CHECK-NEXT: }
+define i8* @testLifetime(i8* %call.i) {
+entry:
+ %obj = alloca i8
+ call void @llvm.lifetime.start.p0i8(i64 8, i8* %obj)
+ %0 = tail call i8* @llvm.objc.autoreleaseReturnValue(i8* %call.i) nounwind
+ call void @llvm.lifetime.end.p0i8(i64 8, i8* %obj)
+ %1 = tail call i8* @llvm.objc.retainAutoreleasedReturnValue(i8* %call.i) nounwind
+ ret i8* %call.i
+}
+
+; 3) Dynamic alloca markers.
+
+declare i8* @llvm.stacksave()
+declare void @llvm.stackrestore(i8*)
+
+; CHECK-LABEL: define i8* @testStack(
+; CHECK: entry:
+; CHECK-NEXT: %save = tail call i8* @llvm.stacksave()
+; CHECK-NEXT: %obj = alloca i8, i8 %arg
+; CHECK-NEXT: %0 = tail call i8* @llvm.objc.autoreleaseReturnValue(i8* %call.i)
+; CHECK-NEXT: call void @llvm.stackrestore(i8* %save)
+; CHECK-NEXT: %1 = tail call i8* @llvm.objc.retain(i8* %call.i)
+; CHECK-NEXT: ret i8* %call.i
+; CHECK-NEXT: }
+define i8* @testStack(i8* %call.i, i8 %arg) {
+entry:
+ %save = tail call i8* @llvm.stacksave()
+ %obj = alloca i8, i8 %arg
+ %0 = tail call i8* @llvm.objc.autoreleaseReturnValue(i8* %call.i) nounwind
+ call void @llvm.stackrestore(i8* %save)
+ %1 = tail call i8* @llvm.objc.retainAutoreleasedReturnValue(i8* %call.i) nounwind
+ ret i8* %call.i
+}
OpenPOWER on IntegriCloud