From 32a4da04c2f5a1514148d35c67eed9257f3cfa41 Mon Sep 17 00:00:00 2001 From: John McCall Date: Wed, 3 Aug 2011 07:02:44 +0000 Subject: In ARC, don't try to reclaim the result of a call to performSelector unless done in a context where the value is used retained. llvm-svn: 136769 --- clang/test/CodeGenObjC/arc.m | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'clang/test/CodeGenObjC/arc.m') diff --git a/clang/test/CodeGenObjC/arc.m b/clang/test/CodeGenObjC/arc.m index 109e360b79b..4592710a3d0 100644 --- a/clang/test/CodeGenObjC/arc.m +++ b/clang/test/CodeGenObjC/arc.m @@ -1754,3 +1754,39 @@ void test60b(void) { // CHECK-NEXT: call void @objc_release(i8* [[T2]]) // CHECK-NEXT: ret void } + +// Verify that we don't try to reclaim the result of performSelector. +// rdar://problem/9887545 +@interface Test61 +- (id) performSelector: (SEL) selector; +- (void) test61_void; +- (id) test61_id; +@end +void test61(void) { + // CHECK: define void @test61() + // CHECK: [[Y:%.*]] = alloca i8*, align 8 + + extern id test61_make(void); + + // CHECK-NEXT: [[T0:%.*]] = call i8* @test61_make() + // CHECK-NEXT: [[T1:%.*]] = call i8* @objc_retainAutoreleasedReturnValue(i8* [[T0]]) + // CHECK-NEXT: [[T2:%.*]] = load i8** @"\01L_OBJC_SELECTOR_REFERENCES_ + // CHECK-NEXT: [[T3:%.*]] = load i8** @"\01L_OBJC_SELECTOR_REFERENCES_ + // CHECK-NEXT: [[T4:%.*]] = call i8* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to i8* (i8*, i8*, i8*)*)(i8* [[T1]], i8* [[T3]], i8* [[T2]]) + // CHECK-NEXT: call void @objc_release(i8* [[T1]]) + [test61_make() performSelector: @selector(test61_void)]; + + // CHECK-NEXT: [[T0:%.*]] = call i8* @test61_make() + // CHECK-NEXT: [[T1:%.*]] = call i8* @objc_retainAutoreleasedReturnValue(i8* [[T0]]) + // CHECK-NEXT: [[T2:%.*]] = load i8** @"\01L_OBJC_SELECTOR_REFERENCES_ + // CHECK-NEXT: [[T3:%.*]] = load i8** @"\01L_OBJC_SELECTOR_REFERENCES_ + // CHECK-NEXT: [[T4:%.*]] = call i8* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to i8* (i8*, i8*, i8*)*)(i8* [[T1]], i8* [[T3]], i8* [[T2]]) + // CHECK-NEXT: [[T5:%.*]] = call i8* @objc_retainAutoreleasedReturnValue(i8* [[T4]]) + // CHECK-NEXT: store i8* [[T5]], i8** [[Y]] + // CHECK-NEXT: call void @objc_release(i8* [[T1]]) + id y = [test61_make() performSelector: @selector(test61_id)]; + + // CHECK-NEXT: [[T0:%.*]] = load i8** [[Y]] + // CHECK-NEXT: call void @objc_release(i8* [[T0]]) + // CHECK-NEXT: ret void +} -- cgit v1.2.3