summaryrefslogtreecommitdiffstats
path: root/clang/test/CodeGenObjCXX
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2016-11-18 01:08:24 +0000
committerJohn McCall <rjmccall@apple.com>2016-11-18 01:08:24 +0000
commit811b291d8c3d262b8705b6d57ccd0ca7392765d8 (patch)
treeb7c88ab232fe72c2f5dd0fb8e31b81892661e6f7 /clang/test/CodeGenObjCXX
parent2d2292009ff6715e1432a29e28d1303a1e36dacc (diff)
downloadbcm5719-llvm-811b291d8c3d262b8705b6d57ccd0ca7392765d8.tar.gz
bcm5719-llvm-811b291d8c3d262b8705b6d57ccd0ca7392765d8.zip
Forward ns_consumed delegate arguments with a move.
StartFunction enters a release cleanup for ns_consumed arguments in ARC, so we need to balance that somehow. We could teach StartFunction that it's emitting a delegating function, so that the cleanup is unnecessary, but that would be invasive and somewhat fraught. We could balance the consumed argument with an extra retain, but clearing the original variable should be easier to optimize and avoid some extra work at -O0. And there shouldn't be any difference as long as nothing else uses the argument, which should always be true for the places we emit delegate arguments. Fixes PR 27887. llvm-svn: 287291
Diffstat (limited to 'clang/test/CodeGenObjCXX')
-rw-r--r--clang/test/CodeGenObjCXX/arc-attrs.mm21
1 files changed, 21 insertions, 0 deletions
diff --git a/clang/test/CodeGenObjCXX/arc-attrs.mm b/clang/test/CodeGenObjCXX/arc-attrs.mm
index 0f0610f1721..0b64d775660 100644
--- a/clang/test/CodeGenObjCXX/arc-attrs.mm
+++ b/clang/test/CodeGenObjCXX/arc-attrs.mm
@@ -46,3 +46,24 @@ void templateTest() {
// CHECK-NEXT: call void @objc_storeStrong(i8** [[X]], i8* null)
// CHECK-NEXT: ret void
}
+
+// PR27887
+struct ForwardConsumed {
+ ForwardConsumed(__attribute__((ns_consumed)) id x);
+};
+
+ForwardConsumed::ForwardConsumed(__attribute__((ns_consumed)) id x) {}
+
+// CHECK: define void @_ZN15ForwardConsumedC2EP11objc_object(
+// CHECK-NOT: objc_retain
+// CHECK: store i8* {{.*}}, i8** [[X:%.*]],
+// CHECK-NOT: [[X]]
+// CHECK: call void @objc_storeStrong(i8** [[X]], i8* null)
+
+// CHECK: define void @_ZN15ForwardConsumedC1EP11objc_object(
+// CHECK-NOT: objc_retain
+// CHECK: store i8* {{.*}}, i8** [[X:%.*]],
+// CHECK: [[T0:%.*]] = load i8*, i8** [[X]],
+// CHECK-NEXT: store i8* null, i8** [[X]],
+// CHECK-NEXT: call void @_ZN15ForwardConsumedC2EP11objc_object({{.*}}, i8* [[T0]])
+// CHECK: call void @objc_storeStrong(i8** [[X]], i8* null)
OpenPOWER on IntegriCloud