summaryrefslogtreecommitdiffstats
path: root/clang/test/CodeGenObjC
diff options
context:
space:
mode:
authorAkira Hatanaka <ahatanaka@apple.com>2019-06-04 16:29:58 +0000
committerAkira Hatanaka <ahatanaka@apple.com>2019-06-04 16:29:58 +0000
commit48566aaab461e014dc8350c2ddd6012e34ffe434 (patch)
treecc19a82f86b893a4cf0512432251b747a7a750dc /clang/test/CodeGenObjC
parentd98a0a362fbe004be2954857551c0274b09bd635 (diff)
downloadbcm5719-llvm-48566aaab461e014dc8350c2ddd6012e34ffe434.tar.gz
bcm5719-llvm-48566aaab461e014dc8350c2ddd6012e34ffe434.zip
[CodeGen][ObjC] Convert '[self alloc]' in a class method to a call to
'objc_alloc(self)' Also convert '[[self alloc] init]' in a class method to a call to 'objc_alloc_init(self)'. rdar://problem/50855121 Differential Revision: https://reviews.llvm.org/D62643 llvm-svn: 362521
Diffstat (limited to 'clang/test/CodeGenObjC')
-rw-r--r--clang/test/CodeGenObjC/convert-messages-to-runtime-calls.m28
-rw-r--r--clang/test/CodeGenObjC/objc-alloc-init.m6
2 files changed, 34 insertions, 0 deletions
diff --git a/clang/test/CodeGenObjC/convert-messages-to-runtime-calls.m b/clang/test/CodeGenObjC/convert-messages-to-runtime-calls.m
index 6a4edfd0979..c51b56b66ff 100644
--- a/clang/test/CodeGenObjC/convert-messages-to-runtime-calls.m
+++ b/clang/test/CodeGenObjC/convert-messages-to-runtime-calls.m
@@ -150,6 +150,34 @@ float test_cannot_message_return_float(C *c) {
return [c retain];
}
+@interface TestSelf
++ (instancetype)alloc;
++ (instancetype)allocWithZone:(void*)zone;
++ (id)classMeth;
+- (id)instanceMeth;
+@end
+
+@implementation TestSelf
+// CHECK-LABEL: define internal i8* @"\01+[TestSelf classMeth]"(
++ (id)classMeth {
+ // MSGS: {{call.*@objc_msgSend}}
+ // MSGS: {{call.*@objc_msgSend}}
+ // CALLS: {{call.*@objc_allocWithZone\(}}
+ // CALLS: {{call.*@objc_alloc\(}}
+ [self allocWithZone:nil];
+ return [self alloc];
+}
+// CHECK-LABEL: define internal i8* @"\01-[TestSelf instanceMeth]"(
+- (id)instanceMeth {
+ // MSGS: {{call.*@objc_msgSend}}
+ // MSGS: {{call.*@objc_msgSend}}
+ // CALLS: {{call.*@objc_msgSend}}
+ // CALLS: {{call.*@objc_msgSend}}
+ [self allocWithZone:nil];
+ return [self alloc];
+}
+@end
+
@interface NSString : NSObject
+ (void)retain_self;
- (void)retain_super;
diff --git a/clang/test/CodeGenObjC/objc-alloc-init.m b/clang/test/CodeGenObjC/objc-alloc-init.m
index 08a383d59f6..c5c1a763b7c 100644
--- a/clang/test/CodeGenObjC/objc-alloc-init.m
+++ b/clang/test/CodeGenObjC/objc-alloc-init.m
@@ -23,14 +23,20 @@ void f() {
@interface Y : X
+(void)meth;
+-(void)instanceMeth;
@end
@implementation Y
+(void)meth {
[[self alloc] init];
+ // OPTIMIZED: call i8* @objc_alloc_init(
+ // NOT_OPTIMIZED: call i8* @objc_alloc(
+}
+-(void)instanceMeth {
// EITHER-NOT: call i8* @objc_alloc
// EITHER: call {{.*}} @objc_msgSend
// EITHER: call {{.*}} @objc_msgSend
+ [[self alloc] init];
}
@end
OpenPOWER on IntegriCloud